diff --git a/README.md b/README.md index 96e3288..c7eeba6 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ See [Mitigating Disaster via Website Backups](https://nystudio107.com/blog/mitig The `sync_backups_to_s3.sh` script syncs the backups from `LOCAL_BACKUPS_PATH` to the Amazon S3 bucket specified in `REMOTE_S3_BUCKET`. +If you have defined a optional subfolder, it will contain the backups to the path defined in `REMOTE_S3_PATH`. + This script assumes that you have already [installed awscli](http://docs.aws.amazon.com/cli/latest/userguide/installing.html) and have [configured it](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html) with your credentials. It's recommended that you set up a separate user with access to only S3, and set up a private S3 bucket for your backups. @@ -216,6 +218,8 @@ All settings that are prefaced with `REMOTE_` refer to the remote environment wh `REMOTE_S3_BUCKET` is the name of the Amazon S3 bucket to backup to via the `sync_backups_to_s3.sh` script +`REMOTE_S3_PATH` is a optional path relative to the Amazon S3 bucket where the `sync_backups_to_s3.sh` script will contain the backups if specified + ### Setting up SSH Keys Normally when you `ssh` into a remote server (as some of the `craft-scripts` do), you have to enter your password. Best practices from a security POV is to not allow for password-based logins, but instead use [SSH Keys](https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2). diff --git a/scripts/example.env.sh b/scripts/example.env.sh index 89fd204..dd1d791 100755 --- a/scripts/example.env.sh +++ b/scripts/example.env.sh @@ -109,3 +109,6 @@ REMOTE_BACKUPS_PATH="REPLACE_ME" # Remote Amazon S3 bucket name REMOTE_S3_BUCKET="REPLACE_ME" + +# Optional subfolder relative to the S3 bucket root; paths should always have a trailing / +REMOTE_S3_PATH="" \ No newline at end of file diff --git a/scripts/sync_backups_to_s3.sh b/scripts/sync_backups_to_s3.sh index ef00173..c30eff4 100755 --- a/scripts/sync_backups_to_s3.sh +++ b/scripts/sync_backups_to_s3.sh @@ -38,7 +38,7 @@ if [[ ! -d "${LOCAL_BACKUPS_PATH}" ]] ; then fi # Sync the local backups to the Amazon S3 bucket -aws s3 sync ${LOCAL_BACKUPS_PATH} s3://${REMOTE_S3_BUCKET} +aws s3 sync ${LOCAL_BACKUPS_PATH} s3://${REMOTE_S3_BUCKET}/${REMOTE_S3_PATH} echo "*** Synced backups to ${REMOTE_S3_BUCKET}" # Normal exit