Backup CP, SickRage, SABnabd, nginx, and Plex for newbies

Status
Not open for further replies.

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
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.
Cron4.jpg


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:

pirateghost

Unintelligible Geek
Joined
Feb 29, 2012
Messages
4,219
I prefer to keep each application in it's own dataset, mount that as storage and utilize snapshots. Anything that gets broken can be rolled back.
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
it looks like I'm getting a cron error /scripts/backup.sh not found. I changed the lines for
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
to
mkdir –p /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
and
cd /mnt/v1/scripts to cd /scripts to put the scripts into a subdir /scripts in the root so it can be found.
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
I did it because I got the error "/scripts/backup.sh: not found in an email after the cron job ran. Originally I had it in the /mnt/v1/scripts directory but after moving it to the root I got the same error. I'm not sure what I'm doing incorrectly. BTW I'm not familar with how to use snapshots so I thought this would be easier <G>.
 

Steve Brown

Explorer
Joined
May 7, 2015
Messages
80
NasKar you probably didnt change the name of your pool/dataset. His is named v1 which is probably not the same as yours or maybe it is. However mine is labeled "data". Also I use RSYNC to backup these directories which only copy's the data if it has changed.

just replace "cp -aR" with "rsync -rv"
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
Steve Brown I'm not familar with Rsync but will look into it. Do you have it run a script from a cron job? My cron job isn't working I'm not sure why but I can run the script manually.
 

Steve Brown

Explorer
Joined
May 7, 2015
Messages
80
Yes I have it run on a cron...

here is my cron setup.
upload_2016-3-1_6-33-5.png


here is my script .. well the meat of it which is all you really need. The " Quotations are not needed " I just had them there just incase there was a space in my directory structure.
upload_2016-3-1_6-34-37.png
 

Attachments

  • upload_2016-3-1_6-34-18.png
    upload_2016-3-1_6-34-18.png
    12 KB · Views: 285

Supa

Patron
Joined
Jan 10, 2014
Messages
204
    • tar -cvfz /mnt/v1/Backups/plexdata.tar.gz /mnt/v1/jails/plexmediaserver_1/var/db/plexdata/
This fails for me.. any idea why? Literally just stops and says "error". I wonder if there's a size limit.
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
    • tar -cvfz /mnt/v1/Backups/plexdata.tar.gz /mnt/v1/jails/plexmediaserver_1/var/db/plexdata/
This fails for me.. any idea why? Literally just stops and says "error". I wonder if there's a size limit.
My guess would be you didn't do 'cd /mnt/v1/jails/plexmediaserver_1/var/db/' before the tar command.
 
Status
Not open for further replies.
Top