Easy Backup Guide for CouchPotato, SABnzbd, SickRage, & Plex - FreeNAS 9.3

Status
Not open for further replies.

statik

Explorer
Joined
Sep 8, 2013
Messages
71
I spent too many hours gathering this information, so why not share it to help you. The following commands will backup the configs/settings for CouchPotato, SABnzbd, SickRage and the configs and database for Plex. Be warned, depending on how many multimedia items you have added to Plex will affect how long it will take to backup. I have 1k+ movies and 30+ tv shows on my plex and it took about twenty minutes making the backup 9Gb. Obviously you can change any of the datasets or folder names are you please, below is what I did.

This quick guide is not intended for "noobs", but is for at least Tier 2 level skilled technicians.

1 ) In the FreeNAS GUI create a dataset for backups
- I created "/mnt/VolumeData/Backup"

2 ) In the FreeNAS GUI create a Share linked to the Backup dataset you just created
- I created the share "Backup"

Assuming you already have CouchPotato, SABnzbd, SickRage, & Plex installed and configured.

3 ) Create the following folder structure in your "Backups" dataset
- FreeNAS
- CouchPotato
- Plex
- SABnzbd
- SickRage


4 ) In the FreeNAS Shell, run the following comands:

- CouchPotato

*backup
cp /mnt/VolumeData/jails/couchpotato_1/var/db/couchpotato/settings.conf /mnt/VolumeData/Backup/FreeNAS/CouchPotato/

*restore
cp /mnt/VolumeData/Backup/FreeNAS/CouchPotato/settings.conf /mnt/VolumeData/jails/couchpotato_1/var/db/couchpotato/


- SABnzbd

*backup
cp /mnt/VolumeData/jails/sabnzbd_1/var/db/sabnzbd/sabnzbd.ini /mnt/VolumeData/Backup/FreeNAS/SABnzbd/

*restore
cp /mnt/VolumeData/Backup/FreeNAS/SABnzbd/sabnzbd.ini /mnt/VolumeData/jails/sabnzbd_1/var/db/sabnzbd/


- SickRage

*backup
cp /mnt/VolumeData/jails/sickrage_1/var/db/sickrage/config.ini /mnt/VolumeData/Backup/FreeNAS/SickRage/

*restore
cp /mnt/VolumeData/Backup/FreeNAS/SickRage/config.ini /mnt/VolumeData/jails/sickrage_1/var/db/sickrage/


- PLEX

*backup
cd /mnt/VolumeData/jails/plexmediaserver_1/var/db/
tar cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz plexdata

*restore
cd /mnt/VolumeData/jails/plexmediaserver_1/var/db/
tar xvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz
 
Last edited:

statik

Explorer
Joined
Sep 8, 2013
Messages
71
*saved
 

depasseg

FreeNAS Replicant
Joined
Sep 16, 2014
Messages
2,874
Great post, thanks for pulling this together.

One question: Why not write the Plex backup and restore as one line, so it can be scripted (or run via cron)?
Backup:
tar -cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz /mnt/VolumeData/jails/plexmediaserver_1/var/db/plexdata/
Restrore:
tar xvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz /mnt/VolumeData/jails/plexmediaserver_1/var/db/
 

statik

Explorer
Joined
Sep 8, 2013
Messages
71
Great post, thanks for pulling this together.

One question: Why not write the Plex backup and restore as one line, so it can be scripted (or run via cron)?
Backup:
tar -cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz /mnt/VolumeData/jails/plexmediaserver_1/var/db/plexdata/
Restrore:
tar xvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz /mnt/VolumeData/jails/plexmediaserver_1/var/db/

That works as well, either way same result. Thanks for the input.
 

bmcclure937

Contributor
Joined
Jul 13, 2012
Messages
110
Thanks for this useful thread. I do not use Plex but I do use Emby, so I might follow a similar approach for the Emby Media Server database (tar).

For CP, SR, and SAB you only ever backup the config file? I know CP will lose wanted, media library, quality profiles, and cached images (all stored within the data directory). Why not backup the entire /var/db/couchpotato directory and have it available in case you need to restore?

