Cloning a site » History » Version 1
Jon Goldberg, 07/30/2021 06:29 PM
| 1 | 1 | Jon Goldberg | # Cloning a site |
|---|---|---|---|
| 2 | The command to clone a site's database to an existing dev/test site is: |
||
| 3 | ```shell |
||
| 4 | ansible-playbook main-playbook.yml --tags site-db-sync --limit example.local |
||
| 5 | ``` |
||
| 6 | |||
| 7 | Specify the *destination* site with `--limit`. The Ansible inventory knows which live site corresponds to the destination site. Depending on the live site's "db sync strategy" value in the inventory, one of two strategies is employed: |
||
| 8 | * *Restore from rsync.net* will download the database dump from the most recent backup of the live site on rsync.net. |
||
| 9 | * *Live mysqldump* will do an immediate `mysqldump` of CMS/CRM/logging databases, and copy them down. Use this with caution for sites where mysqldump might cause a performance issue. Note that at this time, "Live mysqldump" will only work for a locally hosted destination. |
||
| 10 | |||
| 11 | #### Manually dropping all database triggers |
||
| 12 | The Ansible command will drop the trigger definer automatically, but if you need to manually sync a site for whatever reason, then can't write anything to Civi because your triggers lack permission to write to the log, this two-liner will fix it. Run anywhere within the site's webroot. |
||
| 13 | |||
| 14 | ```shell |
||
| 15 | DB=<your database name here, e.g. "example_dev_civi"> |
||
| 16 | echo "SELECT Concat('DROP TRIGGER ', Trigger_Name, ';') FROM information_schema.TRIGGERS WHERE TRIGGER_SCHEMA = '$DB'" | cv sql | tail --lines +2 | cv sql |
||
| 17 | # Drupal only |
||
| 18 | drush civicrm-sql-rebuild-triggers |
||
| 19 | ``` |