sql:sync¶
Copy DB data from a source site to a target site. Transfers data via rsync.
Examples¶
drush sql:sync @source @self
. Copy the database from the site with the alias 'source' to the local site.drush sql:sync @self @target
. Copy the database from the local site to the site with the alias 'target'.drush sql:sync #prod #dev
. Copy the database from the site in /sites/prod to the site in /sites/dev (multisite installation).
Arguments¶
- source. A site-alias or site specification whose database you want to copy from.
- target. A site-alias or site specification whose database you want to replace.
Options¶
- --no-dump. Do not dump the sql database; always use an existing dump file.
- --no-sync. Do not rsync the database dump file from source to target.
- --runner=RUNNER. Where to run the rsync command; defaults to the local site. Can also be source or target.
- --create-db. Create a new database before importing the database dump on the target machine.
- --db-su=DB-SU. Account to use when creating a new database (e.g. root).
- --db-su-pw=DB-SU-PW. Password for the db-su account.
- --target-dump=TARGET-DUMP. The path for storing the sql-dump on target machine.
- --source-dump[=SOURCE-DUMP]. The path for retrieving the sql-dump on source machine.
- --extra-dump=EXTRA-DUMP. Add custom arguments/options to the dumping of the database (e.g. mysqldump command).
- --skip-tables-key=SKIP-TABLES-KEY. A key in the $skip_tables array. @see Site aliases
- --structure-tables-key=STRUCTURE-TABLES-KEY. A key in the $structure_tables array. @see Site aliases
- --tables-key=TABLES-KEY. A key in the $tables array.
- --skip-tables-list=SKIP-TABLES-LIST. A comma-separated list of tables to exclude completely.
- --structure-tables-list=STRUCTURE-TABLES-LIST. A comma-separated list of tables to include for structure, but not data.
- --tables-list=TABLES-LIST. A comma-separated list of tables to transfer.
Global Options¶
- -v|vv|vvv, --verbose. Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
- -y, --yes. Auto-accept the default for all user prompts. Equivalent to --no-interaction.
- -l, --uri=URI. A base URL for building links and selecting a multi-site. Defaults to https://default.
- To see all global options, run
drush topic
and pick the first choice.
Topics¶
- Creating site aliases for running Drush on remote sites. (docs:aliases)
- Example policy file. (docs:policy)
- Drush configuration. (docs:configuration)
- Extend sql-sync to allow transfer of the sql dump file via http. (docs:example-sync-via-http)
Aliases¶
- sql-sync
Legend
- An argument or option with square brackets is optional.
- Any default value is listed at end of arg/option description.
- An ellipsis indicates that an argument accepts multiple values separated by a space.