scripts/backup

26 lines
776 B
Text
Raw Normal View History

2022-06-25 23:08:57 +00:00
#!/usr/bin/fish
2021-09-06 00:54:02 +00:00
# Create an incremental system backup using bup
# Useful resources:
2021-09-06 00:54:02 +00:00
# https://gist.github.com/bradfa/a710a4e4b83b07b7a8be77cae86ff56b
# https://gist.github.com/jasontbradshaw/6a69d7c9ae0c73f54200
set name (date -u +'%Y-%m-%d')
set repository /mnt/drive/bup
2021-09-06 00:54:02 +00:00
# Set the `bup` directory here so it affects all the `bup` commands.
2022-06-25 23:08:57 +00:00
export BUP_DIR=$repository
2021-09-06 00:54:02 +00:00
# Create the backup repository if it doesn't exist.
2022-06-25 23:08:57 +00:00
if test -d $repository
bup init
chmod 700 $repository
2022-06-25 23:08:57 +00:00
end
2021-09-06 00:54:02 +00:00
# Do the backup as non-intrusively as possible.
2022-06-25 23:08:57 +00:00
echo "Indexing $name..."
nice -n19 ionice -c3 bup index -vv --exclude-rx-from=(status dirname)/exclude /etc /var /srv /home/ta180m
2021-09-06 00:54:02 +00:00
2022-06-25 23:08:57 +00:00
echo "Backing up $name to $repository..."
2022-07-04 03:26:03 +00:00
nice -n19 ionice -c3 bup save -vv --name=$name --compress=9 /