After a recent problem with couchpotato I realized I need an automatic backup of CouchPotato, SickRage, SABnzbd, ngnix, and Plex. With the help of bmcclure937 whodirected me to https://forums.freenas.org/index.php?threads/scripts-to-report-smart-zpool-and-ups-status-hdd-cpu-t°-hdd-identification-and-backup-the-config.27365/ see script basics, and https://forums.freenas.org/index.ph...tato-sabnzbd-sickrage-plex-freenas-9-3.35444/ for the backup and restore examples. As I’m new to unix I would appreciate it if someone could check my post for accuracy. Hopefully other new users will find this helpful.
My Dataset Name =v1, all plugins installed in sabnzbd_1 except Plex is in plexmediaserver_1
I used putty to ssh into my freenas:
mkdir –p /mnt/v1/scripts /mnt/v1/backup/FreeNAS/CouchPotato /mnt/v1/backup/FreeNAS/SickRage /mnt/v1/backup/FreeNAS/SABnzbd /mnt/v1/backup/FreeNAS/nginx/ /mnt/v1/backup/FreeNAS/Plex
cd /mnt/v1/scripts
nano -w backup.sh
copy the code below and paste into nano by right clicking the mouse
#!/bin/sh
### Backup CP,SickRage,SABnzbd,Plex,nginx ###
echo ""
cp -aR /mnt/v1/jails/sabnzbd_1/var/db/couchpotato/ /mnt/v1/backup/FreeNAS/CouchPotato/
cp -aR /mnt/v1/jails/sabnzbd_1/var/db/sickrage/ /mnt/v1/backup/FreeNAS/SickRage/
cp -aR /mnt/v1/jails/sabnzbd_1/var/db/sabnzbd/ /mnt/v1/backup/FreeNAS/SABnzbd/
cp -aR /mnt/v1/jails/sabnzbd_1/usr/local/etc/nginx/nginx.conf /mnt/v1/backup/Fr$
cd /mnt/v1/jails/plexmediaserver_1/var/db/
tar cvfz /mnt/v1/backup/FreeNAS/Plex/plexdata.tar.gz plexdata
echo "Backup Complete"
save and quit the editor (for nano: Ctrl + O then Enter, and then Ctrl + X)
Add execution rights to the file:chmod +x backup.sh
Now you should have a working script, you can test it like this:./backup.sh
I created a cron job to backup at 2am everyday.
The restore script is:
#!/bin/sh
### Restore CP,SickRage,SABnzbd,Plex,nginx ###
echo ""
cp -aR /mnt/v1/backup/FreeNAS/CouchPotato/ /mnt/v1/jails/sabnzbd_1/var/db/couchpotato/
cp -aR /mnt/v1/backup/FreeNAS/SABnzbd/ /mnt/v1/jails/sabnzbd_1/var/db/sabnzbd/
cp -aR /mnt/v1/backup/FreeNAS/SickRage/ /mnt/v1/jails/sabnzbd_1/var/db/sickrage/
cp -aR /mnt/v1/backup/FreeNAS/nginx/nginx.conf /mnt/v1/jails/sabnzbd_1/usr/local/etc/nginx/
cd /mnt/v1/jails/plexmediaserver_1/var/db/
tar xvfz /mnt/v1/backup/FreeNAS/Plex/plexdata.tar.gz
echo "Restore Complete"
My Dataset Name =v1, all plugins installed in sabnzbd_1 except Plex is in plexmediaserver_1
I used putty to ssh into my freenas:
mkdir –p /mnt/v1/scripts /mnt/v1/backup/FreeNAS/CouchPotato /mnt/v1/backup/FreeNAS/SickRage /mnt/v1/backup/FreeNAS/SABnzbd /mnt/v1/backup/FreeNAS/nginx/ /mnt/v1/backup/FreeNAS/Plex
cd /mnt/v1/scripts
nano -w backup.sh
copy the code below and paste into nano by right clicking the mouse
#!/bin/sh
### Backup CP,SickRage,SABnzbd,Plex,nginx ###
echo ""
cp -aR /mnt/v1/jails/sabnzbd_1/var/db/couchpotato/ /mnt/v1/backup/FreeNAS/CouchPotato/
cp -aR /mnt/v1/jails/sabnzbd_1/var/db/sickrage/ /mnt/v1/backup/FreeNAS/SickRage/
cp -aR /mnt/v1/jails/sabnzbd_1/var/db/sabnzbd/ /mnt/v1/backup/FreeNAS/SABnzbd/
cp -aR /mnt/v1/jails/sabnzbd_1/usr/local/etc/nginx/nginx.conf /mnt/v1/backup/Fr$
cd /mnt/v1/jails/plexmediaserver_1/var/db/
tar cvfz /mnt/v1/backup/FreeNAS/Plex/plexdata.tar.gz plexdata
echo "Backup Complete"
save and quit the editor (for nano: Ctrl + O then Enter, and then Ctrl + X)
Add execution rights to the file:chmod +x backup.sh
Now you should have a working script, you can test it like this:./backup.sh
I created a cron job to backup at 2am everyday.
The restore script is:
#!/bin/sh
### Restore CP,SickRage,SABnzbd,Plex,nginx ###
echo ""
cp -aR /mnt/v1/backup/FreeNAS/CouchPotato/ /mnt/v1/jails/sabnzbd_1/var/db/couchpotato/
cp -aR /mnt/v1/backup/FreeNAS/SABnzbd/ /mnt/v1/jails/sabnzbd_1/var/db/sabnzbd/
cp -aR /mnt/v1/backup/FreeNAS/SickRage/ /mnt/v1/jails/sabnzbd_1/var/db/sickrage/
cp -aR /mnt/v1/backup/FreeNAS/nginx/nginx.conf /mnt/v1/jails/sabnzbd_1/usr/local/etc/nginx/
cd /mnt/v1/jails/plexmediaserver_1/var/db/
tar xvfz /mnt/v1/backup/FreeNAS/Plex/plexdata.tar.gz
echo "Restore Complete"
Last edited: