Replicate MYSQL data from stage to dev with script

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

Right now, the "scene" is undergoing real-world beta testing.

From time to time I want an exact copy of the data to replicate to the "dev" database.

Both databases are on the same Linux guest machine.

Sometimes I create "dummy" data in a development environment. At this stage, I would be fine if he had to write on stage.

Thank.

+1


source to share


2 answers


Make sure to add security to your script so that only the user you authorize can run this 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 a backup with the second command, casting the backup to a different database engine. Be careful , because if you run it in the same exact mysql process, you back up the adn database and then restore it to the same database, you must change the database name.

Hope it helps.

+3


source


Just use mysqldump to back up your staging database and then upload the dump file through your dev database. This will give you an exact copy of the stage data.



0


source







All Articles