24 lines
757 B
Bash
24 lines
757 B
Bash
|
#!/bin/bash
|
||
|
HOSTNAME=$(hostname -s)
|
||
|
IP=
|
||
|
SOURCE=/opt/backup/
|
||
|
DEST=/volume2/backup
|
||
|
NTFY_TOKEN=
|
||
|
NTFY_CHANNEL=https://ntfy.exmaple.tld/backups
|
||
|
|
||
|
if ping -c 1 $IP &> /dev/null
|
||
|
then
|
||
|
echo "> success"
|
||
|
# Delete old rsync.log
|
||
|
rm /var/log/rsync.log
|
||
|
# Mount synology nfs share
|
||
|
/usr/bin/mount $IP:$DEST/$HOSTNAME /mnt/backup/
|
||
|
# Backup files with rsync
|
||
|
rsync --log-file=/var/log/rsync.log --delete --stats -rlhPt $SOURCE /mnt/backup \
|
||
|
&& curl -H "Authorization: Bearer $NTFY_TOKEN" -H prio:low -d "docker-01: backup to nas succeeded" $NTFY_CHANNEL \
|
||
|
|| curl -H "Authorization: Bearer $NTFY_TOKEN" -H tags:warning -H prio:high -d "docker-01: backup to nas failed" $NTFY_CHANNEL
|
||
|
# Unmount nfs share
|
||
|
/usr/bin/umount /mnt/backup/
|
||
|
else
|
||
|
echo "> error"
|
||
|
fi
|