Thanks
 

Supa

Patron
Joined
Jan 10, 2014
Messages
204
Fixed formatting a bit:

  • CouchPotato
    • Backup
      • cp /mnt/VolumeData/jails/couchpotato_1/var/db/couchpotato/settings.conf /mnt/VolumeData/Backup/FreeNAS/CouchPotato/
    • Restore
      • cp /mnt/VolumeData/Backup/FreeNAS/CouchPotato/settings.conf /mnt/VolumeData/jails/couchpotato_1/var/db/couchpotato/
  • SickRage
    • Backup
      • cp /mnt/VolumeData/jails/sickrage_1/var/db/sickrage/config.ini /mnt/VolumeData/Backup/FreeNAS/SickRage/
    • Restore
      • cp /mnt/VolumeData/Backup/FreeNAS/SickRage/config.ini /mnt/VolumeData/jails/sickrage_1/var/db/sickrage/
  • Plex
    • Backup
      • tar -cvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz /mnt/VolumeData/jails/plexmediaserver_1/var/db/plexdata/
    • Restore
      • tar xvfz /mnt/VolumeData/Backup/FreeNAS/Plex/plexdata.tar.gz /mnt/VolumeData/jails/plexmediaserver_1/var/db/
I didn't realize Sickrage only needed a config.ini backed up... and CP a settings.conf. That's really it?

Are cron jobs really only 1 line only? So if you'd want to automate it you need 6 + lines?

Tried a cron job but getting this:

freenas cron[37903]: _secure_path: /mnt/v1/media/.login_conf is not owned by uid 816

816 is just my media user... for all my plugins
 
Last edited:

zerocool2007a

Dabbler
Joined
Oct 22, 2015
Messages
14
So when you manually do the backup process for Sickrage through the GUI the zip file it gives contains the cache, cache.db, config.ini, failed.db, and sickbeard.db. So if you wanted to automate this you could do:

Code:
zip -v -r sickrage-`date \+%Y\%m\%d`.zip cache.db config.ini failed.db sickbeard.db cache cache


Then setup that as a cron job to do that and copy it somewhere out in your pool and you're good to go. Oh also make sure you install the zip package before you try this.

I spun up another instance of Sickrage and tried to restore from a zip file I created and it worked. The only issue I ran into was Sickrage wouldn't start and I got the following error:

Code:
Your config version (8) has been incremented past what this version of SickRage supports (7).
If you have used other forks or a newer version of SickRage, your config file may be unusable due to their modifications.
/usr/local/etc/rc.d/sickrage: WARNING: failed to start sickrage


To fix this I had to modify the config_version parameter in the config.ini from 8 to 7 and it started.

[edit] Make sure you're pointing that line to /var/db/sickrage/ or it wont work.

[another edit]
If anyone was curious how I got this to run as a script below is the script that I use :

Code:
#!/bin/sh

zip=/mnt/tank/jails/sickrage_1/usr/local/bin/zip

cd /mnt/tank/jails/sickrage_1/var/db/sickrage
$zip -v -r sickrage-`date \+%Y\%m\%d`.zip cache.db cconfig.ini failed.db sickbeard.db cache cache
mv /mnt/tank/jails/sickrage_1/var/db/sickrage/sickrage-*.zip /mnt/tank/backups/Sickrage/


I installed zip within the sickrage jail and just pointed the script to its location. I set this as a cron job to run a few times a month.
 
Last edited:

Nucshuco

Explorer
Joined
Aug 22, 2014
Messages
52
Why not just create a new dataset, let’s say couchpotatoDB and create a folder in that called couchpotato. Then mount couchpotato in /var/db/couchpotato. Then do periodic snapshots of couchpotatoDB.

So if you have a issue with couchpotato plugin or jail you can delete and start over. Your couchpotatoDB is always there. No need for all this backup.
do the same for plex and sickrage
 

zerocool2007a

Dabbler
Joined
Oct 22, 2015
Messages
14
Why not just create a new dataset, let’s say couchpotatoDB and create a folder in that called couchpotato. Then mount couchpotato in /var/db/couchpotato. Then do periodic snapshots of couchpotatoDB.

