Fix: Show backup logs from service start, not just new entries

PROBLEM:
- journalctl -fu only shows NEW log entries after you start following
- By the time journalctl started, backup had already begun
- User missed all initial output and saw blank screen

ROOT CAUSE:
- We started the service, then started journalctl
- The -f flag only follows future entries
- All the backup progress was already written to journal before follow began

SOLUTION:
1. Start systemctl in background with &
2. Reduced sleep from 1s to 0.5s
3. Use --since "5 seconds ago" to capture logs from service start
4. Use -n 100 to show last 100 lines of context
5. Moved progress box display before starting service

CHANGES:
- journalctl -fu SERVICE -> journalctl -u SERVICE -f --since "5 seconds ago" -n 100
- systemctl start SERVICE -> systemctl start SERVICE & (background)
- sleep 1 -> sleep 0.5
- Applied to both manual backup locations

Now user sees full verbose backup output including:
- File backup progress bars
- Block device backup transfer rates
- Chunk upload progress
- All PBS client output

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zaphod-black 2025-11-01 19:51:36 -05:00
parent 9486eb6a8c
commit f542fe2730

View file

@ -994,12 +994,6 @@ run_backup_now() {
log "Starting immediate FULL backup (files + block device)..."
echo
# Start the manual backup (forces full backup)
systemctl start pbs-backup-manual.service
# Wait a moment for service to start
sleep 1
# Show real-time progress
echo "╔════════════════════════════════════════════════════════════╗"
echo "║ Backup Progress (Live) ║"
@ -1007,6 +1001,12 @@ run_backup_now() {
echo "╚════════════════════════════════════════════════════════════╝"
echo
# Start the manual backup (forces full backup)
systemctl start pbs-backup-manual.service &
# Wait a brief moment for service to register
sleep 0.5
# Monitor backup in background and kill journalctl when done
(
while systemctl is-active --quiet pbs-backup-manual.service; do
@ -1017,8 +1017,9 @@ run_backup_now() {
) &
MONITOR_PID=$!
# Follow logs in foreground (will be killed by monitor when backup completes)
journalctl -fu pbs-backup-manual.service 2>/dev/null || true
# Follow logs in foreground from the start (will be killed by monitor when backup completes)
# Use --since to catch logs from service start, and -n 100 to show recent context
journalctl -u pbs-backup-manual.service -f --since "5 seconds ago" -n 100 2>/dev/null || true
# Wait for monitor to finish
wait $MONITOR_PID 2>/dev/null
@ -1149,12 +1150,6 @@ main() {
info "Running FULL backup now (files + block device)..."
echo
# Start the manual backup (forces full backup)
systemctl start pbs-backup-manual.service
# Wait a moment for service to start
sleep 1
# Show real-time progress
echo "╔════════════════════════════════════════════════════════════╗"
echo "║ Backup Progress (Live) ║"
@ -1162,6 +1157,12 @@ main() {
echo "╚════════════════════════════════════════════════════════════╝"
echo
# Start the manual backup (forces full backup)
systemctl start pbs-backup-manual.service &
# Wait a brief moment for service to register
sleep 0.5
# Monitor backup in background and kill journalctl when done
(
while systemctl is-active --quiet pbs-backup-manual.service; do
@ -1172,8 +1173,9 @@ main() {
) &
MONITOR_PID=$!
# Follow logs in foreground (will be killed by monitor when backup completes)
journalctl -fu pbs-backup-manual.service 2>/dev/null || true
# Follow logs in foreground from the start (will be killed by monitor when backup completes)
# Use --since to catch logs from service start, and -n 100 to show recent context
journalctl -u pbs-backup-manual.service -f --since "5 seconds ago" -n 100 2>/dev/null || true
# Wait for monitor to finish
wait $MONITOR_PID 2>/dev/null