Page 1 of 1

Best way to backup SABnzbd?

Posted: April 23rd, 2013, 3:14 am
by josiahrulez
Hey all,

So I'm looking for the best way to automatically backup sabnzbd.

I was planning on using ubuntu backup to automatically backup my sabnzbd folder. But would there be a problem backing up while sabnzbd is still running? or should i write a script to shutdown sabnzbd first then backup the folder?

Re: Best way to backup SABnzbd?

Posted: April 23rd, 2013, 3:22 am
by AutomaticCoding
Code isn't mine, credits to whoever made it, which, I honestly couldn't tell you who it is:-

To stop sabnzbd (Obviously will need editing):-

Code: Select all

sabnzbd_stop()
{
	# no-op if not running
	if [ ! -r /var/run/sabnzbd/sabnzbd-$PORT.pid ]; then
		return
	fi
	
	echo "Stopping SABnzbd..."
	sleep 1
	
	if [ -d $DATADIR ] && [ -f $DATADIR/sabnzbd.ini ]; then
		APIKEY=`grep -w api_key $DATADIR/sabnzbd.ini | cut -d " " -f3`
		IP=$(ifconfig  | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | grep -v '^5' | awk '{ print $1}')
		RES=$(wget -qO - "http://$IP:$PORT/sabnzbd/api?mode=shutdown&apikey=$APIKEY")
		if [[ $RES != "ok" ]]; then
			kill $(cat /var/run/sabnzbd/sabnzbd-$PORT.pid)
		fi
	else
		kill $(cat /var/run/sabnzbd/sabnzbd-$PORT.pid)
	fi
	sleep 3

	if [ -e /var/run/sabnzbd/sabnzbd-$PORT.pid ]; then
		kill -9 $(cat /var/run/sabnzbd/sabnzbd-$PORT.pid )
		rm /var/run/sabnzbd/sabnzbd-$PORT.pid
	fi
	echo "... OK"
	sleep 1
}
then just something like:-

Code: Select all

cp $datadir /backupDir/$date/
then back to:-

Code: Select all

sudo -u yourSabnzbdDaemonAccount python sabnzbd
The above code probably isn't the best way, but, it works.

EDIT:- As for your question, the only way to be sure is to check sabnzbd's saving script, however, my GUESS would be:-
Don't save while it's open, although it will recover (Assuming you back EVERYTHING up, not just sabnzbd.ini), if it's currently unraring/par2ing something it'll probably start spewing errors when you load it back up from the backup.

Re: Best way to backup SABnzbd?

Posted: April 28th, 2013, 3:48 am
by josiahrulez
Well i learnt that hyper-v hosts don't like ubuntu, so i had to force reset my downloadbox yesterday and lost my queue.

so i was backing up with the ubuntu backup utility and restored the queue ok. But i may look at oracle virtual box and try setup automatic snapshots.