2024-08-25 18:56:46 +00:00
|
|
|
#!/bin/bash
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo "Usage: $0 <backup_location>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo 'backing up the following folders:'
|
|
|
|
echo -e "\e[32m-------------------------------------------"
|
|
|
|
cat backup.txt
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo -e '\e[0mexclude the following folders:'
|
|
|
|
echo -e "\e[32m-------------------------------------------"
|
|
|
|
cat exclude.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo -e "\e[0mStarting Backup"
|
|
|
|
|
2024-08-25 19:31:02 +00:00
|
|
|
rsync -rptgpXh --delete-excluded --delete-before --stats --exclude-from=./exclude.txt --include-from=./backup.txt $@ > backup_data_tmp 2>&1
|
2024-08-25 18:56:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
if [ $? -eq 0 ]; then
|
2024-08-25 19:31:02 +00:00
|
|
|
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
|
2024-08-25 18:56:46 +00:00
|
|
|
else
|
2024-08-25 19:31:02 +00:00
|
|
|
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
|
2024-08-25 18:56:46 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
rm ./backup_data_tmp
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo -e "\e[0mBackup Done"
|
|
|
|
|
|
|
|
|