This commit is contained in:
David Tomaschik
2026-04-21 15:59:38 -07:00
parent fec16225e4
commit db2c02bd2d
27 changed files with 150 additions and 55 deletions

38
bin/linux/backup.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
set -o nounset
set -o errexit
if [ "$(uname)" != "Linux" ]; then
echo "Error: This backup script is only intended for use on Linux." >&2
exit 1
fi
DEFAULT=`echo /media/${USER}/[bB]ackup/${USER}/`
DEST="${1:-${DEFAULT}}"
function verify_dest {
arr=($1)
items=${#arr[@]}
if [ $items -ne 1 ] ; then
echo "Bad count of backup destinations." > /dev/stderr
exit 1
fi
dir="$1"
end=$((${#dir}-1))
last="${dir:$end:1}"
if [ "$last" != "/" ] ; then
echo -n "Destination $dir does not end in a /, " > /dev/stderr
echo "this is probably not what you want!" > /dev/stderr
echo "Press a key to continue, or CTRL-C to cancel." > /dev/stderr
read
fi
}
verify_dest "$DEST"
time nice rsync -Hax --delete --exclude-from="$HOME/.rsync_ignore" \
--delete-excluded "${HOME}/" "$DEST"
echo "Backup completed..."
time sync
echo "Run finished, safe to unmount."