- Create a file in the home directory of the remote server titled
.my.cnf
. It should contain:
[mysqldump]
user=DATABASE USERNAME
password=DATABASE PASSWORD
-
Chmod this file 500 to prevent it being read by nefarious individuals.
-
Create a directory in the home directory of the remote server titled .dbdumps. Make sure the user you log in with can write to it.
-
Create a file in your local home directory titled
.my.cnf
. It should be the same as step 1 (but with your local credentials). -
Create a directory in your local home directory titled .dbdumps.
-
Move the script ("syncdb") to /usr/local/bin or whatever weird alternate location you prefer. Make sure its location is in your PATH.
-
Do
chmod +x syncdb
to make it executable. -
Put "syncdb.conf" in /usr/local/etc. This is where the script expects this to be, so if you don't want it there you'll need to edit the script to reflect its new location.
-
Edit syncdb.conf as required. Details are available as an example (the first item) in the configuration file itself.
-
On any server you'll be working with you'll need to do a bit of prep. To wit:
-
In the home directory of the user you log in as, add a folder titled .dbdumps.
-
In the same directory, create a file called .my.cnf. It should look like this:
[mysqldump] user=A_USER_WITH_SELECT_PRIVS password=THE_USERS'S_PASSWORD
Make sure that this file is NOT READABLE BY ANY USERS OTHER THAN THE OWNER, which should be the database owner.
-
-
You will probably want to make sure your public key is on the server because this script logs in like three times and will get to be a real pain in the ass otherwise.
To use the script, simply type syncdb
. The script will ask you for the name of the site you wish
to sync -- this is keyed to the name field in syncdb.conf.
Please.