Skip to content

[codex] fix backup dump handling#41

Merged
henmohr merged 6 commits into
mainfrom
feat/nextcloud-upgrade-hooks
Jul 4, 2026
Merged

[codex] fix backup dump handling#41
henmohr merged 6 commits into
mainfrom
feat/nextcloud-upgrade-hooks

Conversation

@henmohr

@henmohr henmohr commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Keeps a single PostgreSQL dump at /backups/nextcloud-db.sql.gz during upgrade, writes it atomically, and makes sure maintenance mode is turned off on failure.

Why

This avoids timestamped dump sprawl and reduces the chance of leaving a partial dump or a stuck maintenance state.

Validation

  • bash tests/test-hooks.sh
  • make test-hooks

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be81860e7c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docker-compose.yml Outdated
Comment thread .env.example
Comment on lines +11 to +12
NEXTCLOUD_BACKUP_DIR=/backups
NEXTCLOUD_UPGRADE_MIN_FREE_MB=2048

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pass upgrade hook settings into the container

These new values are only added to .env.example, but the app service environment lists in the compose files never pass NEXTCLOUD_BACKUP_DIR or NEXTCLOUD_UPGRADE_MIN_FREE_MB through to the container. In deployments that edit .env to change the backup path or free-space threshold as documented, the pre-upgrade hook still falls back to /backups and 2048, so the safety check and backup location cannot actually be configured from the sample env file. Add these variables to the app environment in both compose files.

Useful? React with 👍 / 👎.

}

echo "Running post-upgrade Nextcloud commands"
php occ app:list > /backups/app_list.new

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor the configured backup directory after upgrade

When NEXTCLOUD_BACKUP_DIR is customized for the pre-upgrade hook, this post-upgrade hook still writes and reads /backups directly. On setups that mount only the configured backup path, the redirect here fails after occ upgrade but before maintenance:mode --off, leaving the upgraded instance stuck in maintenance; even when /backups exists, the app-list diff compares the wrong files. Use the same backup directory variable here as the pre-upgrade script.

Useful? React with 👍 / 👎.

@henmohr henmohr marked this pull request as draft July 4, 2026 14:31
@henmohr henmohr changed the title Feat/nextcloud upgrade hooks [codex] fix backup dump handling Jul 4, 2026
@henmohr henmohr marked this pull request as ready for review July 4, 2026 15:14
@henmohr henmohr requested review from YvesCesar and vitormattos July 4, 2026 15:14
@henmohr henmohr self-assigned this Jul 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e1777e29d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

rm -f "$backup_tmp_file"
}

trap cleanup EXIT

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep maintenance mode on until post-upgrade

When the pre-upgrade dump succeeds, this EXIT trap still runs cleanup; because maintenance_enabled was set after maintenance:mode --on, the hook immediately turns maintenance mode back off before the Docker entrypoint proceeds to occ upgrade and the post-upgrade hook. In production upgrades with live traffic, requests can then hit the instance while files/schema are being upgraded, so the trap should only disable maintenance on failure or be cleared before a successful exit.

Useful? React with 👍 / 👎.

@henmohr henmohr merged commit 1e1777e into main Jul 4, 2026
2 checks passed
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.

1 participant