backup/rsync_backups/rsync_backup

39 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 <file lists> <backup_location>"
exit 1
fi
echo "backing up the following folders: ${1}/backup.txt"
echo -e "\e[32m-------------------------------------------"
cat "${1}/backup.txt"
echo -e "\e[0mexclude the following folders: ${1}/exclude.txt"
echo -e "\e[32m-------------------------------------------"
cat "${1}/exclude.txt"
mkdir -p $2
echo ""
echo -e "\e[0mStarting Backup"
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. $(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. $(tail -n 17 /tmp/backup_data_tmp)" https://ntfy.locker98.com/camera_h9CQ0
fi
#rm /tmp/backup_data_tmp
echo ""
echo -e "\e[0mBackup Done"