lnd-channel-s3-backup/files/lnd-channel-s3-backup.sh
author Luke Hoersten <luke@hoersten.org>
Mon, 05 Jul 2021 10:46:30 -0500
changeset 19 5c8335b57353
permissions -rw-r--r--
Added lnd channel backup to s3 role.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
5c8335b57353 Added lnd channel backup to s3 role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     1
#!/bin/bash
5c8335b57353 Added lnd channel backup to s3 role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     2
5c8335b57353 Added lnd channel backup to s3 role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     3
BUCKET=$1
5c8335b57353 Added lnd channel backup to s3 role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     4
CHAN_BACKUP=$2
5c8335b57353 Added lnd channel backup to s3 role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     5
5c8335b57353 Added lnd channel backup to s3 role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     6
aws s3 mb "s3://$BUCKET/"
5c8335b57353 Added lnd channel backup to s3 role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     7
aws s3api put-bucket-versioning --bucket "$BUCKET" --versioning-configuration Status=Enabled
5c8335b57353 Added lnd channel backup to s3 role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     8
5c8335b57353 Added lnd channel backup to s3 role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     9
while true; do
5c8335b57353 Added lnd channel backup to s3 role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    10
    inotifywait $CHAN_BACKUP
5c8335b57353 Added lnd channel backup to s3 role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    11
    aws s3 cp $CHAN_BACKUP "s3://$BUCKET/"
5c8335b57353 Added lnd channel backup to s3 role.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    12
done