Updated minecraft backup for lifecycles.
authorLuke Hoersten <luke@hoersten.org>
Sat, 03 Jul 2021 13:38:02 -0500
changeset 158 1b7ccb729164
parent 157 5e5c9e605142
child 159 05d0cf32e077
Updated minecraft backup for lifecycles.
mercurial/aws-s3-backup/files/mercurial-s3-backup-lifecycle.json
minecraft/aws-s3-backup/files/minecraft-s3-backup-lifecycle.json
minecraft/aws-s3-backup/files/minecraft-s3-backup.sh
minecraft/aws-s3-backup/tasks/main.yaml
pleroma/aws-s3-backup/files/pleroma-lifecycle.json
--- a/mercurial/aws-s3-backup/files/mercurial-s3-backup-lifecycle.json	Sat Jul 03 13:24:52 2021 -0500
+++ b/mercurial/aws-s3-backup/files/mercurial-s3-backup-lifecycle.json	Sat Jul 03 13:38:02 2021 -0500
@@ -1,7 +1,7 @@
 {
 	 "Rules": [
 		  {
-				"ID": "pleroma-expiration",
+				"ID": "expiration",
 				"Filter": {},
 				"Status": "Enabled",
 				"NoncurrentVersionExpiration": {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/minecraft/aws-s3-backup/files/minecraft-s3-backup-lifecycle.json	Sat Jul 03 13:38:02 2021 -0500
@@ -0,0 +1,12 @@
+{
+	 "Rules": [
+		  {
+				"ID": "expiration",
+				"Filter": {},
+				"Status": "Enabled",
+				"NoncurrentVersionExpiration": {
+					 "NoncurrentDays": 5
+				}
+		  }
+	 ]
+}
--- a/minecraft/aws-s3-backup/files/minecraft-s3-backup.sh	Sat Jul 03 13:24:52 2021 -0500
+++ b/minecraft/aws-s3-backup/files/minecraft-s3-backup.sh	Sat Jul 03 13:38:02 2021 -0500
@@ -1,12 +1,13 @@
 #!/bin/bash
 
 BUCKET=$1
-DATE=`date --iso-8601`
 BACKUP_DIR=$2
-BACKUP_TAR="/tmp/$BUCKET-$DATE.tgz"
+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/minecraft-s3-backup-lifecycle.json"
 aws s3 cp $BACKUP_TAR "s3://$BUCKET/"
 
 rm $BACKUP_TAR
--- a/minecraft/aws-s3-backup/tasks/main.yaml	Sat Jul 03 13:24:52 2021 -0500
+++ b/minecraft/aws-s3-backup/tasks/main.yaml	Sat Jul 03 13:38:02 2021 -0500
@@ -7,6 +7,13 @@
     dest: "/usr/local/bin/minecraft-s3-backup.sh"
     mode: "0755"
 
+- name: create s3 backup lifesycle json file
+  become: yes
+  copy:
+    src: "minecraft-s3-backup-lifecycle.json"
+    dest: "/usr/local/share/minecraft-s3-backup-lifecycle.json"
+    mode: "0755"
+
 - name: configure minecraft s3 backup systemd service
   become: yes
   template:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pleroma/aws-s3-backup/files/pleroma-lifecycle.json	Sat Jul 03 13:38:02 2021 -0500
@@ -0,0 +1,12 @@
+{
+	 "Rules": [
+		  {
+				"ID": "expiration",
+				"Filter": {},
+				"Status": "Enabled",
+				"NoncurrentVersionExpiration": {
+					 "NoncurrentDays": 30
+				}
+		  }
+	 ]
+}