how to backup/restore database?

Support and queries relating to all previous versions of ZoneMinder
Locked
darkpaw
Posts: 166
Joined: Thu Apr 26, 2007 2:35 am

how to backup/restore database?

Post 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.
PacoLM
Posts: 971
Joined: Wed Dec 02, 2009 9:55 pm
Location: Spain

Post 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
Flash_
Posts: 441
Joined: Wed Jan 11, 2006 12:19 pm

Post 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.
darkpaw
Posts: 166
Joined: Thu Apr 26, 2007 2:35 am

great info

Post 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. :)
darkpaw
Posts: 166
Joined: Thu Apr 26, 2007 2:35 am

got it

Post by darkpaw »

No password for MySQL by default. :)
Locked