Question

I read this article now.

I need to get the central database backup and restore it to the remote servers.

In this case I have 43 other branches servers and a central server.

That means i'm going to keep 44 database in my central server (Going to use a VPS).

So can I write a PHP script, to run the equivalent of the following command line code, to backup my branch servers to the central server?

So that I would have 43 databases on my central server to restore with 43 remote servers. (I don't have a network connection to all 43 branche servers or doesn't have a VPN )

[local-server]# mysqldump -u root -ptmppassword sugarcrm | mysql \
                 -u root -ptmppassword --host=remote-server -C sugarcrm1
[Note: There are two -- (hyphen) in front of host]
Était-ce utile?

La solution

You might want to think about using mysql replication (with 1 master and 43 slaves), instead of backing up and restoring periodically like you are describing here. Replication would run continuously, so the 43 slaves would be synced to the master in real time. See http://dev.mysql.com/doc/refman/5.5/en/replication-howto.html for more info.

Autres conseils

I would build a script that checks the connection first then if all ok, does the transfer. Once this script is tested you can call it once for each of your 43 databases. Some may fail, but your script will tell you which (if it reports errors properly). Then work out what is causing any failures. Eventually you will get all 43 going.

The backup script you end up with will use the code you have posted, but it will be more general and will have checking and reporting. Why don't you post it here when you have it working?

Greg Ambrose

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top