Battle tested backup scripts

Anyone have really solid battle tested backup scripts for restic?

Right now I have a script for local and remote backup as well as a maintnance script to prune while using --keep-within as well as a check script for --read-data-subset==1G.

This all works well, as far as I can tell so far.

A few things I want to solve that I do not have done.

Fail script if it is still running. This means, if my remote backup is still running, and a cron job kicks off a new one, it doesn’t have issues. I know Restic has it’s own locking, but from my quick testing, it will still try to do more than one, and won’t error gracefully. This also needs to be limited to the specific backup, like the local won’t fail if the remote is still going.

Notification of errors. Right now I am just manually kicking off the local and remote scripts every so often, so I can baby sit it while I get used to restic as well as moving stuff from my old machine to this machine and start migrating from Backblaze’s personal backup system to B2. I don’t want an email if everything goes fine, but if there is a problem, I would like to be notified. This includes some form of notification if the backup hasn’t been done in 24 hours.

Backup validation checking, right now I use the check data random 1G segment feature, but I am not sure how reliable that really is. I know some people download specific files then compare it to their current filesystem as well.

Anything else I might have missed.

1 Like

Only addressing the notification part: you can use healthchecks.io. You notify it of success or failure by making a request to a URL they give you, and it will email you if you either don’t ping it in a while (by default 24h + 1h grace period, but configurable) or ping it with a failure.

1 Like

Looking more for notification if something fails, not that it doesn’t run. There are lots of potential error messages that could happen.

1 Like

Your backup script can check for errors and ping it with a failure, you’ll get notified either way.

1 Like

Have you looked at ResticProfile or AutoRestic

Personally, I just use cronic and run restic with -v. If it runs with no errors, I get zero output (cron doesn’t email me). If it errors, I get a very detailed output from cron as to what went wrong.

For monitoring the actual repos to ensure they’ve being modified/updated I use Zabbix, which would be way overkill for your situation.

I would really suggest you look at resticprofile, it’s great.

4 Likes

Can you post a sample? I’m using Windows

Sorry fede, cronic is a Unix based script.

1 Like

Thank you very much anyway!

If you are on Windows, I recommend using WSL2. It’s very good, probably the only good thing besides VS Code that MS has done in the last 10 years.

2 Likes

There is also NPBackup, which is basically a big CLI / GUI wrapper for restic, which handles most scenarios, adds rotating logs, supervision support, restic_password encryption, permissions…

My current implementation runs on about 100 various workloads (windows, linux, kvm backups, synology NAS…).

Perhaps you could give it a try: GitHub - netinvent/npbackup: A secure and efficient file backup solution that fits both system administrators (CLI) and end users (GUI)

PS: Sorry if this is seen as some kind of ad… But at least the software is GPL, and shows it’s restic roots :wink:

1 Like

I already have WSL installed. So you’re saying to run Cron jobs in WSL under Windows?

Just out of curiosity, why is WSL needed here ?

1 Like

If he wants to use cronic

1 Like

The only caveat to be aware of if using WSL2 to back up data from the native windows filesystem is that the I/O performance is not good:

1 Like

Okay, I’m sorry if this is out of subject, but why cronic specifically ?
My project for instance uses restic x64 (to support various windows only functions like VSS) and schedules it’s run via task manager.
Isn’t the windows task manager good enough ?

1 Like

Thanks a lot for the info.

Currently I also use only Windows and I launch the backups with the Task Scheduler

I was just curious to know how to implement those reports as I am working on Windows scripts to do automatic checks of various backups and wanted to get a general overview.

Personally, I just use cronic and run restic with -v. If it runs with no errors, I get zero output (cron doesn’t email me). If it errors, I get a very detailed output from cron as to what went wrong.

@fede That’s exactly the job my project does.
Launch backups, housekeeping (eg check + forget + prune) and report all that to prometheus or a local file :wink:

On top, my solution has an orchestrator, where you define group settings (retention policies, upload speeds…) and then launch group operations on all repos from group.

Perhaps you could have a look ? (Sorry if I’m doing some advertisement, but I’m desperate to get some feedback before going RTM).

1 Like

First of all, thanks for the reply!

I’m working on something simpler and in my case the report was sent to me by email.
I’d like to improve the reporting part, perhaps with “verbose”.

My idea is to use an old notebook to automatically check a few different backups once a week.

You’re obviously 1000 steps ahead!

Sure! But remember that I’m not an expert, so I may not be able to contribute much once your code is up and running.

:grinning:

I’m not searching contributions (even if they’re welcome), but more feedback.
I’m releasing a RC5 today (with restic 0.17.1 baked in).
Perhaps you could just give the viewer a try, and perhaps tell me if the GUI makes sense to you ^^

If the project happens to please to you, I could (quickly) bake in mail alert support so perhaps you could use that project which is quite battle tested now.

1 Like