Skip to content

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Restic-Backup

Shell scripts to automate backup of a folder to a Backblaze B2 bucket or another local folder using Restic.

Environment Variables

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 at REMOTEPATH.
  • 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 the forget command (e.g. --keep-last 3 --keep-monthly 6 --keep-yearly 25).
  • BACKUPOPTIONS - Additional options passed to the backup command (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.

Actions

  • 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 forget command to mark certain snapshots for deletion. Uses the RETENTIONPOLICY from vars.sh to target the snapshots to be deleted.
  • Prune - Runs a prune command 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.

Usage

Run main.sh and pick a command.

About

Shell scripts to automate backup of a folder to a Backblaze B2 bucket using Restic.

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Contributors

Languages