diff --git a/README.md b/README.md index 3066e00..233f273 100644 --- a/README.md +++ b/README.md @@ -322,10 +322,13 @@ docker compose down # stop Every service in this repo backs up a live config before overwriting it — `Caddyfile.backup.`, `/etc/fstab.backup.`, and so on — but nothing cleans those up afterward, so they build up on any box -reconfigured regularly. `base` offers a daily systemd timer -(`prune-old-backups`) that removes anything older than 30 days, always -keeping at least the single newest backup per file regardless of age — a -box left alone for months never ends up with zero backups for something. +reconfigured regularly. `base` sets up a daily systemd timer +(`prune-old-backups`), automatically and without asking (the same way it +sets up [tab completion](#tab-completion) — low-stakes enough not to need +a prompt, and idempotent either way), that removes anything older than 30 +days, always keeping at least the single newest backup per file regardless +of age — a box left alone for months never ends up with zero backups for +something. ```bash sudo bash tools/prune-old-backups.sh [KEEP_DAYS] # run by hand, default 30 diff --git a/services/base.sh b/services/base.sh index 346b4b1..f776807 100644 --- a/services/base.sh +++ b/services/base.sh @@ -23,7 +23,7 @@ install_base() { echo "[DRY-RUN] Would offer CrowdSec intrusion prevention install (full repo only)" echo "[DRY-RUN] Would offer to add SSH Host aliases to ~/.ssh/config" echo "[DRY-RUN] Would add setup.sh tab completion to ~/.bashrc (if not already there)" - echo "[DRY-RUN] Would offer daily pruning of old *.backup.* config files (systemd timer)" + echo "[DRY-RUN] Would set up daily pruning of old *.backup.* config files (systemd timer, if not already there)" return 0 fi @@ -120,9 +120,12 @@ _base_setup_tab_completion() { # Every service in this repo backs up a live config before overwriting it # (Caddyfile, /etc/fstab, ...) but none of them ever clean those up # afterward — see tools/prune-old-backups.sh's own header for the full -# reasoning. Offers a daily systemd timer that prunes anything older than +# reasoning. Sets up a daily systemd timer that prunes anything older than # 30 days, always keeping at least the single newest backup per file -# regardless of age. +# regardless of age. No prompt — same reasoning as _base_setup_tab_completion +# right above: idempotent, and the safety net (only ever touches disposable +# *.backup.* files, never the newest one for anything) makes this low-stakes +# enough not to ask about, the same way that one doesn't. _base_setup_backup_pruning() { command -v systemctl >/dev/null 2>&1 || return 0 systemctl list-unit-files prune-old-backups.timer --no-legend 2>/dev/null | grep -q . && return 0 @@ -130,11 +133,6 @@ _base_setup_backup_pruning() { local prune_script="$HERE/tools/prune-old-backups.sh" [ -f "$prune_script" ] || return 0 - echo "" - local ENABLE_PRUNE="" - prompt_yn "Automatically prune old config backups (Caddyfile.backup.*, fstab.backup.*, etc — keeps 30 days, always keeps at least the newest one)? (y/n):" "y" ENABLE_PRUNE - [[ "$ENABLE_PRUNE" =~ ^[Yy]$ ]] || return 0 - cat > /etc/systemd/system/prune-old-backups.service << UNIT [Unit] Description=Prune old *.backup.* config backups (Caddyfile, fstab, etc)