trellis-simple-sync
trellis-simple-sync
Ansible playbooks for Trellis database and uploads sync.
Just copy and run without any extra configuration.
Installation
-
Copy
database.ymlanduploads.ymlfiles into Trellis root folder -
Copy
bin/sync.shfiles into Trellis bin folder -
(Optional) Add
db-backup-*.sql.gzto your Bedrock.gitignorefile
Usage
Run ./bin/sync.sh <environment> <site name> <type> <mode>
-
Available
<type>options:uploads,database,all -
Available
<mode>options:push,pull -
The
pushis for upload data from development and update selected environment, and thepullfor download data from selected environment and update development. -
uploadssync is not destructive, it only adds or update new files, don’t delete missing files. -
On every database sync a datetimed backup
db-backup-YYYYMMDDTHHMMSS.sql.gzis saved before import data.
Aliases
You can use alias for a shorter or more intuitive commands
- staging – stag – s
- production – prod – p
- database – db
- uploads – media
- push – up
- pull – down
Examples:
./bin/sync.sh stag example.com db up
./bin/sync.sh prod example.com media down
./bin/sync.sh prod example.com all up
Skipping GUIDs
Skipping the GUID column is the default behaviour as it can have unwanted effects on production environments. If you are sure you want to replace GUID URLs, for example if you are deploying a site to production for the first time, you can prevent skipping GUIDs with --extra-vars "skip_guids=false".
Example:
./bin/sync.sh prod example.com db up --extra-vars "skip_guids=false"
Notes
- Tested up to Ansible 2.6.1
- Replace Elementor urls on database sync (if installed).
- For database sync the development vagrant VM must be powered on every time you run a command
-
On every database sync a
db-backup-YYYYMMDDTHHMMSS.sql.gzfile is automatically created inside destination environment Bedrock folder. In development, if you don’t want it to be saved in the repository:-
You can add
db-backup-*.sql.gzto your Bedrock.gitignorefile -
Or you can comment
PULL > Backup development databasetask ondatabase.yml
-
You can add
Contribute
- Anyone is welcome to contribute to the plugin.
- Please merge (squash) all your changes into a single commit before you open a pull request.
License
MIT
Credits
© 2018 Creame.
Heavily inspired by trellis-database-uploads-migration and trellis-db-push-and-pull.
Special thanks to the Roots team whose Trellis make this project possible.