aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xlifeboat29
1 files changed, 13 insertions, 16 deletions
diff --git a/lifeboat b/lifeboat
index 4ce396c..ec13352 100755
--- a/lifeboat
+++ b/lifeboat
@@ -4,8 +4,12 @@ set -e
LIFEBOAT_ROOT=${LIFEBOAT_ROOT:-"/srv/backup/lifeboat"}
-errx() {
+err() {
printf "lifeboat: %s\n" "$1" >&2
+}
+
+errx() {
+ err "$1"
exit 1
}
@@ -42,28 +46,21 @@ clean_default() {
}
sync_default() {
- if ! test -r config/sync; then
- return
- fi
+ test -r config/sync || return
while read -r target_spec; do
target=$(echo "$target_spec" | cut -f1)
limit=$(echo "$target_spec" | cut -sf2)
- if test -n "$limit"; then
- if test "$(du -s "$RESTIC_REPOSITORY" | cut -f1)" -gt "$limit"; then
- printf "Warning: size threshold exceeded, skipping sync to %s\n" "$target/$LIFEBOAT_REPO_NAME"
- else
- sync_single "$target"
- fi
- else
- sync_single "$target"
+ test -n "$target" || errx "Empty target in config/sync"
+
+ if test -n "$limit" && test "$(du -s "$RESTIC_REPOSITORY" | cut -f1)" -gt "$limit"; then
+ err "Warning: size threshold exceeded, skipping sync to $target/$LIFEBOAT_REPO_NAME"
+ continue
fi
- done < config/sync
-}
-sync_single() {
- rclone sync --transfers 20 --fast-list "$RESTIC_REPOSITORY" "$1/$LIFEBOAT_REPO_NAME"
+ rclone sync --transfers 20 --fast-list "$RESTIC_REPOSITORY" "$target/$LIFEBOAT_REPO_NAME"
+ done < config/sync
}
test $# -lt 2 && usage