new script with confirmation email
This commit is contained in:
parent
9616c2ebe5
commit
cd74483e94
1 changed files with 29 additions and 0 deletions
29
docker2-backup-email.sh
Normal file
29
docker2-backup-email.sh
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get today's date for our backup filename
|
||||||
|
backupDate=$(date +'%F')
|
||||||
|
|
||||||
|
echo "Stopping all containers..." | tee docker-$backupDate.log
|
||||||
|
docker stop $(docker ps -a -q) >> docker-$backupDate.log 2>&1
|
||||||
|
|
||||||
|
# Enter backup directory
|
||||||
|
cd /home/debian/dockerbackup || exit
|
||||||
|
|
||||||
|
echo "Creating a tar archive of your docker parent folder..." | tee -a docker-$backupDate.log
|
||||||
|
tar -czvf $backupDate-backup-docker2.tar.gz /docker >> docker-$backupDate.log 2>&1
|
||||||
|
|
||||||
|
# Start ALL containers
|
||||||
|
echo "Starting all containers..." | tee -a docker-$backupDate.log
|
||||||
|
docker start $(docker ps -a -q) >> docker-$backupDate.log 2>&1
|
||||||
|
|
||||||
|
echo "Uploading backup file to BackBlaze..." | tee -a docker-$backupDate.log
|
||||||
|
rclone copy $backupDate-backup-docker2.tar.gz b2:rgm-docker2 --progress >> docker-$backupDate.log 2>&1
|
||||||
|
|
||||||
|
# remove the tar file from the main home folder after it's copied
|
||||||
|
echo "Removing local backup cache..." | tee -a docker-$backupDate.log
|
||||||
|
rm -rf $backupDate-backup-docker2.tar.gz >> docker-$backupDate.log 2>&1
|
||||||
|
|
||||||
|
# Email log to an email address
|
||||||
|
sendmail -s "Docker Backup Completed" rgmcewan@outlook.com < docker-$backupDate.log
|
||||||
|
|
||||||
|
echo "Docker Backup Completed Successfully!" | tee -a docker-$backupDate.log
|
Loading…
Reference in a new issue