Borg Backup Script
This is a little helper script to regulary back up your data using the Borg backup tool. I wrote this as I was frustrated with Deja-Dup, which does not allow me to exclude directories by pattern, hence I ended up with backups that were very large and took a really long time to create because they contained many directories with non-essential files (e.g. node modules or Python virtual environments). Borg backup is a simple tool that offers everything that Deja-Dup does and is easier to customize.
- Put the script in your home folder and make it executable.
- Call it regularly using e.g. cron (put e.g. "0 * * * * [your username] /home/[your username]/make_backup.sh" in your
/etc/crontab- this will call the script every hour). Please note that the script will perform its own checking to see if a new backup is necessary, so it doesn't hurt to call it very often. If you would put a specific date in crontab and it would happen that your computer is turned off at that date, crontab would not execute the backup script. By calling the script every hour we make sure that the backups are created regularly.
- Modify the arguments that you pass to the Borg CLI to customize the directories that you want to back up.
The script will check the modification date of a file called
last_backup.txt in your home directory
to decide if a new backup should be created (by default once a week). If the file does not exist it
will create it, if the backup fails it will erase it.