diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-04-23 13:27:52 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-04-23 13:27:52 +0200 |
commit | 2695a79e8ad351c8a62a126c2b4d614a12319a07 (patch) | |
tree | d2567aa93dcbd7930dfeb0a15118ad8951572c2a /op_guide/garage | |
parent | 1e9a538be9f8496fd6241f010a4648a06200b125 (diff) | |
download | infrastructure-2695a79e8ad351c8a62a126c2b4d614a12319a07.tar.gz infrastructure-2695a79e8ad351c8a62a126c2b4d614a12319a07.zip |
Add garage backup info
Diffstat (limited to 'op_guide/garage')
-rw-r--r-- | op_guide/garage/README.md | 1 | ||||
-rw-r--r-- | op_guide/garage/backup.sh | 65 |
2 files changed, 66 insertions, 0 deletions
diff --git a/op_guide/garage/README.md b/op_guide/garage/README.md new file mode 100644 index 0000000..44fda62 --- /dev/null +++ b/op_guide/garage/README.md @@ -0,0 +1 @@ +Not very generic currently, check the backup.sh script diff --git a/op_guide/garage/backup.sh b/op_guide/garage/backup.sh new file mode 100644 index 0000000..2ff18cd --- /dev/null +++ b/op_guide/garage/backup.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +cd $(dirname $0) + +if [ "$(hostname)" != "io" ]; then + echo "Please run this script on io" + exit 1 +fi + +if [ ! -d "buckets" ]; then + btrfs subvolume create $(pwd)/buckets +fi + + +AK=$1 +SK=$2 + +function gctl { + docker exec garage /garage $@ +} + +gctl status +BUCKETS=$(gctl bucket list | tail -n +2 | cut -d " " -f 3 | cut -d "," -f 1) + +for BUCKET in $BUCKETS; do + case $BUCKET in + *backup*) + echo "Skipping $BUCKET (not doing backup of backup)" + ;; + *cache*) + echo "Skipping $BUCKET (not doing backup of cache)" + ;; + *) + echo "Backing up $BUCKET" + + if [ ! -d $(pwd)/buckets/$BUCKET ]; then + mkdir $(pwd)/buckets/$BUCKET + fi + + gctl bucket allow --key $AK --read $BUCKET + rclone sync --s3-endpoint http://localhost:3900 \ + --s3-access-key-id $AK \ + --s3-secret-access-key $SK \ + --s3-region garage \ + --s3-force-path-style \ + --transfers 32 \ + --fast-list \ + --stats-one-line \ + --stats 10s \ + --stats-log-level NOTICE \ + :s3:$BUCKET $(pwd)/buckets/$BUCKET + ;; + esac +done + +# Remove duplicates +#duperemove -dAr $(pwd)/buckets + +if [ ! -d "$(pwd)/snapshots" ]; then + mkdir snapshots +fi + +SNAPSHOT=$(pwd)/snapshots/buckets-$(date +%F) +echo "Making snapshot: $SNAPSHOT" +btrfs subvolume snapshot $(pwd)/buckets $SNAPSHOT |