| no longer need borg, ext-drive is encrypted - dotfiles - These are my dotfiles.… | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit da516cf043b452115b244b84b4d8c33b1d6620bd | |
| parent c6bcea6a0ffccebe7a17f5c9751a739cacfc57f2 | |
| Author: Jay Scott <[email protected]> | |
| Date: Sun, 15 Jan 2023 22:55:22 +0000 | |
| no longer need borg, ext-drive is encrypted | |
| Diffstat: | |
| M bin/backup.sh | 57 +++--------------------------… | |
| 1 file changed, 5 insertions(+), 52 deletions(-) | |
| --- | |
| diff --git a/bin/backup.sh b/bin/backup.sh | |
| @@ -1,57 +1,10 @@ | |
| #!/bin/sh | |
| -BORG_PASSPHRASE="$(pass misc/local-backup | head -n1)" | |
| -BORG_REPO='/data/backup' | |
| +cmd=/usr/bin/rsync | |
| +source=/home/jay | |
| +dest=/mnt/backup | |
| -export BORG_PASSPHRASE | |
| -export BORG_REPO | |
| -info() { printf "\n%s %s\n\n" "$(date)" "$*" >&2; } | |
| - | |
| -if pidof -x borg >/dev/null; then | |
| - info "Backup already running" | |
| - exit | |
| -fi | |
| - | |
| -trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM | |
| - | |
| -info "Starting backup" | |
| - | |
| -borg create \ | |
| - --verbose \ | |
| - --filter AME \ | |
| - --list \ | |
| - --stats \ | |
| - --show-rc \ | |
| - --compression lz4 \ | |
| - --exclude-caches \ | |
| - --exclude '/home/*/.cache/*' \ | |
| - --exclude '/home/*/.local/share/Steam/*' \ | |
| - ::"linux-$(date +%d-%m-%Y)" \ | |
| - /home | |
| - | |
| -backup_exit=$? | |
| - | |
| -info "Pruning repository" | |
| - | |
| -borg prune \ | |
| - --list \ | |
| - --prefix 'linux-' \ | |
| - --show-rc \ | |
| - --keep-daily 7 \ | |
| - --keep-weekly 4 \ | |
| - --keep-monthly 6 | |
| - | |
| -prune_exit=$? | |
| - | |
| -global_exit=$((backup_exit > prune_exit ? backup_exit : prune_exit)) | |
| - | |
| -if [ ${global_exit} -eq 0 ]; then | |
| - info "Backup and Prune finished successfully" | |
| -elif [ ${global_exit} -eq 1 ]; then | |
| - info "Backup and/or Prune finished with warnings" | |
| -else | |
| - info "Backup and/or Prune finished with errors" | |
| +if [ -f /mnt/.backupdrive ]; then | |
| + $cmd -avz --log-file=/mnt/usb/backup.log -avz $source $dest | |
| fi | |
| - | |
| -exit ${global_exit} |