diff options
| author | Mitsuo Tokumori <[email protected]> | 2023-11-24 16:26:29 -0500 |
|---|---|---|
| committer | Mitsuo Tokumori <[email protected]> | 2023-11-24 16:26:29 -0500 |
| commit | dc73cdfede767b55a51ec0bc01da05e2a8bfd325 (patch) | |
| tree | 75143012b5aca2824d6a9591e1914198aea6ba99 /local/bin/backup_desktop.sh | |
| parent | edbe323e1df0173d1d945d69b7c2e20a5614224d (diff) | |
| download | dotfiles-dc73cdfede767b55a51ec0bc01da05e2a8bfd325.tar.gz dotfiles-dc73cdfede767b55a51ec0bc01da05e2a8bfd325.tar.bz2 dotfiles-dc73cdfede767b55a51ec0bc01da05e2a8bfd325.zip | |
Rename backup script
Diffstat (limited to 'local/bin/backup_desktop.sh')
| -rwxr-xr-x | local/bin/backup_desktop.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/local/bin/backup_desktop.sh b/local/bin/backup_desktop.sh new file mode 100755 index 0000000..dffaf96 --- /dev/null +++ b/local/bin/backup_desktop.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Fast backup using rsync + +if [ $# -ne 2 ]; then + echo "Usage: $(basename "$0") /dev/sdX backup" + exit 1 +fi + +if [ "$(id -u)" -ne 0 ]; then + echo "This script must be run as root." + exit 1 +fi + +rsync_options="-auvP --delete" +device=$1 +name=$2 + +# Note: `name` (nor `device`) should not contain spaces + +cryptsetup open --type luks $device $name +if [ $? -ne 0 ]; then + # bad device + exit 1 +fi +mount /dev/mapper/$name /mnt/$name +# TODO: stop backing up /var. Backup is just for Postgres and Mediawiki. +# `/var` is used by too many applications. Specialy pacman that clutters it +# with cached binaries. +rsync $rsync_options /var /mnt/$name # <10G +rsync $rsync_options /home /mnt/$name # <900G +rsync $rsync_options /etc /mnt/$name # <20M +echo "Backup complete." +df -h | grep -E "${name}|var|home|etc" +umount /mnt/$name +cryptsetup close $name + +echo "All done. Check \`$ lsblk\` before unplugging the storage device." |
