ttcDbSnapshotPlugin - 1.0.0

Save, load and Sync mysql databases

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

ttcDbSnapshotPlugin

Usage Scenarios

  1. You are testing a feature but it's tedious to revert and test again because of many data changes - save data then reload.
  2. Client has a problem with some of it's data - sync remote prod to local dev and test with real data

Requirements/Limitations

To be fast and take usable snapshot, the plugin uses mysqldump to save, and mysql to load which are both available on linux/unix system which means windows users won't be able to use this plugin as is.

For now it also parses the databases.yml file to get connection credentials thru Doctrine_Manager which also means Propel users can't use it unless you provide your own getConnectionCredentials() like in baseTtcDbSnapshotTask.class.php

Basic Usage

The tasks to do all these actions requires the mysqldump and mysql executable to be available which probably means trouble for windows users but hopefully your production server uses linux and you should be able to get benefits like I do from this plugin.

  • To take a snapshot: $ symfony ttc:take-snapshot

  • To load one: $ symfony ttc:load-snapshot

Syncing

To use the syncing feature with ease, you are not required to but you should create a public/private ssh key pair and upload your public key to your server, then create a config file in your .ssh home folder that would look like this:

Host myprodserver Hostname myprodserver.com User prodLinuxUsername IdentityFile /.ssh/private_key Port 12345

Then to sync your production data to your dev data, you would use: $ symfony ttc:load-snapshot-from --env=dev myprodserver '/sf' prod

  1. Will use the config above to connect thru ssh.
  2. From the '~/sf' folder on your production, it will use the prod connection and ttc:take-snapshot there.
  3. Then it will transfer the saved snapshot thru ssh again to data/remote_ttc_db_snapshot_prod.sql
  4. And finally it will run ttc:load-snapshot --env=dev full_path_to/remote_ttc_db_snapshot_prod.sql