#!/bin/bash # garage-backup: copy a single-node Garage to a second place with rclone. # garage-backup DEST DEST is an rclone remote path (offsite:garage-backup) # or a local directory. # Order matters: a consistent metadata snapshot first, then the data blocks # (immutable files named by their hash), then the config. # Restore: https://exe.dev/deploy/garage#back-up-and-restore set -euo pipefail DEST=${1:?usage: garage-backup DEST} META=/var/lib/garage/meta DATA=/var/lib/garage/data SNAPS=/var/lib/garage/snapshots garage meta snapshot >/dev/null SNAP=$(ls -1d "$SNAPS"/*/ | sort | tail -n 1) rclone copyto "$SNAP/db.sqlite" "$DEST/meta/db.sqlite" rclone copy "$META" "$DEST/meta" --include 'node_key*' --include cluster_layout --include data_layout rclone sync "$DATA" "$DEST/data" rclone copyto /etc/garage.toml "$DEST/garage.toml" echo "garage-backup: $(basename "$SNAP") -> $DEST"