From 545adbc2e058c1f456550aea4744dfef5c097085 Mon Sep 17 00:00:00 2001 From: Theodotos Andreou Date: Tue, 16 Jan 2018 11:22:13 +0200 Subject: [PATCH] Updated Setting up Backup (markdown) --- Setting-up-Backup.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Setting-up-Backup.md b/Setting-up-Backup.md index 2fd52dc..b220780 100644 --- a/Setting-up-Backup.md +++ b/Setting-up-Backup.md @@ -16,6 +16,26 @@ $ drush dl backup_migrate $ drush en backup_migrate ``` +## Deny access to the backup folders + +Add these in the virtualhost file (*/etc/nginx/sites-available/cms*): + +``` + location ~ ^/sites/.*/files/private/backup_migrate/manual { + deny all; + } + + location ~ ^/sites/.*/files/private/backup_migrate/scheduled { + deny all; + } +``` + +Reload *Nginx*: + +``` +$ sudo systemctl reload nginx +``` + ## Create a scheduled backup Go to `Configuration -> Backup and Migrate -> Schedules`: @@ -37,12 +57,13 @@ Prepare the following script (*/etc/cron.daily/backup-cms*): #!/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +HOSTNAME=$(hostname) 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}/${HOSTNAME}/ 2>&1 ${S3_CMS_LOG_PATH} +aws s3 sync ${CMS_BACKUP_PATH} s3://${S3_BUCKET}/${HOSTNAME} > ${S3_CMS_LOG_PATH} 2>&1 find ${CMS_BACKUP_PATH} -type f -mtime +30 -delete find /var/log/aws-s3-sync-*.log -type f -mtime +30 -delete