Aegir batch site backup script

Many Aegir users ask whether there is a way to schedule backups of all sites provisioned in Aegir. Currently at the time of writing, no such scheduling exists within Aegir itself, since we have a few design decisions to work out (such as where to store the backups, especially when multi-server comes in!)

For the meantime, here's a crude little shell script that might help you. You should execute it as the aegir user.

Users of Ubuntu with /bin/sh symlinked to /bin/dash might experience problems with Drush that have been documented elsewhere. Consider changing the shebang to #!/bin/bash and executing it with bash rather than sh.

Users that have Drush 2.1 or earlier and Aegir 0.4alpha3 or earlier should use the aegir_backup_0.4-alpha3.sh script. Users of Drush and Aegir HEAD components, or anything higher than Drush 2.1, should use the aegir_backup.sh script. The difference is that the backup command (like all other of our Drush commands) has changed in Aegir from 'provision backup' to 'provision-backup', to make Aegir compatible with the next version of Drush which uses hyphenated commands.

aegir_backup.sh

aegir_backup_0.4-alpha3.sh

The latest versions of the scripts are always available on git.mig5.net in the scripts repository.

Hopefully you don't need to change any variables if you are using the recommended file structure (/var/aegir/config/vhost.d to store the apache vhost configs etc), but you can if you wish, and you can tweak the verbosity.

Please do test and let me know if it works. It works for me. Ideally you'd put it in aegir's crontab to run hourly or daily or somesuch, i.e midnight every night:

0 0 * * * bash /var/aegir/aegir_backup.sh

Note that because these provision-backup scripts are being executed only from the backend via the CLI and not via the Hosting frontend, they aren't associated with the Aegir database/task store in any way, meaning that these backups aren't registered in Aegir as being available to use the Restore command against (at least, not through the frontend). You would have to restore from these backups manually with the 'provision-restore' or provision-deploy command, which is unfortunate, but hey! at least you have backups right? :)

This whole process will get a lot easier if/when we get scheduled backups implemented properly. I hope this helps you.

Tags: