diff options
| author | Luke Hoersten <[email protected]> | 2021-07-05 10:46:30 -0500 |
|---|---|---|
| committer | Luke Hoersten <[email protected]> | 2021-07-05 10:46:30 -0500 |
| commit | d31c0aa6ae67ec592b90ffb42e33982ebf73d676 (patch) | |
| tree | 65b65709c33b62ab6fb219e442daaaf1abe97fa3 | |
| parent | 6ef783150c4a91be790cee5c81379b80d0845e91 (diff) | |
Added lnd channel backup to s3 role.
| -rw-r--r-- | lnd-channel-s3-backup/files/lnd-channel-s3-backup.sh | 12 | ||||
| -rw-r--r-- | lnd-channel-s3-backup/handlers/main.yaml | 5 | ||||
| -rw-r--r-- | lnd-channel-s3-backup/meta/main.yaml | 4 | ||||
| -rw-r--r-- | lnd-channel-s3-backup/tasks/main.yaml | 25 | ||||
| -rw-r--r-- | lnd-channel-s3-backup/templates/[email protected] | 10 |
5 files changed, 56 insertions, 0 deletions
diff --git a/lnd-channel-s3-backup/files/lnd-channel-s3-backup.sh b/lnd-channel-s3-backup/files/lnd-channel-s3-backup.sh new file mode 100644 index 0000000..53cd292 --- /dev/null +++ b/lnd-channel-s3-backup/files/lnd-channel-s3-backup.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +BUCKET=$1 +CHAN_BACKUP=$2 + +aws s3 mb "s3://$BUCKET/" +aws s3api put-bucket-versioning --bucket "$BUCKET" --versioning-configuration Status=Enabled + +while true; do + inotifywait $CHAN_BACKUP + aws s3 cp $CHAN_BACKUP "s3://$BUCKET/" +done diff --git a/lnd-channel-s3-backup/handlers/main.yaml b/lnd-channel-s3-backup/handlers/main.yaml new file mode 100644 index 0000000..4cbab58 --- /dev/null +++ b/lnd-channel-s3-backup/handlers/main.yaml @@ -0,0 +1,5 @@ +--- + +- name: reload s3 backup service + systemd: name="lnd-channel-s3-backup@{{lnd_channel_s3_backup_bucket}}.service" enabled="yes" daemon_reload="yes" + become: yes diff --git a/lnd-channel-s3-backup/meta/main.yaml b/lnd-channel-s3-backup/meta/main.yaml new file mode 100644 index 0000000..f9c6f63 --- /dev/null +++ b/lnd-channel-s3-backup/meta/main.yaml @@ -0,0 +1,4 @@ +--- + +dependencies: + - aws-s3-backup diff --git a/lnd-channel-s3-backup/tasks/main.yaml b/lnd-channel-s3-backup/tasks/main.yaml new file mode 100644 index 0000000..c54de1a --- /dev/null +++ b/lnd-channel-s3-backup/tasks/main.yaml @@ -0,0 +1,25 @@ +--- + +# https://gist.github.com/alexbosworth/2c5e185aedbdac45a03655b709e255a3 + +- name: install lnd-channel s3 backup apt packages + become: yes + apt: name="inotify-tools" + +- name: create lnd-channel s3 backup shell script + become: yes + copy: + src: "lnd-channel-s3-backup.sh" + dest: "/usr/local/bin/lnd-channel-s3-backup.sh" + mode: "0755" + +- name: configure lnd-channel s3 backup systemd service + become: yes + template: + src: "[email protected]" + dest: "/lib/systemd/system/lnd-channel-s3-backup@{{lnd_channel_s3_backup_bucket}}.service" + notify: reload s3 backup service + +- name: ensure lnd-channel s3 backup service is started + become: yes + systemd: name="lnd-channel-s3-backup@{{lnd_channel_s3_backup_bucket}}.service" enabled="yes" diff --git a/lnd-channel-s3-backup/templates/[email protected] b/lnd-channel-s3-backup/templates/[email protected] new file mode 100644 index 0000000..b3c1ead --- /dev/null +++ b/lnd-channel-s3-backup/templates/[email protected] @@ -0,0 +1,10 @@ +[Unit] +Description=LND channel s3 backup for "%I" + +[Service] +ExecStart=/usr/local/bin/lnd-channel-s3-backup.sh %i "{{lnd_channel_s3_backup}}" +Restart=always +RestartSec=1 + +[Install] +WantedBy=multi-user.target |
