fixed relative path problem

This commit is contained in:
locker98 2024-08-27 20:29:14 -04:00
parent c94339deca
commit 4876caec39

View File

@ -1,38 +1,36 @@
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <backup_location>"
if [ $# -ne 2 ]; then
echo "Usage: $0 <file lists> <backup_location>"
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"