Skip to content

Instantly share code, notes, and snippets.

@MrMastodonFarm
Forked from jamescarlos/cache_backup.sh
Created April 28, 2024 15:53
Show Gist options
  • Select an option

  • Save MrMastodonFarm/b94af6d391f623c7abe256c8867a8cfd to your computer and use it in GitHub Desktop.

Select an option

Save MrMastodonFarm/b94af6d391f623c7abe256c8867a8cfd to your computer and use it in GitHub Desktop.
Backup unRAID cache drive
#!/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