Page 1 of 1

how to backup/restore database?

Posted: Mon Mar 07, 2011 12:43 am
by darkpaw
I am looking to migrate my ZM setup to a new server (dual 3.0GHz with hyperthreading, as opposed to my current setup of dual 3.0GHz without), and was hoping there was an easy way to backup my database config (including all zones per camera) and then just restore it on the new server. It would be extremely time consuming to try to come up with lining up and tweaking all the zones again to get it to my current layout. I'm not very familiar with MySQL, and wouldn't know the first thing about which tables would be needed for what.

Posted: Mon Mar 07, 2011 6:26 am
by PacoLM
Hi,

Try to install PHPMyadmin. Then select the ZM database and do a backup of the database selecting all the tables and exporting them in SQL format.
After installing the new server, do the opposite, install phpmyadmin, install zoneminder, that will create an empty database. After this, import the stored SQL database to the new system.

Hope it helps,

PacoLM

Posted: Mon Mar 07, 2011 6:37 am
by Flash_
Actually, that is often a lot of faff since phpmyadmin won't accept large incoming files to restore. You can copy the dumpfile locally and import from there, but even then often times out.

If you just want the setup and not the events, then phpmyadmin is handy since you just select all the tables except events (the really large one) and do as PacoLM says.

If copying the lot though;

Code: Select all

mysqldump --user=XXXXXXXX --password=XXXXXXX --databases zm > /PATH/TO/DUMPFILE.SQL
That creates DUMPFILE.SQL containing everything from zm's database. Copy that file to the new machine with zoneminder already installed (but stopped) and add it to mysql with;

Code: Select all

mysql  --user=XXXXXXXX --password=XXXXXXXX zm < /PATH/TO/DUMPFILE.SQL
Remember to copy turn off zm before importing the new db, and to copy across all the jpg files (/var/cache/zoneminder by default). If you don't copy across the jpgs, zmaudit will kill all your new events as orphans. (But will keep your events, monitors etc)

Only when both bits are installed can you restart zm and check all is good.

great info

Posted: Wed Mar 09, 2011 2:21 am
by darkpaw
This is great info. I also found this posting, though Ubuntu it should be close:

http://www.zoneminder.com/forums/viewto ... p+database

One problem.....it's been so long since I installed this, I can't remember my password for MySQL. I'm sure it's in a config file somewhere, but I can't figure it out. I don't see it in the config from the UI.

Help. :)

got it

Posted: Fri Mar 11, 2011 11:27 pm
by darkpaw
No password for MySQL by default. :)