diff --git a/Setting-up-Backup.md b/Setting-up-Backup.md new file mode 100644 index 0000000..68bd016 --- /dev/null +++ b/Setting-up-Backup.md @@ -0,0 +1,70 @@ +Here we are describing a basic back-up scenario for our site. We will be using Amazon S3 for the backup. + +## Install *Backup and Migrate* Module + +Sign in as the *webadmin* user: + +``` +$ sudo su - webadmin +``` + +Download and enable the *Backup and Migrate' module: + +``` +$ cd cms +$ ./vendor/bin/drush dl backup_migrate +$ ./vendor/bin/drush en backup_migrate +``` + +## Setup CRON + +Run `crontab -e` as the *webadmin* user and add this cron job: + +``` +0 * * * * wget -O - -q -t 1 https://cms.theo-andreou.org/cron.php?cron_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX#overlay-context= +``` + +## Create a scheduled backup + +Go to `Configuration -> Backup and Migrate -> Schedules`: + +Press the 'Add Schedule': +* Schedule Name: **Daily backup** +* Backup Source: **Entire site** +* Enabled: **Tick** + +Keep the default settings on everything else. + +## Prepare the backup script + +Install prerequisites: + +Prepare the following script (*/etc/cron.daily/backup-cms*): + +``` +#!/bin/sh + +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +CMS_BACKUP_PATH=/srv/webadmin/cms/sites/default/private/backup_migrate/scheduled +S3_CMS_LOG_PATH=/var/log/aws-s3-sync-cms-$(date +%F).log +S3_BUCKET=s3.example.com + +aws s3 sync ${CMS_BACKUP_PATH} s3://${S3_BUCKET}/ 2>&1 ${S3_CMS_LOG_PATH} + +find ${CMS_BACKUP_PATH} -type f -mtime +30 -delete +find /var/log/aws-s3-sync-*.log -type f -mtime +30 -delete +``` + +Give execute permissions: + +``` +# chmod +x /etc/cron.daily/backup-cms +``` + +**NOTE: This is an over-simplified backup scenario. For large installations you may need to come up with something more elaborate.** + +References +---------- +* https://www.drupal.org/docs/7/backing-up-and-migrating-a-site/backing-up-a-site +* https://www.drupal.org/docs/7/setting-up-cron-for-drupal/configuring-cron-jobs-using-the-cron-command \ No newline at end of file