So if you have a issue with couchpotato plugin or jail you can delete and start over. Your couchpotatoDB is always there. No need for all this backup.
do the same for plex and sickrage

32b5b09db9dedddb049949b3fa64f31e.jpg


But really that is smart thinking and something I'll probably do instead. :) We always have to over complicate things don't we? ha!
 

TommyGun

Cadet
Joined
Apr 2, 2016
Messages
1
So when you manually do the backup process for Sickrage through the GUI the zip file it gives contains the cache, cache.db, config.ini, failed.db, and sickbeard.db. So if you wanted to automate this you could do:

Code:
zip -v -r sickrage-`date \+%Y\%m\%d`.zip cache.db config.ini failed.db sickbeard.db cache cache


Then setup that as a cron job to do that and copy it somewhere out in your pool and you're good to go. Oh also make sure you install the zip package before you try this.

I spun up another instance of Sickrage and tried to restore from a zip file I created and it worked. The only issue I ran into was Sickrage wouldn't start and I got the following error:

Code:
Your config version (8) has been incremented past what this version of SickRage supports (7).
If you have used other forks or a newer version of SickRage, your config file may be unusable due to their modifications.
/usr/local/etc/rc.d/sickrage: WARNING: failed to start sickrage


To fix this I had to modify the config_version parameter in the config.ini from 8 to 7 and it started.

[edit] Make sure you're pointing that line to /var/db/sickrage/ or it wont work.

[another edit]
If anyone was curious how I got this to run as a script below is the script that I use :

Code:
#!/bin/sh

zip=/mnt/tank/jails/sickrage_1/usr/local/bin/zip

cd /mnt/tank/jails/sickrage_1/var/db/sickrage
$zip -v -r sickrage-`date \+%Y\%m\%d`.zip cache.db cconfig.ini failed.db sickbeard.db cache cache
mv /mnt/tank/jails/sickrage_1/var/db/sickrage/sickrage-*.zip /mnt/tank/backups/Sickrage/


I installed zip within the sickrage jail and just pointed the script to its location. I set this as a cron job to run a few times a month.

I like it better this way; (CouchPotato and Sickrage backup)

Code:
#!/bin/sh
echo "Starting SickRage and CouchPotato Backup on $(date)"

### Sickrage ###
# File location
SR_PATH='/volume2/@appstore/sickbeard-custom/var'

# Create archive
/bin/tar -cvf /volume1/backups/sickrage/sickrage-`date \+%Y\%m\%d`.tar.gz "$SR_PATH/config.ini" "$SR_PATH/cache.db" "$SR_PATH/sickbeard.db" "$SR_PATH/cache" "$SR_PATH/failed.db"

### CouchPotato ###
# File location
CP_PATH='/volume2/@appstore/couchpotatoserver/var'

# Create archive
/bin/tar -cvf /volume1/backups/couchpotato/couchpotato-`date \+%Y\%m\%d`.tar.gz "$CP_PATH/settings.conf" "$CP_PATH/database"


Just add this to somescript.sh and execute it using cron / scheduled task.

I created this on DSM (Synology) btw, but will work on any other NAS as long as you adjust the paths and install / change the packages if required.
 

TomasNZ78

Dabbler
Joined
Apr 19, 2016
Messages
25
Why not just create a new dataset, let’s say couchpotatoDB and create a folder in that called couchpotato. Then mount couchpotato in /var/db/couchpotato. Then do periodic snapshots of couchpotatoDB.

So if you have a issue with couchpotato plugin or jail you can delete and start over. Your couchpotatoDB is always there. No need for all this backup.
do the same for plex and sickrage

Hi there

I'm pretty new to Freenas and UNIX commands so could you help me setup what you have recommended but for plex. I would need a step by step instruction assuming that my data set is called v1 folder in it is called plexDB, my jails are in data set called SSD1/ jails/ Can I do what you said in webui? or do I need to use shell?

Thanks
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
I'm trying to backup plex that is in a standard jail. My impression is I can exclude the Cache directory.
My location of the archive is /mnt/v1/backup/Plex

