Advomatic has created several command line tools to assist you in moving your data efficiently between your staging server and your production server.
Note: These commands can only be used for servers within the Advomatic network.
The site_sync utility is a command line tool used to move files from your staging server to your production server. This tool has also been designed to take multiple webheads into account in case you have a clustered configuration.
This is a very powerful tool, and it is possible to overwrite your entire site. Please use it with caution. If you have any questions, email support@advomatic.com prior to using this utility.
The standardized file architecture in place has your staging site at ~/domains/CLIENTDOMAIN/staging
Your production site is at ~/domains/CLIENTDOMAIN/prod
$ site_sync [OPTIONS] [FOLDER_OR_FILE_TO_BE_SYNCED]The file or folder is relative to the webroot -- this is ~/domains/CLIENTDOMAIN/staging
$ site_sync sites/all/modules/This will push your ~/domains/CLIENTDOMAIN/staging/sites/all/modules/ directory and everything underneath it, to ~/domains/CLIENTDOMAIN/prod/sites/all/modules/ Note the trailing slash '/'
$ site_sync sites/all/testfile.txtThis will push your ~/domains/CLIENTDOMAIN/staging/sites/all/testfile.txt file to ~/domains/CLIENTDOMAIN/prod/sites/all/testfile.txt
- This utility supports the '-d' flag to specify which domain you wish to use, in the event you are set up with multiple domains in ~/domains/. If you fail to specify '-d' and it is required, no changes will be made, and an error will be displayed.
- The destination is always relative to the web root (most likely ~/domains/CLIENTDOMAIN/staging/). This means that even if you are in a deeper directory and you do a '$ site_sync testfile.txt'
you will sync ~/domains/CLIENTDOMAIN/staging/testfile.txt.
- To protect user uploaded data already on the production servers, the Drupal 'files' directory in the webroot is excluded by this tool. Please see the utility 'files_sync' below.
- Please use caution when synching a directory that is frequently changing (i.e. a theme directory). You may inadvertently push something to the production servers that is not production ready.
The db_sync utility is a command line tool used to copy a database from either your staging server to the production database servers or from the production database servers to your staging server.
No matter which direction you are copying the database, it is important to understand that this is a destructive command: in copying a database from one server to another, it will overwrite the data on the destination server. There is no mechanism to reverse an incorrect db_sync command short of a restoration of your database from a backup.
Please use this command with care.
NOTE: THIS COMMAND HAS CHANGED. PLEASE USE THE '--help' FLAG TO SEE THE NEW SYNTAX!
$ db_sync [OPTIONS] [SOURCE DESTINATION]The 'destination' will be overwritten with the 'source'.
This will copy your staging database to the production database:
$ db_sync YOURSITE.advomatic.com YOURSITE.com This will copy the Shared Cluster production database to your staging server:
$ db_sync YOURSITE.com YOURSITE.advomatic.com - This utility supports the '-d' flag to specify which domain you wish to use, in the event you are set up with multiple domains in ~/domains/. If you fail to specify '-d' and it is required, no changes will be made, and an error will be displayed.
- This utility will not work if $db_url is an array (i.e. a site accesses multiple databases via db_set_active()). In this case you will need to do a manual mysqldump and restore. Email support@advomatic.com for further instructions.
- This utility will leave a backup copy of each database in your home directory, just in case you need to undo your actions. Keep in mind that "undo" is a manual mysql restore. Email support@advomatic.com for further instructions.
The files_sync utility is a command line tool used to copy contents of the Drupal 'files' directory from the development server to the production servers and vice versa. Once the file transfer is complete, permissions are changed on the production servers, making those items owned by the user www-data.
$ files_sync [OPTIONS] [SOURCE DESTINATION]The destination will be overwritten with the source.
This will copy the 'testfile.txt' from the production 'files' directory to your staging server's 'files' directory using the '--production-to-staging' (-p2s) flag.
$ files_sync -p2s testfile.txtThis will copy the 'testfile.txt' from your staging server's 'files' directory to the production 'files' directory using the '--staging-to-production' (-s2p) flag.
$ files_sync -s2p testfile.txt- This utility supports the '-d' flag to specify which domain you wish to use, in the event you are set up with multiple domains in ~/domains/. If you fail to specify '-d' and it is required, no changes will be made, and an error will be displayed.
- files_sync, by design, manipulates files that are in use on your production directory. In a clustered configuration, a read/write mount of your production files network share is mounted directly into the 'prod' directory on your staging server. Directly manipulating the contents of this directory will alter your production files content, and runs the risk of a permissions mismatch, potentially causing a production site failure.