Ajout : sauvegardes automatiques des bases postgresql.
[lhc/ateliers.git] / local / backup-status
diff --git a/local/backup-status b/local/backup-status
new file mode 100755 (executable)
index 0000000..a82d2f9
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh -eu
+# SYNTAX: $databases [...]
+tool=$(readlink -e "${0%/*}/..")
+TRACE=${TRACE:-}
+. "$tool"/local/lib.sh
+
+for data in $(sudo -u backup find ~backup/data \
+ -mindepth 2 -maxdepth 2 -type d \
+ ${@:+-false $(printf -- '-or -path /home/backup/data/%s\n' "$@")} \
+ -printf '%P\n')
+ do
+       # NOTE: 0.9765625 = $(units -1 kilobytes kibibytes)
+       size=$(bc <<-EOF
+               scale=0; print ($(sudo -u backup du -ks ~backup/data/"$data" | cut -f 1) * 0.9765625 / 1), " Kio"
+               EOF
+        )
+       info '' data size
+       cat <<-EOF
+               ${tput_setaf_0}${tput_bold}
+               $(sudo -u backup ~backup/bin/duplicity 2>/dev/null \
+                --name "$data" \
+                collection-status \
+                file:///home/backup/data/"$data")
+               ${tput_sgr0}
+               EOF
+ done