Add a bup backup script
This commit is contained in:
parent
b9bf658e49
commit
520c8b0647
1 changed files with 54 additions and 0 deletions
54
backup
Normal file
54
backup
Normal file
|
@ -0,0 +1,54 @@
|
|||
#!/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/lib/docker/devicemapper/.*' \
|
||||
--exclude-rx='^/var/cache/packman/pkg/.*' \
|
||||
--exclude-rx='.*/lost\+found/.*' \
|
||||
--exclude-rx='^/home/[^/]+/\.cache/.*' \
|
||||
--exclude-rx='^/home/[^/]+/VirtualBox VMs/.*' \
|
||||
--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 \
|
||||
"${repository}"
|
Loading…
Reference in a new issue