Created
May 27, 2015 10:21
-
-
Save jamescarlos/d0d49f539c76e96387d0 to your computer and use it in GitHub Desktop.
Backup unRAID cache drive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LogFile=/var/log/cache_backup.log | |
BackupDir=/mnt/disk6/cache_backup | |
echo `date` "Starting cache drive backup to " $BackupDir >> $LogFile | |
#Stop plugin services located in /etc/rc.d/ | |
# enter in plugins to stop here, if any | |
# /etc/rc.d/rc.plexmediaserver stop >> $LogFile | |
#stop dockers | |
# find running docker containers | |
declare -a Containers=(`docker ps -q`) | |
# stop running containers | |
for Cont in "${Containers[@]}" | |
do | |
echo `date` " Stopping Container: " $Cont >> $LogFile | |
docker stop $Cont >> $LogFile | |
done | |
#Backup cache via rsync | |
/usr/bin/rsync -avrtH --delete /mnt/cache/ $BackupDir >> $LogFile | |
## RESTORE | |
## /usr/bin/rsync -avrtH --delete $BackupDir /mnt/cache/ | |
#Start plugin services | |
# enter in plugins to start here, if any | |
# /etc/rc.d/rc.plexmediaserver start >> $LogFile | |
#start dockers previousy stopped | |
for Cont in "${Containers[@]}" | |
do | |
echo `date` " Starting Container: " $Cont >> $LogFile | |
docker start $Cont >> $LogFile | |
done | |
echo `date` "backup Completed " $BackupDir >> $LogFile | |
# send notification | |
notify -i normal -s "Cach Drive Backup Completed" -d " Cache Drive Backup completed at `date`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment