This is a set of useful scripts for setting up a borg backup to a (remote) repository. Features:
- Defining variables, exclude and include patterns via config / env files
- Backup script for creating / updating backups as well as pruning
- Automated mounting of repository to a local folder for easy browsing and restoring from the archive
- Ubuntu 18.04 / 20.04
- BorgBackup 1.2
- Remote repository: Hetzner Storage Box (ssh / rsync)
- clone this repo
- copy
.env.exampleto.envand set your vars - make all scripts executable with
chmod +x *.sh
- login to remote server
- $
ssh-keygen - choose
~/.ssh/id_rsa_borgas saving key cat ~/.ssh/id_rsa_borg.pub- copy and paste above
id_rsa_borg.pubinto your backup server~/.ssh/authorized_keys - do not forget to set permissions directory and file
chmod 700 ~/.ssh; chmod 600 ~/.ssh/authorized_keys
- wget
https://github.com/borgbackup/borg/releases/download/1.2.8/borg-linuxold64 - chmod +x
borg-linuxold64 - cp
borg-linuxold64/usr/local/bin/borg - run
borg-init.shto intialize remote repo - the repo will be setup with the passphrase configured in
.env - the encryption key will be copied to the current directory - please store it in secure location and remove it
- copy
patterns.example.lsttopatterns.lstto define your included and excluded patterns, the script is using thepatterns-fromfeature - see here for details https://manpages.debian.org/testing/borgbackup/borg-patterns.1.en.html
- run
borg-backup.shto create initial backup - add entry to crontab for daily backups:
0 3 * * * /MY_PATH_TO/borg-backup/borg-backup.sh > /dev/null 2>&1
- check logfile (see .env) for results or errors
- configure restore folder in
.env, e.g./mnt/borg - run
borg-mount.sh- this will mount the repository to the defined location - now you can browse all archives and restore files via bash
- be sure to unmount the restore folder with
borg umount MY_RESTORE_FOLDER
For questions please contact [email protected]