Scheduling a second backup

I’ve been using Restic for a week or so now, and absolutely love it. Currently I have my (Linux) home directory backed up to a OneDrive repository, which I’ve automated using Cron. Here’s the shell script that Cron runs.

restic -r rclone:onedrive:Backup backup ~/
restic -r rclone:onedrive:Backup forget --keep-within-daily 7d --keep-within-weekly 1m --keep-within-monthly 1y --prune

I would like to back up to a second repository on an external storage drive. What’s the best way to do this? And since my backup script runs when I power up my machine, should I lock my home directory beforehand? If so, how?

if your question is about backing up the same folder to multiple/different repositories you can do that by running 2 backup jobs.
Of course it means that you’ll have to create another repository on the external storage you want to use.

something I personally do is setting my restic config as ENV variables and check each time if the remote repository exists or not ( just in case I remove it and forget about it )

# Repo check 
if ([ -z "$(restic cat config)" ]) 2>/dev/null;
  restic init               
  echo "Repo Initialized"                  

Hope my answer helped you !

1 Like

Thanks, @Sofiane. Is running two backup jobs the preferred method? I’ve read that you can also use restic copy or rclone to sync the second repo with the first. Simply running a second backup job seems much easier.

Your checking that the target repo exists seems like a sensible fail-safe. Thank you!

I run multiple backup jobs and it works great.

1 Like

Do you lock your directory before backing it up, @rawtaz, or do you not find that necessary? Since I back up automatically upon reboot, I find myself tempted to start work before the backup is completed, meaning that (in principle at least) I have files open while it is underway.

No, I don’t lock anything. Restic will be able to read files even if you have them open. If there is some file it cannot read, it will tell you in the output from the backup run.

1 Like

Thanks, @rawtaz. Good to know.

1 Like