Skip to content

Commit

Permalink
Merge pull request #11 from sjelfull/master
Browse files Browse the repository at this point in the history
Add support for optional subfolder in sync_backups_to_s3.sh
  • Loading branch information
khalwat authored Jun 28, 2017
2 parents 4bc7104 + 246ea6c commit 6b0aa20
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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).
Expand Down
3 changes: 3 additions & 0 deletions scripts/example.env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
2 changes: 1 addition & 1 deletion scripts/sync_backups_to_s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b0aa20

Please sign in to comment.