diff options
| author | Luke Hoersten <[email protected]> | 2020-06-29 18:38:49 -0500 |
|---|---|---|
| committer | Luke Hoersten <[email protected]> | 2020-06-29 18:38:49 -0500 |
| commit | 993697be3753be25f3d05617c53d66c64b0e97b5 (patch) | |
| tree | 41cb6f26f121f0659be66269110624bd21a3cf63 /mercurial/aws-s3-backup | |
| parent | b4c42a383953a34d6ff8091caf6e6bd34776b0c6 (diff) | |
Added mercurial web hosting
Diffstat (limited to 'mercurial/aws-s3-backup')
| -rw-r--r-- | mercurial/aws-s3-backup/files/mercurial-s3-backup.sh | 10 | ||||
| -rw-r--r-- | mercurial/aws-s3-backup/handlers/main.yaml | 5 | ||||
| -rw-r--r-- | mercurial/aws-s3-backup/tasks/main.yaml | 19 | ||||
| -rw-r--r-- | mercurial/aws-s3-backup/templates/[email protected] | 9 |
4 files changed, 43 insertions, 0 deletions
diff --git a/mercurial/aws-s3-backup/files/mercurial-s3-backup.sh b/mercurial/aws-s3-backup/files/mercurial-s3-backup.sh new file mode 100644 index 0000000..b5ba305 --- /dev/null +++ b/mercurial/aws-s3-backup/files/mercurial-s3-backup.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +BUCKET=$1 +DATE=`date --iso-8601` +BACKUP_DIR=$2 +BACKUP_TAR="/tmp/$BUCKET-$DATE.tgz" + +tar -zc -f $BACKUP_TAR $BACKUP_DIR +aws s3 mb "s3://$BUCKET/" +aws s3 cp $BACKUP_TAR "s3://$BUCKET/" diff --git a/mercurial/aws-s3-backup/handlers/main.yaml b/mercurial/aws-s3-backup/handlers/main.yaml new file mode 100644 index 0000000..8c3315b --- /dev/null +++ b/mercurial/aws-s3-backup/handlers/main.yaml @@ -0,0 +1,5 @@ +--- + +- name: reload s3 backup service + systemd: name="mercurial-s3-backup@{{mercurial_s3_backup_bucket}}.service" enabled="yes" daemon_reload="yes" + become: yes diff --git a/mercurial/aws-s3-backup/tasks/main.yaml b/mercurial/aws-s3-backup/tasks/main.yaml new file mode 100644 index 0000000..45a3457 --- /dev/null +++ b/mercurial/aws-s3-backup/tasks/main.yaml @@ -0,0 +1,19 @@ +--- + +- name: create mercurial s3 backup shell script + become: yes + copy: + src: "mercurial-s3-backup.sh" + dest: "/usr/local/bin/mercurial-s3-backup.sh" + mode: "0755" + +- name: configure mercurial s3 backup systemd service + become: yes + template: + src: "[email protected]" + dest: "/lib/systemd/system/mercurial-s3-backup@{{mercurial_s3_backup_bucket}}.service" + notify: reload s3 backup service + +- name: ensure mercurial s3 backup service is started + become: yes + systemd: name="mercurial-s3-backup@{{mercurial_s3_backup_bucket}}.service" enabled="yes" diff --git a/mercurial/aws-s3-backup/templates/[email protected] b/mercurial/aws-s3-backup/templates/[email protected] new file mode 100644 index 0000000..ba6ca80 --- /dev/null +++ b/mercurial/aws-s3-backup/templates/[email protected] @@ -0,0 +1,9 @@ +[Unit] +Description=Mercurial s3 backup for "%I" + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/mercurial-s3-backup.sh %i "{{mercurial_s3_backup_dir}}" + +[Install] +WantedBy=aws-s3-backup.target |