Code:
cd /mnt/v1/jails/mediaserver/usr/local
tar -cvpfz /mnt/v1/backup/Plex/plexdata.tar.gz --exclude=/mnt/v1/jails/mediaserver/usr/local/plexdata/'Plex Media Server'/Cache plexdata

for some reason I get these errors:
Code:
tar: Removing leading '/' from member names
a mnt/v1/backup/Plex/plexdata.tar.gz
tar: --exclude=/mnt/v1/jails/mediaserver/usr/local/plexdata/Plex Media Server/Cache: Cannot stat: No such file or directory

I'm total lost as to why it gives those errors
 

sschroeder

Cadet
Joined
Mar 28, 2017
Messages
2
I'm trying to backup plex that is in a standard jail. My impression is I can exclude the Cache directory.
My location of the archive is /mnt/v1/backup/Plex

Code:
cd /mnt/v1/jails/mediaserver/usr/local
tar -cvpfz /mnt/v1/backup/Plex/plexdata.tar.gz --exclude=/mnt/v1/jails/mediaserver/usr/local/plexdata/'Plex Media Server'/Cache plexdata

for some reason I get these errors:
Code:
tar: Removing leading '/' from member names
a mnt/v1/backup/Plex/plexdata.tar.gz
tar: --exclude=/mnt/v1/jails/mediaserver/usr/local/plexdata/Plex Media Server/Cache: Cannot stat: No such file or directory

I'm total lost as to why it gives those errors

The error above occurs because your tar options are in the wrong order. tar is really picky when it comes down to options and parameters. First, the posted command line will result in an archive called z. Always - read again: ALWAYS - supply -f as the last option to tar, because the following parameter will be the resulting file name.
Second, as in your command line, if you supply a relative path to tar, the exclude parameter also works on relative paths. Thus, your corrected command line is:

tar -cvzf /mnt/v1/backup/Plex/plexdata.tar.gz --exclude="Cache/*" plexdata

Greetings
// Sascha


-- cut here --

Slightly off topic... A simple example to what's the deal with exclude-option in tar, let's assume the following:

user@host:/foo# ls
bar baz foz


Now we want to archive foo without the baz sub-directory:

user@host:/foo# cd ..
user@host:/# tar -cvf /tmp/foo.tar --exclude="/foo/baz" foo
a foo/
a foo/bar/
a foo/baz/
a foo/foz/


Oh, what the he..., why this? Because we supplied a relative path to tar to archive, not an absolute one. Therefore we have to cut the leading slash (/) from the exclude parameter:

user@host:/# tar -cvf /tmp/foo.tar --exclude="foo/baz" foo
a foo/
a foo/bar
a foo/foz


It's also worth noting that --exclude accepts expressions. So watch out for things like --exclude="Cache/.*". If you thought that this would exclude all dot files, you're on the wrong path. You would end up with not archiving Cache at all, because the expression matches Cache/ and also Cache/filename.ext.

I recommend to read the man page ( man 1 tar). You should always consult the man-pages first. Most of the time there are some examples at the end of each man-page which should lead you in the correct direction.
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
tar -cvzf /mnt/v1/backup/Plex/plexdata.tar.gz --exclude="Cache/*" plexdata
Thanks for the detailed explanation. I did look at the man page for tar but I couldn't understand it enough to fix the issue.
I did use this code
Code:
cd /mnt/v1/jails/mediaserver/usr/local/
tar cfpz /mnt/v1/plexdata/plexdata.tar.gz --exclude=plexdata/Plex\ Media\ Server/Cache plexdata


I think it also works.
 

sschroeder

Cadet
Joined
Mar 28, 2017
Messages
2
Glad to hear.
Ok, I checked and see that bsdtar is somewhat different from GNU tar *SIGH*
As I wrote my post today, I was using my Linux netbook with GNU tar. Therefore your solution is correct too as bsdtar is not that silly about parameter sequence. Or I'm just an old dinosaur and only remember the syntax of around 1999 o_O
 
Status
Not open for further replies.
Top