mercurial/aws-s3-backup/files/mercurial-s3-backup.sh
author Luke Hoersten <luke@hoersten.org>
Sat, 24 Jul 2021 17:55:23 -0500
changeset 171 534b247bed1c
parent 157 5e5c9e605142
permissions -rw-r--r--
Fixed writefreely role.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
df042396074e Opensourcing raspberry pi roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     1
#!/bin/bash
df042396074e Opensourcing raspberry pi roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     2
df042396074e Opensourcing raspberry pi roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     3
BUCKET=$1
df042396074e Opensourcing raspberry pi roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     4
BACKUP_DIR=$2
157
5e5c9e605142 Add aws s3 versioning and lifecycles to backup.
Luke Hoersten <luke@hoersten.org>
parents: 136
diff changeset
     5
BACKUP_TAR="/tmp/$BUCKET.tgz"
0
df042396074e Opensourcing raspberry pi roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     6
df042396074e Opensourcing raspberry pi roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     7
tar -zc -f $BACKUP_TAR $BACKUP_DIR
df042396074e Opensourcing raspberry pi roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     8
aws s3 mb "s3://$BUCKET/"
157
5e5c9e605142 Add aws s3 versioning and lifecycles to backup.
Luke Hoersten <luke@hoersten.org>
parents: 136
diff changeset
     9
aws s3api put-bucket-versioning --bucket "$BUCKET" --versioning-configuration Status=Enabled
5e5c9e605142 Add aws s3 versioning and lifecycles to backup.
Luke Hoersten <luke@hoersten.org>
parents: 136
diff changeset
    10
aws s3api put-bucket-lifecycle-configuration --bucket "$BUCKET" --lifecycle-configuration "file:///usr/local/share/mercurial-s3-backup-lifecycle.json"
0
df042396074e Opensourcing raspberry pi roles.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    11
aws s3 cp $BACKUP_TAR "s3://$BUCKET/"
136
1751be33651f Added cleanup to mercurial backup script.
Luke Hoersten <luke@hoersten.org>
parents: 56
diff changeset
    12
1751be33651f Added cleanup to mercurial backup script.
Luke Hoersten <luke@hoersten.org>
parents: 56
diff changeset
    13
rm $BACKUP_TAR