docker container backup with ntfy notifications
docker container backup with ntfy notifications
Section titled “docker container backup with ntfy notifications”Used in selfhosted server and also a VPS
??? note “Can be used in a set”
- [Docker Backup](docker-backup.md) to backup your yaml files and container data- [Docker Restore](docker-restore.md) to restore your yaml files and container data in the same or another host- [Docker Start](docker-start.md) to start all containers in your yaml filesScript to be modified with your own setup:
Example user: ubuntu
#!/bin/bash
# Get today's date for our backup filenamesbackupDate=$(date +'%F')
# this just prints the formated date variable to the console if you want to see it.echo "Backup date $backupDate"
# move to the path where you will keep all of yoru docker configurations and datacd /home/ubuntu/docker
cd gatewaydocker compose stopcd ../tar -czvf ./_backups/gateway-backup-$backupDate.tar.gz gatewaycd gatewaydocker compose start
cd ../comingsoondocker compose stopcd ../tar -czvf ./_backups/comingsoon-backup-$backupDate.tar.gz comingsooncd comingsoondocker compose start
# # move to the path where you will keep all of your docker configurations and datacd ../
# # now go back to home, and copy my backup file to my NASecho ""echo "Backup copy is running..."
# # copy the tar archive to your final backup locationbackuplog=$(rsync -avz -e ssh /home/ubuntu/docker/_backups ubuntu@IP:/mnt/ubuntu/backups/)
# # remove the tar file from the main home folder after it's copiedmv ./_backups/* /mnt/backups/# rm ./_backups/*
topicurl=https://ntfy.example.com/topic
curl \ -d "Date: $backupDate--- backup transfer start ---$backuplog--- backup transfer end ---
The backup is now complete.Please check for errors." \ -H "Title: docker backup - $(hostname)" \ $topicurl