PDA

View Full Version : Backing Up the Slimserver Database



kweller
2006-01-08, 14:32
Having just had an 'accident' I've restored my SlimServer program
directory but am having to re-scan my music tracks to rebuild the
database. The reason for that is that Slimserver runs 24/7 and
SecondCopy (a Windows back-up program) says it can't back-up the
database file as it in use.

Are there command lines I can use to tell SlimServer to shut down and
restart that I can set up in Windows Scheduler? If I can do that I can
schedule the back-up as well.

SecondCopy does actually have an option to try to ignore whether a file
is in use but when I set that SlimServer stops whenever the back-up
kicks in and doesn't restart.

Thanks.

(Be nice if Slimserver contained an option to backup the database to a
specified directory at a specified time)

Kevin

Dr Lovegrove
2006-01-08, 15:47
On 08/01/06, Kevin Weller <SlimDML (AT) thewellers (DOT) net> wrote:
>
> (Be nice if Slimserver contained an option to backup the database to a
> specified directory at a specified time)

Be pretty handy for Moose too as pointing it at the 'live' db file
causes all sorts of grief..

--
- Dr Lovegrove
http://www.rusticrhino.com/drlovegrove

adhawkins
2006-01-08, 16:32
In article <VA.000007db.010e030c (AT) thewellers (DOT) net>,
Kevin Weller<SlimDML (AT) TheWellers (DOT) net> wrote:
> Are there command lines I can use to tell SlimServer to shut down and
> restart that I can set up in Windows Scheduler? If I can do that I can
> schedule the back-up as well.

net stop service name
net start service name

I don't know what the appropriate service name is for Slimserver is under
Windows, but it shouldn't be too hard to find.

Andy

Michaelwagner
2006-01-08, 20:08
I'm not sure how useful this would be.

If any of the songs change after the backup and you restore to a backup, there are errors. In order to fix them, you have to rescan. The thing you wanted to avoid.

kweller
2006-01-09, 01:36
In article <67fb4bc40601081447j6c20d5d1y (AT) mail (DOT) gmail.com>, Dr Lovegrove
wrote:
> Be pretty handy for Moose too as pointing it at the 'live' db file
> causes all sorts of grief..

I'm just discovering that. Memo to self: Read the warnings that come on
the label and follow the instructions! :)

Kevin

kweller
2006-01-09, 12:10
In article <slrnds388j.r73.andy (AT) gently (DOT) org.uk>, Andy Hawkins wrote:
> net stop service name
> net start service name

With a DOS Copy in the middle that works nicely thanks (the service
name is slimserver BTW).

I don't suppose there a way to halt player(s) before I do that then
restart them afterwards is there? I'm wandering round the Wiki trying
to find that but not come across it yet.

We leave SoftSqueeze and the Squeezeboxes running 24/7 on random play
then just turn the appropriate speakers on when we want to listen.
Shutting down SlimServer while they're playing not surprisingly upsets
both Squeezebox and Softsqueeze to the extent they have to be
restarted.

Kevin

Browny
2006-01-09, 14:35
You might want to try coming to this from a different direction.

The problem you're encountering is a file lock on the db file when the backup runs.

If you were to switch to using MySQL then you could either use the database backup features available in the database, or even run scheduled tasks to copy the records from one db to a spare.

Switching to MySQL is fairly painless - see the wiki below:

http://wiki.slimdevices.com/index.cgi?MySQL

JJZolx
2006-01-09, 16:43
Having just had an 'accident' I've restored my SlimServer program
directory but am having to re-scan my music tracks to rebuild the
database. The reason for that is that Slimserver runs 24/7 and
SecondCopy (a Windows back-up program) says it can't back-up the
database file as it in use.

Are there command lines I can use to tell SlimServer to shut down and
restart that I can set up in Windows Scheduler? If I can do that I can
schedule the back-up as well.

SecondCopy does actually have an option to try to ignore whether a file
is in use but when I set that SlimServer stops whenever the back-up
kicks in and doesn't restart.
I would simply make a copy of the database file (assuming you're using SQLite), then backup the copy. Use a batch file and schedule this copy operation to occur a few minutes before the backup is scheduled to happen. If you schedule your backups in the middle of the night when Slim Server isn't being used, there's little chance that the copy will be in such a state that it can't be used for a restore. If you're using MySQL, you'll need to do a database dump and then backup the dump.


(Be nice if Slimserver contained an option to backup the database to a
specified directory at a specified time)
I agree. But since program settings aren't kept in the database (yet) you can just run a rescan and you're back to where you began. You shouldn't be having catastrophic database losses so often that having to do a rescan should be a major inconvenience. If/when server and player (and user) settings are kept in the database, backups will be much more important. A nice user interface for backups and restores, and scheduled backups will be critical for the casual user who can't be expected to be doing MySQL (SS v6.5) administration.

samlw
2006-01-09, 17:27
Are there command lines I can use to tell SlimServer to shut down and restart that I can set up in Windows Scheduler? If I can do that I can schedule the back-up as well.

I don't know about Windows, but on Unix/Linux you can create a small script that will tell Sqlite to backup the database without the need to shut down SlimServer.

To backup to a gzipped sql file, do something like this:

echo '.dump' | sqlite /path/to/.slimserversql.db | gzip > slimserver_backup.sql.gz

Or, to backup to a sqlite database:

echo '.dump' | sqlite /path/to/.slimserversql.db | sqlite slimserver_backup.db

Of course, the script can be placed in a cron tab for scheduled execution.

kweller
2006-01-10, 01:57
In article <Browny.21dzwn (AT) no-mx (DOT) forums.slimdevices.com>, Browny wrote:
> Switching to MySQL is fairly painless - see the wiki below:

Thanks for the suggestion Browny but I think that'll stop Moose working
so I'm going to stick with SQLite until Moose supports MySQL.

Kevin

kweller
2006-01-10, 09:44
In article <samlw.21e7rz (AT) no-mx (DOT) forums.slimdevices.com>, Samlw wrote:
> I don't know about Windows, but on Unix/Linux you can create a small
> script that will tell Sqlite to backup the database

Thanks. Having downloaded and installed SQLite and tried to come up with a DOS command line
to do that I've come to the conclusion I'm too stupid to figure it out!

My head hurts now so I'll have another go tomorow :)

Kevin