Keeping local and Dev Cloud databases in sync

Keeping local and Dev Cloud databases in sync

10 posts / 0 new
Last post
jgirard's picture
jgirard
Points: 0
Keeping local and Dev Cloud databases in sync

We are working on a Drupal site and do mods locally before pushing up to Acquia. Is there a simple way to keep the local and the Acquia databases synched?

Thanks!

Status: 
Unresolved
steve.cronen-townsend@acquia.com's picture
steve.cronen-townsend
Points: 49

John,

I am interested in getting this capability for the Acquia Dev Cloud, and there is another customer I know of who is working on setting this up. Ideally there would be an Acquia-specific version of drush sql-sync called ah-sql-sync.

The best we have so far is setting up a MySQL client like MySQL Workbench or Navicat to access both your local database and, say, the database of your Dev environment on Acquia Cloud.

Do you have this set up?

With this capability you can use the MySQL client on a local development machine to dump the local database and then import it into your Dev environment with overwrite. What little documentation we have is in the evolving page at https://network.acquia.com/documentation/cloud/ssh/drush. If you have trouble setting up this capability please file a Dev Cloud ticket asking for assistance.

Regards,


Steve Cronen-Townsend | Dev Cloud Support, Acquia Client Advisory Team. Acquia Hosting documentation.
peter.vanhee's picture
peter.vanhee
Points: 0

Interested in getting the sql-sync functionality for acquia dev cloud as well.

What is the current recommended way to get dev/stage/prod databases to a local environment?

steve.cronen-townsend@acquia.com's picture
steve.cronen-townsend
Points: 49

Currently the recommendation for transferring to a local database is to use a local client; dump the cloud database; then drop, recreate, and import the local database from the dump. To go the other way it use the same procedure reversed.

That said, please file a ticket and we will get drush sql-sync setup. Then we will probably document how to do that and make it the recommendation. (Note that customers can file as many tickets about our platform as they need to.)

Regards,

Steve Cronen-Townsend | Dev Cloud Support, Acquia Client Advisory Team. Acquia Hosting documentation.

tvilms8's picture
tvilms
Points: 1

Hi, I'm brand new to Dev Cloud. I have a question about "go the other way". Perhaps you can clarify for me:

I've dumped my local database, gzipped it, and uploaded it into my Dev Cloud development environment's /import directory. How/From where do I execute the SQL Drop, Recreate, and Import statements in Dev Cloud? On my local PC, I would do this from phpMyAdmin. I don't see a similar admin tool available to me in the Dev Cloud dashboard.

Also, what's the difference between doing that, as opposed to using the "Migrate" button available at admin/config/system/acquia-agent?

Building Music Sites

tvilms8's picture
tvilms
Points: 1

Well okay then?! I'm surprised to get no responses or hints from the Acquia Network community. This seems like such a basic workflow task that's not well documented at all. I had to piece it together myself. So, for the benefit of others, to save you time in the future when getting started with Dev Cloud, here's what worked for me:

1. Locally made a copy of my database, taking the extra step of setting SQL Compatibility Mode = MYSQL40
2. Locally from command line gzipped the database $ gzip foo_db.sql
3. Locally from command line uploaded the compressed DB to the devcloud "backups" directory $ scp foo_db.sql.gz [sitename]@[acquia_server].devcloud.hosting.acquia.com:/mnt/files/[sitename].dev/backups
4. Logged into DevCloud backups directory where I just uploaded the compressed DB $ SSH [sitename]@[acquia_server].devcloud.hosting.acquia.com:/mnt/files/[sitename].dev/backups
5. Uncompressed the DB file I just uploaded $ unzip foo_db.sql.gz
6. Navigated to DevCloud dashboard databases page to see the Database Connection Details (note the specific values for the DEV environment - my objective was to restore the dev environment's database with the new database reflecting changes made in my local environment)
7. Entered MYSQL mode $ mysql -h [acquia_server] -u [username] -p[password]
8. Dropped the existing database mysql$ drop database [MySQL Name];
9. Created an empty database mysql$ create database [MySQL Name] charset utf8;
10. Exited mysql mode mysql$ \q
11. Restored the new database $ mysql -h [acquia_server] -u [username] -p [mySQLname] < foo_db.sql
12. Entered the database password when prompted $ [password]

This being said, it would be nice to know if there's a simpler workflow. For example, I thought for a minute the "restore" feature on the backups dashboard would allow me to quickly restore the backup I uploaded to the backups folder. However, that didn't work because the only backups listed in the Acquia dashboard are the ones that Acquia creates. Any DB backups I uploaded myself into the /backups directory weren't visible from the dashboard. :-(

Building Music Sites

msugimoto's picture
Mori Sugimoto
Points: 5

Hi tvilms8,

The best solution would be to use drush sql-sync. We do not yet provide tools to import / export DB dumps via UI.

Here's a detailed information on how to do the sync. Although it's the other way around (remote -> local), reversing the source and target will work.

https://library.acquia.com/articles/synchronizing-local-development-envi...

Kind regards,

Mori Sugimoto

tvilms8's picture
tvilms
Points: 1

Hi, thanks for the link. However, that method assumes I'm using Dev Desktop. I'm not. Do you have pointers for getting Drush installed and configured properly to use the simple drush sql-sync command running the MAMP stack on Mac OSX?

Building Music Sites

steve.cronen-townsend@acquia.com's picture
steve.cronen-townsend
Points: 49

I just did a test of this newly published document and it worked for me. For those Dev Desktop users out there, let's get any tricks, tales of success, etc... in this thread. This is clearly a great way, because you do not have to see the connection details one you've got it set up. You can just do the synchronization with one drush command each time you have to do it. So this can truly be part of an efficient developer workflow.

lorcz@uwec.edu's picture
lorcz
Points: 3

I have tried drush sql-sync @site.prod @self and I got the following error:

Error: no database record could be found for target @self

MySQL server was freshly installed and not running Dev Desktop. The current folder was docroot when I ran this command.