Script for Office Backups
This script makes backing up data semi-automatically quite simple, following the Office Backup guide.
Save the script
Save the code below (in the gre box) to a directory of your choice, for example as a new file called borg_backup.sh in a directory bin inside of your home directory.
Open the directory, in which you created this file, with your terminal. Now execute chmod +x borg_backup.sh to make the file executable.
Configure the script
Now, open the file in a plain text editor and change some parts:
Change the value behind export BORG_REPO= to the actual destination you save your backups in. Please consult the people maintaining the backups in the office for assistance.
If wished, edit the value behind BACKUP=. Here, we save almost everything within your home directory.
If you derived your pass settings from the guide mentioned above, edit the value behind export BORG_PASSCOMMAND= to set the pass entry you used for borg's password.
By default, this script excludes the .cache directory in your home folder which does not contain valuable information. If you want to exclude more, for example large downloads or git repositories, copy the line containing --exclude $HOME/.cache and adapt the path.
- The last command takes care of pruning old backups following a well-established scheme. You may edit it if you want, but please consult the borg documentation first.
#!/bin/sh # Destination for borg repository export BORG_REPO=ssh://FSFEUSER@fsfe-backup.fritz.box:22/~/Borg # Which files/directories shall be backupped? Separate with spaces BACKUP="$HOME" # command to get borg password from, in this case from within `pass` export BORG_PASSCOMMAND='pass show borg_backup' # Actual backup command # If you need to exclude more directories, copy and amend `--exclude` line borg create --verbose --stats --progress \ --one-file-system --compression lz4 --exclude-caches \ --exclude $HOME/.cache \ ::'{hostname}-{now}' \ ${BACKUP} borg prune -v --list \ --keep-within=1d \ --keep-daily=7 \ --keep-weekly=4 \ --keep-monthly=12 \ --prefix '{hostname}-'