Abort rsync_backup if envar empty

This commit is contained in:
flyingscorpio@arch-desktop 2021-04-09 18:38:27 +02:00
parent adc06e9a1b
commit ca0da2ff03
2 changed files with 5 additions and 1 deletions

View file

@ -33,6 +33,6 @@ fileignoreconfig:
ignore_detectors:
- filename
- filename: rsync_backup.sh
checksum: a622ec17b80f20296ee7f5a7ead28a0c49b1ead256e15deb818fba57730355de
checksum: bba788ae9f66264e9e902f4c50623de8b61a9ee1ea9867a350a919a48328f448
- filename: secrets.template
checksum: c6735d96a94ea5ce4ae1b7b3c72f2a75845539cca02664929b8025bcc07a0618

View file

@ -3,4 +3,8 @@
# Backup script that uses rsync, taken from https://wiki.archlinux.org/index.php/Rsync#As_a_backup_utility
# This script should be run daily with cron or a systemd timer.
[ -z "$SETUP_COCKPIT_USER" ] && echo "SETUP_COCKPIT_USER was not set, quitting" && exit 1
[ -z "$RSYNC_BACKUP_SRC" ] && echo "RSYNC_BACKUP_SRC was not set, quitting" && exit 1
[ -z "$RSYNC_BACKUP_DEST" ] && echo "RSYNC_BACKUP_DEST was not set, quitting" && exit 1
rsync -a --delete --quiet --exclude-from=/home/"$SETUP_COCKPIT_USER"/setup-cockpit/rsync_backup_excludes "$RSYNC_BACKUP_SRC" "$RSYNC_BACKUP_DEST"