diff options
| author | Luke Hoersten <[email protected]> | 2021-07-04 12:05:24 -0500 |
|---|---|---|
| committer | Luke Hoersten <[email protected]> | 2021-07-04 12:05:24 -0500 |
| commit | f8aa3247303a857a07581d9e97d08347d149b4d5 (patch) | |
| tree | d4e902fed13c2e7bc0544fbaec20542ab12362f1 /writefreely/aws-s3-backup/files/writefreely-s3-backup.sh | |
| parent | 74bb4077fed1ed5927e4e0385c75d469af6debbf (diff) | |
Added writefreely backup.
Diffstat (limited to 'writefreely/aws-s3-backup/files/writefreely-s3-backup.sh')
| -rw-r--r-- | writefreely/aws-s3-backup/files/writefreely-s3-backup.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/writefreely/aws-s3-backup/files/writefreely-s3-backup.sh b/writefreely/aws-s3-backup/files/writefreely-s3-backup.sh new file mode 100644 index 0000000..402d6fe --- /dev/null +++ b/writefreely/aws-s3-backup/files/writefreely-s3-backup.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +BUCKET=$1 +BACKUP_DIR=$2 +BACKUP_TAR="/tmp/$BUCKET.tgz" + +tar -zc -f $BACKUP_TAR $BACKUP_DIR +aws s3 mb "s3://$BUCKET/" +aws s3api put-bucket-versioning --bucket "$BUCKET" --versioning-configuration Status=Enabled +aws s3api put-bucket-lifecycle-configuration --bucket "$BUCKET" --lifecycle-configuration "file:///usr/local/share/writefreely-s3-backup-lifecycle.json" +aws s3 cp $BACKUP_TAR "s3://$BUCKET/" + +rm $BACKUP_TAR |
