views:

121

answers:

2

I have two versions of my application, one "stage" and one "dev."

Right now, "stage" is exposed to the real world for beta-testing.

From time to time, I want an exact replica of the data to be replicated into the "dev" database.

Both databases are on the same hosted Linux machine.

Sometimes I create "dummy" data in the development environment. At this stage, I'd be fine if it needs to get written over in stage.

Thanks.

A: 

Just use mysqldump to create a backup of the staging database and then load the dump file over your dev database. This will give you an exact copy of the stage data.

Rob Booth
Hi, I want to script it, ideally from a bash.sh script...how do I load it back into dev?
AFG
+1  A: 

Be sure to add security to your script so only the user you are authorizing is able to run that script. basically you want to use mysql and mysqldump commands.

mysqldump -u username --password=userpass --add-drop-database --add=locks --create-options --disable-keys --extend-insert --result-file=database.sql databasename
mysql -u username --password=userpass -e "source database.sql;"

The first command will make the backup the second command will bring the backup to another database engine. Be careful because if you run it on the same exact process of mysql you are only backing up the database adn then restoring it to the same database, you have to change the database name.

Hope this helps.

Geo
how do I specify which database to bring in the backup?
AFG
the last parameter that specified the databasename.
Geo