Add backups/backup_dokuwiki.sh

This commit is contained in:
2025-01-13 19:42:59 +11:00
parent 620b8d73f0
commit e2820ebc30

View File

@@ -0,0 +1,37 @@
#/bin/bash
#docker config colder
docker_conf=/home/bsncubed/docker
now=$( date '+%F_%H%M%S' )
cd $docker_conf
#remove old temp files
rm /tmp/dokuwiki_*.tar.gz
docker stop dokuwiki
tar cvzf /tmp/dokuwiki_$now.tar.gz dokuwiki
#tar error reporting
if [ $? -eq 0 ]
then
echo "send succsess"
else
curl -H "Content-Type: application/json" -d '{"content":"Dokuwiki backup **DID NOT COMPLETE**. It was at **Tar**","embeds":null,"username":"Dr Backup","avatar_url":"PIC URL","attachments":[]}' "DISCORD WEBHOOK"
exit
fi
rsync -a /tmp/dokuwiki_$now.tar.gz moria.s0.is:backup_drive/Ben/dokuwiki
#rsync error reporting
if [ $? -eq 0 ]
then
echo "send succsessed"
else
curl -H "Content-Type: application/json" -d '{"content":"Dokuwiki backup **DID NOT COMPLETE** . It was at **rsync**","embeds":null,"username":"Dr Backup","avatar_url":"PIC URL","attachments":[]}' "DISCORD WEBHOOK"
exit
fi
cd dokuwiki
docker compose up -d
if [ $? -eq 0 ]
then
curl -H "Content-Type: application/json" -d '{"content":"Dokuwiki backup completed sucsesfully <@264643868081782795>","embeds":null,"username":"Dr Backup","avatar_url":"PIC URL","attachments":[]}' "DISCORD WEBHOOK"
else
curl -H "Content-Type: application/json" -d '{"content":"Dokuwiki backup **DID NOT COMPLETE** <@264643868081782795>. It was at **docker**","embeds":null,"username":"Dr Backup","avatar_url":"PIC URL","attachments":[]}' "DISCORD WEBHOOK"
exit
fi