aboutsummaryrefslogtreecommitdiff
path: root/content/operations/rclone.md
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-04-17 12:24:51 +0200
committerAlex Auvolat <alex@adnab.me>2023-04-17 12:24:51 +0200
commit7d41074f738de8f9d7a7e910fb1c26ed698373c2 (patch)
tree4f9ec3cea7b573d7fe7a90e619453ab3473b6a40 /content/operations/rclone.md
parent1701a090c292f9f3f1894e6844032b3cbe6d15de (diff)
parent4a98a21215262f646307113782b3e8762de70660 (diff)
downloadguide.deuxfleurs.fr-7d41074f738de8f9d7a7e910fb1c26ed698373c2.tar.gz
guide.deuxfleurs.fr-7d41074f738de8f9d7a7e910fb1c26ed698373c2.zip
Merge branch 'main' into reduce-image-sizes
Diffstat (limited to 'content/operations/rclone.md')
-rw-r--r--content/operations/rclone.md78
1 files changed, 78 insertions, 0 deletions
diff --git a/content/operations/rclone.md b/content/operations/rclone.md
new file mode 100644
index 0000000..1352aaf
--- /dev/null
+++ b/content/operations/rclone.md
@@ -0,0 +1,78 @@
+---
+title: "rclone"
+description: "rclone"
+weight: 20
+sort_by: "weight"
+extra:
+ parent: 'operations/sauvegardes.md'
+---
+
+Script de backup brut, on planifie une approche plus élégante à l'avenir :
+
+```
+#!/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
+```