Kieran's opinionated (and probably slightly dumb) nix config

feat: more logs

dunkirk.sh 19ca97e3 d127dfa4

verified
+38 -29
+38 -29
modules/nixos/services/restic/cli.nix
··· 132 132 exit 1 133 133 fi 134 134 135 + run_backup() { 136 + local svc_name=$1 137 + 138 + # Check if already running 139 + if systemctl is-active --quiet "restic-backups-$svc_name.service"; then 140 + style --foreground 214 "! $svc_name backup already in progress" 141 + style --foreground 117 " Use: journalctl -u restic-backups-$svc_name.service -f" 142 + return 1 143 + fi 144 + 145 + style --foreground 117 "Backing up $svc_name..." 146 + 147 + # Start following journal before starting service 148 + journalctl -u "restic-backups-$svc_name.service" -f -n 0 --output=cat & 149 + journal_pid=$! 150 + 151 + # Small delay to ensure journalctl is attached 152 + sleep 0.2 153 + 154 + systemctl start "restic-backups-$svc_name.service" 155 + 156 + while systemctl is-active --quiet "restic-backups-$svc_name.service"; do 157 + sleep 1 158 + done 159 + 160 + kill $journal_pid 2>/dev/null || true 161 + 162 + if systemctl is-failed --quiet "restic-backups-$svc_name.service"; then 163 + style --foreground 196 "✗ $svc_name failed" 164 + return 1 165 + else 166 + style --foreground 35 "✓ $svc_name complete" 167 + return 0 168 + fi 169 + } 170 + 135 171 if [ "$svc" = "all" ]; then 136 172 for s in $SERVICES; do 137 - style --foreground 117 "Backing up $s..." 138 - systemctl start "restic-backups-$s.service" 139 - journalctl -u "restic-backups-$s.service" -f -n 0 --output=cat & 140 - journal_pid=$! 141 - while systemctl is-active --quiet "restic-backups-$s.service"; do 142 - sleep 1 143 - done 144 - kill $journal_pid 2>/dev/null || true 145 - if systemctl is-failed --quiet "restic-backups-$s.service"; then 146 - style --foreground 214 "! Failed to backup $s" 147 - else 148 - style --foreground 35 "✓ $s complete" 149 - fi 173 + run_backup "$s" || true 150 174 echo 151 175 done 152 176 else 153 - style --foreground 117 "Backing up $svc..." 154 - systemctl start "restic-backups-$svc.service" 155 - journalctl -u "restic-backups-$svc.service" -f -n 0 --output=cat & 156 - journal_pid=$! 157 - while systemctl is-active --quiet "restic-backups-$svc.service"; do 158 - sleep 1 159 - done 160 - kill $journal_pid 2>/dev/null || true 177 + run_backup "$svc" 161 178 fi 162 179 163 - if [ "$svc" != "all" ]; then 164 - if systemctl is-failed --quiet "restic-backups-$svc.service"; then 165 - style --foreground 196 "✗ Backup failed" 166 - exit 1 167 - else 168 - style --foreground 35 "✓ Backup complete" 169 - fi 170 - fi 171 180 } 172 181 173 182 cmd_restore() {