Project

General

Profile

Actions

Cloning a site

The command to clone a site's database to an existing dev/test site is:

ansible-playbook main-playbook.yml --tags site-db-sync --limit example.local

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:

  • Restore from rsync.net will download the database dump from the most recent backup of the live site on rsync.net.
  • 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.

Manually dropping all database triggers

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.

DB=<your database name here, e.g. "example_dev_civi">
echo "SELECT Concat('DROP TRIGGER ', Trigger_Name, ';') FROM  information_schema.TRIGGERS WHERE TRIGGER_SCHEMA = '$DB'" | cv sql | tail --lines +2 | cv sql
# Drupal only
drush civicrm-sql-rebuild-triggers

Updated by Jon Goldberg over 2 years ago · 1 revisions