Backup script for Linux servers utilizing Borg Backup https://decatec.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DecaTec 5ce609b380 Added an option for Borg compression 9 months ago
LICENSE Initial commit 2 years ago
README.md Link 2 years ago
server_backup.sh Added an option for Borg compression 9 months ago

README.md

Linux-Server-Backup

Backup script for Linux servers utilizing Borg Backup. It is based on the (German) article Backup-Strategie für Linux Server.

General information

The backup is created in two steps:

  • Whole applications are backed up separately into a (temporary) local backup directory. As an example, Nextcloud is backed up by the script Nextcloud Backup Restore. But you could also back up any other application, e.g. Wordpress (see Wordpress Backup-Restore).
  • Borg Backup is used to backup pre defined directories besides the local backup directory where the application backups are stored.

Important After cloning or downloading the repository, you'll have to edit the script so that it fits you needs (directories, applications included in the backup, etc.). All values which need to be customized are marked with TODO in the script’s comments.

Backup

Before calling the script, initialize a Borg repository using following command (using a password):

borg init -e repokey-blake2 /media/hdd2/server_backup/borg

To create a backup, simply call this script as root after your customization.

./server.backup.sh

You can also run this script with cron in order to automate the backup (In this example every night at 2 am):

0 2 * * * /home/user/scripts/server_backup.sh > /dev/null 2>&1

Restore

You can inspect the Borg repository to find a specific backup set:

borg list /media/hdd2/server_backup/borg/

A backup set can then be mounted:

mkdir -p /mnt/borg
borg mount /media/hdd2/server_backup/borg::20191006_020001 /mnt/borg

You can then copy contents from the mounted backup set (e.g. using cp).