From 4876caec396525bbe1f2edb69d2bc1c8fb047dc8 Mon Sep 17 00:00:00 2001 From: locker98 Date: Tue, 27 Aug 2024 20:29:14 -0400 Subject: [PATCH] fixed relative path problem --- rsync_backups/rsync_backup | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/rsync_backups/rsync_backup b/rsync_backups/rsync_backup index 883879a..dd6a0d5 100755 --- a/rsync_backups/rsync_backup +++ b/rsync_backups/rsync_backup @@ -1,38 +1,36 @@ #!/bin/bash -if [ $# -ne 1 ]; then - echo "Usage: $0 " +if [ $# -ne 2 ]; then + echo "Usage: $0 " exit 1 fi -echo 'backing up the following folders:' +echo "backing up the following folders: ${1}/backup.txt" echo -e "\e[32m-------------------------------------------" -cat backup.txt +cat "${1}/backup.txt" -echo "" -echo "" -echo -e '\e[0mexclude the following folders:' +echo -e "\e[0mexclude the following folders: ${1}/exclude.txt" echo -e "\e[32m-------------------------------------------" -cat exclude.txt - +cat "${1}/exclude.txt" +mkdir -p $2 echo "" echo -e "\e[0mStarting Backup" -rsync -rptgpXh --delete-excluded --delete-before --stats --exclude-from=./exclude.txt --include-from=./backup.txt $@ > backup_data_tmp 2>&1 +rsync -rptgpXh --delete-excluded --delete-before --progress --stats --exclude-from="${1}/exclude.txt" --files-from="${1}/backup.txt" / $2 > /tmp/backup_data_tmp 2>&1 if [ $? -eq 0 ]; then - curl -H "Title: Backup: $(hostname)" -d "The backup on $(hostname) finished successfully. $(cat ./backup_data_tmp | grep -v '^[d-]' | grep -v '^skipping')" https://ntfy.locker98.com/camera_h9CQ0 + curl -H "Title: Backup: $(hostname)" -d "The backup on $(hostname) finished successfully. $(tail -n 17 /tmp/backup_data_tmp)" https://ntfy.locker98.com/camera_h9CQ0 else - curl -H "Title: Backup: $(hostname)" -H "Priority: urgent" -H "Tags: warning" -d "The backup on $(hostname) failed. $(cat ./backup_data_tmp | grep -v '^[d-]' | grep -v '^skipping')" https://ntfy.locker98.com/camera_h9CQ0 + curl -H "Title: Backup: $(hostname)" -H "Priority: urgent" -H "Tags: warning" -d "The backup on $(hostname) failed. $(tail -n 17 /tmp/backup_data_tmp)" https://ntfy.locker98.com/camera_h9CQ0 fi -rm ./backup_data_tmp +#rm /tmp/backup_data_tmp echo "" echo -e "\e[0mBackup Done"