Skip to content

Fix app re-enable after upgrade (#2797)#2816

Open
notarealnumber wants to merge 1 commit intonextcloud:mainfrom
notarealnumber:fix/app-reenable-backup-rotation-2797
Open

Fix app re-enable after upgrade (#2797)#2816
notarealnumber wants to merge 1 commit intonextcloud:mainfrom
notarealnumber:fix/app-reenable-backup-rotation-2797

Conversation

@notarealnumber
Copy link
Copy Markdown

Fixes #2797

Problem

The enabled_apps_before_upgrade.txt is saved to $BACKUP in line 369, but the backup
rotation (formerly lines 1157-1164) moves everything to $BACKUP-OLD/<timestamp>/, deletes
$BACKUP, and recreates it empty. When the re-enable logic runs at line 1366, the file is
gone. The condition silently evaluates to false and no apps are re-enabled.

Root cause

$BACKUP pointed to a fixed path (/mnt/NCBACKUP) that was reused and rotated during
the same script run.

Fix

  • lib.sh: $BACKUP now includes a timestamp (/mnt/NCBACKUP/<timestamp>), giving each
    run its own directory. No rotation needed, no file loss.
  • nextcloud_update.sh: Remove the rotation block. Add cleanup of backups older than one
    year. Fix the legacy migration block (/var/NCBACKUP → new structure). The re-enable
    logic works unchanged since $BACKUP now persists throughout the script.

Additional fixes

  • Eliminates a race condition where $(date +%Y-%m-%d-%H%M%S) was called separately for
    mkdir and rsync, potentially producing two different timestamps.

The enabled_apps_before_upgrade.txt was written to $BACKUP before the
backup rotation moved all contents to $BACKUP-OLD/<timestamp> and
recreated an empty $BACKUP directory. The re-enable logic at the end
of the script could never find the file.

Fix: Move the timestamp into the $BACKUP variable itself (lib.sh) so
that each backup run gets its own directory under /mnt/NCBACKUP/. This
eliminates the rotation step that destroyed the file and also fixes a
minor race condition where $(date) was called twice for mkdir and
rsync, potentially creating two different timestamp directories.

Additionally:
- Add cleanup of backups older than one year
- Fix legacy migration block to use correct target paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apps are disabled during update but not re-enabled

1 participant