2021-09-06 00:54:02 +00:00
|
|
|
#!/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')"
|
2022-01-10 13:47:19 +00:00
|
|
|
repository=/mnt/drive/bup/
|
2021-09-06 00:54:02 +00:00
|
|
|
|
|
|
|
# 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
|
2022-01-10 13:47:19 +00:00
|
|
|
chmod 700 "${repository}"
|
2021-09-06 00:54:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Do the backup as non-intrusively as possible.
|
|
|
|
echo "Indexing ${name}..."
|
|
|
|
nice -n19 ionice -c3 \
|
|
|
|
bup index \
|
2022-01-10 01:42:49 +00:00
|
|
|
--exclude='/var/tmp' \
|
|
|
|
--exclude='/var/cache' \
|
2021-09-06 00:56:35 +00:00
|
|
|
--exclude-rx='.*.qcow2' \
|
2021-09-06 01:49:41 +00:00
|
|
|
--exclude-rx='.*.journal' \
|
2021-09-06 02:02:45 +00:00
|
|
|
--exclude-rx='.*.wbfs' \
|
|
|
|
--exclude-rx='.*.3ds' \
|
|
|
|
--exclude-rx='.*.xci' \
|
|
|
|
--exclude-rx='.*.nsp' \
|
2021-09-06 00:54:02 +00:00
|
|
|
--exclude-rx='^/home/[^/]+/\.cache/.*' \
|
|
|
|
--exclude-rx='^/home/[^/]+/\.local/share/Trash/.*' \
|
2022-01-09 20:54:26 +00:00
|
|
|
--exclude-rx='^/home/[^/]+/\.local/share/containers/.*' \
|
|
|
|
--exclude-rx='^/home/[^/]+/\.cemu/.*' \
|
|
|
|
--exclude-rx='^/home/[^/]+/\.local/share/yuzu/.*' \
|
2022-01-10 01:42:49 +00:00
|
|
|
'/home' '/etc' '/var' '/srv'
|
2021-09-06 00:54:02 +00:00
|
|
|
|
|
|
|
echo "Backing up ${name} to '${repository}'..."
|
|
|
|
nice -n19 ionice -c3 \
|
|
|
|
bup save \
|
|
|
|
--name="${name}" \
|
|
|
|
--compress=9 \
|
|
|
|
-vv \
|
2021-09-06 01:47:23 +00:00
|
|
|
'/'
|