Roots Discourse

Your Agency's Backup Plan

This is one of those “looking for advice” posts. Most of my background is with shared hosting environments, so please forgive my ignorance.

I’m researching Trellis/Bedrock/Sage/Digital Ocean as a workflow and general How We Do Things policy for my agency. My goal is to produce a document outlining the pros and cons of this method, specifically the Digital Ocean portion, as compared with the current shared hosting platform that we offer clients.

And one of the big pieces I’m missing is backups.

Currently the cPanel shared hosting environments we have keep a couple of days, and a couple of weeks of full account backups for each of our client sites, and the number of times I’ve had to restore from them for various reasons is greater than 0.

DO offers weekly whole-server backups, but my clients expect something a little more frequent and I’d like to be able to provide that.

I see two options.

Plugins
There is no end to the available backup plugins for WordPress, but we’re deploying 2-3 sites per month and making sure we set up a backup plugin according to whatever best practice we lay out, individually, per-site, could get difficult to manage, especially if we ever change that policy.

Do you use a plugin? If so which one? Do you have any kind of config-management in place?

Some Other Script
Another option would be a script that creates an archive of the site’s assets and database (wp-cli db export for the database, cp -r or rsync? for the assets? . The rest is in version control with Trellis after all. Daily backups for a week, combined with DO’s weekly snapshots should do the trick I would think.

Is there a playbook I could create or edit to set up a scheduled backup of these items via cron or some such tool? Have you ever done it this way? Am I crazy?

I appreciate any advice you might have.

2 Likes

This looks nice:

That does look nice. Do you have in you a quick primer for how to use Trellis’s existing variables to configure the backup_profiles in example here?

Trellis is my first Ansible experience and I’m working hard to catch up, but any advice is welcome.

If you outsource your DB to AWS RDS you get minute level DB backups, multiple availability zones, and easy replication and such. Might be a good idea if you need the peace of mind.

1 Like

One more update. I have a prototype role for setting up the above-linked Stouts.backup here: https://github.com/MWDelaney/trellis-backup

I’ll be working on this as times goes on, but it’s a start!

7 Likes

Great start. Why not add it to the Ansible Galaxy in stead of cloning?

Because I’m completely new to Ansible and have no idea how to do that. I’ll get there, I’m sure! Thanks!

1 Like

One more quick note, there appears to be a problem with Stouts.backup that’s preventing jobs from running (a hard coded path to Duplicity is incorrect). I’ve submitted an Issue on their GitHub here.

Here’s a rundown of the fix:

In Stouts.backup/templates/cron.j2

FIND:

{{profile.schedule}} {{profile.user|default(backup_user)}} /usr/local/bin/duply {{backup_home}}/{{profile.name}} {{profile.action|default('backup')}} >> {{backup_logdir}}/{{profile.name}}.log 2>&1

CHANGE TO:

{{profile.schedule}} {{profile.user|default(backup_user)}} /usr/bin/duply {{backup_home}}/{{profile.name}} {{profile.action|default('backup')}} >> {{backup_logdir}}/{{profile.name}}.log 2>&1

Hi, I came across a bug. You’re using “{{admin_user}}” from the with_dict {{wordpress_sites}} for the cron job, however, if you have changed (as i have) the default admin user in your site from “admin” to something else, it is not the same anymore as the Server Admin user (which is what you actually want.

I guess it could be a good for Trellis to rename the property to something like {{wp_admin_user}}. But for now, just using a hardcoded string ‘admin’ as a workaround.

I guess that’s kind of a question for the Trellis team; is there a variable that would make more sense here that covers both scenarios?

I’m trying to figure that out too, but when I run the task neither “web” nor “admin” have permissions to create the directory “{{ www_root }}/{{ item.key }}/backup”, so I’m kind of stuck there right now.

This is a really interesting topic.
Any cheap and simple backup-only cloud services, preferably EU based (GDPR)?
Is deduplication worth it? Would the backup work incrementally?
Would a dedicated ZFS-file server on the cloud make sense?

It’d be interesting to hear how others are handling backups in general.

We’re relying on DigitalOcean for all our backup needs ie. backups enabled on the droplet, block storage & managed database for incremental db backups. Wonder if we’re missing anything / whether this setup is resilient enough? kinda putting all our eggs in the 1 (DigitalOcean) basket.