Add automated db backups as part of Trellis?

I just did my first Ansible script for making automated backups of production server’s db. Here is my ansible task:

- name: Create directory for backups
    path: "/db-backups"
    state: directory
- name: Set weekly database backups
    name: "Weekly database backup"
    job: "{{ site_path }}/"
    minute: 0
    hour: 1
    weekday: 1

And here is

cd /srv/www/
wp db export /db-backups/mysite-`date +%d-%m-%Y`.sql --allow-root

This way crontab makes every monday at 1 AM mysql dump of the whole production database.

Have you guys though of making this kind of behaviour part Trellis? I am sure that many people would like to have this feature since backups are very important. Guys at Digital Ocean said you shouln’t trust their backups 100% when dealing with databases. They recommend to do your sqldump files also like I did :slight_smile:


I have a work-in-progress role that sets this up without an sh script. Check it out here. The library I’m using to set up the jobs has some bugs noted in that thread.