#!/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/Backups/ # 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 fi # Do the backup as non-intrusively as possible. echo "Indexing ${name}..." nice -n19 ionice -c3 \ bup index \ --exclude-rx='^/dev/.*' \ --exclude-rx='^/proc/.*' \ --exclude-rx='^/sys/.*' \ --exclude-rx='^/tmp/.*' \ --exclude-rx='^/run/.*' \ --exclude-rx='^/mnt/.*' \ --exclude-rx='^/media/.*' \ --exclude-rx='^/var/tmp/.*' \ --exclude-rx='^/var/lib/docker/devicemapper/.*' \ --exclude-rx='^/var/cache/pacman/pkg/.*' \ --exclude-rx='.*/lost\+found/.*' \ --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/[^/]+/\.config/[^/]*chrom[^/]*/Default/File System/.*' \ --exclude-rx='^/home/[^/]+/\.config/[^/]*chrom[^/]*/Default/GPUCache/.*' \ --exclude-rx='^/home/[^/]+/\.local/share/Trash/.*' \ --exclude-rx='^/home/[^/]+/\.mozilla/firefox/[^/]+/Cache' \ --exclude-rx='^/home/[^/]+/\.gvfs' \ --exclude-rx='^/home/[^/]+/\.thumbnails/.*' \ --exclude-rx='\.pyc$' \ '/' echo "Backing up ${name} to '${repository}'..." nice -n19 ionice -c3 \ bup save \ --name="${name}" \ --compress=9 \ -vv \ '/'