#!/usr/bin/bash # https://gist.github.com/bradfa/a710a4e4b83b07b7a8be77cae86ff56b # https://gist.github.com/jasontbradshaw/6a69d7c9ae0c73f54200 # We name the repository directory after the system's hostname and the current # year/month. We include the year/month combo so our backup repository doesn't # continue to grow forever, and we can manually delete old ones as necessary. # name="$(hostname)" name="$(date -u +'%Y-%m-%d')" # repository_dir="$(dirname "${1:-}/gets-removed")" # repository="${repository_dir}/${name}/$(date -u +'%Y-%m')" repository=/mnt/drive/bup/ # Set the `bup` directory here so it affects all the `bup` commands. export BUP_DIR="${repository}" # Create the backup repository if it doesn't exist. if [ ! -d "${repository}" ]; then bup init chmod 700 "${repository}" fi # Do the backup as non-intrusively as possible. echo "Indexing ${name}..." nice -n19 ionice -c3 \ bup index \ --exclude='/var/tmp' \ --exclude='/var/cache' \ --exclude-rx='.*.qcow2' \ --exclude-rx='.*.journal' \ --exclude-rx='.*.wbfs' \ --exclude-rx='.*.3ds' \ --exclude-rx='.*.xci' \ --exclude-rx='.*.nsp' \ --exclude-rx='^/home/[^/]+/\.cache/.*' \ --exclude-rx='^/home/[^/]+/\.local/share/Trash/.*' \ --exclude-rx='^/home/[^/]+/\.local/share/containers/.*' \ --exclude-rx='^/home/[^/]+/\.cemu/.*' \ --exclude-rx='^/home/[^/]+/\.local/share/yuzu/.*' \ '/home' '/etc' '/var' '/srv' echo "Backing up ${name} to '${repository}'..." nice -n19 ionice -c3 \ bup save \ --name="${name}" \ --compress=9 \ -vv \ '/'