Shell scripts to automate backup of a folder to a Backblaze B2 bucket or another local folder using Restic.
Copy or rename the vars.template.sh file to vars.sh, then fill in the empty variables:
B2_ACCOUNT_ID- Application Key ID for a BackBlaze B2 account (leave empty if using a local repo).B2_ACCOUNT_KEY- Application Key for the above Key ID (leave empty if using a local repo).RESTIC_PASSWORD- Password to the encrypted Restic repo (if running for the first time, set this to the desired password). If this is empty, you will be asked for a password when running commands.TARGETBUCKET- B2 Bucket name where the Restic repo should be. If this is left empty, the Restic repo is assumed to be a local folder atREMOTEPATH.LOCALPATH- Path to the local folder to be backed up.REMOTEPATH- Path for where the backup should be stored. When using B2, this is the path within the bucket. When using a local repo, this is the local directory path.RETENTIONPOLICY- Options passed to theforgetcommand (e.g.--keep-last 3 --keep-monthly 6 --keep-yearly 25).BACKUPOPTIONS- Additional options passed to thebackupcommand (e.g.--exclude .stversions --exclude '**/node_modules').
You can place vars.sh at an alternative path and provide it as the first argument to the script.
- Backup - Backs up the folder to the Restic repo, according to the configuration in
vars.sh. Creates a repo if one does not exist, else updates the existing backup. - Forget - Runs a
forgetcommand to mark certain snapshots for deletion. Uses theRETENTIONPOLICYfromvars.shto target the snapshots to be deleted. - Prune - Runs a
prunecommand to actually delete all snapshots that are marked for deletion, as well as any invalid snapshots. - List Backup Snapshots - Lists all backup snapshots for the configured Restic repo.
- Check Backup Integrity - Checks to see if the currently backed up snapshots are valid.
- Mount - Mounts the repo to
~/resticBackup. This can be used to restore data. - Freeform - Allows you to run any other Restic command, using the configuration in
vars.sh.
Run main.sh and pick a command.