first commit 🚀
This commit is contained in:
commit
9d6f036ead
4 changed files with 128 additions and 0 deletions
24
backup.sh
Normal file
24
backup.sh
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/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
|
Loading…
Add table
Add a link
Reference in a new issue