From f8aa3247303a857a07581d9e97d08347d149b4d5 Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Sun, 4 Jul 2021 12:05:24 -0500 Subject: Added writefreely backup. --- writefreely/aws-s3-backup/files/writefreely-s3-backup.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 writefreely/aws-s3-backup/files/writefreely-s3-backup.sh (limited to 'writefreely/aws-s3-backup/files/writefreely-s3-backup.sh') 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 -- cgit v1.2.3