Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve logging for unattended backups with cron #667
I'd say that most production uses of restic would be through cron. You set backup to fire up in the dead of the night, when systems are more idle than during the day, and let it do it's job. In the morning, you expect email from cron, reporting some statistics about the run and any errors that might've occured while you were sleeping. At least that's how I usually do it.
Now, we have 2 modes of logging, the usual pretty progress bars on console, and -q quiet switch to not log at all. I'd say none of those is suitable to be used from cron. For some time I run with -q, but I missed email reports in the morning. :( Now, that I've switched to verbose logging, all those progresses come as a spam in the mailbox. What's worse, errors are hidden among lots of lines, like this:
And it's ugly as hell, you must admit. ;)
So, I propose third way of logging, suitable for unattended runs. Which would log everything, except progress.
There are at least 2 ways to do this, I'll let you decide which you prefer better.
If you prefer the second version, I'll send the required few lines of code, I already used this mechanism in some of my apps.
#974 is a great success! Thank you very much for working on this long standing issue. Finally I can read backup reports in the morning.
This is what we have now:
IOW, this would be really perfect output, based on the example and comments above:
But hey, even if you just close the ticket without any additional improvement, I'm happy and grateful, this is much better output now, compared what we had before.
Question - how do you use this? I can't see anything in the documentation that seems to suggest it turns on or off progress indicators other than -q mentioned above, and the linked bug doesn't say. Does restic automatically detect whether it's being run interactively? I have cron and windows scheduler run restic so this is of interest.