Appearance
How to restore a Nextcloud PostgreSQL database
Nextcloud on aux uses Postgres inside the compose stack (nextcloud-db-1), data bind-mounted at ~/nextcloud/db/. Do not confuse this with host postgresql@16-main unless you have knowingly moved the DB.
Prerequisites
- Maintenance window (users locked out or in read-only)
- A known-good dump or restic snapshot
- Disk space for a second copy of
~/nextcloud/db
Steps (logical dump)
- Stop the app (keep DB up for dump/restore as needed):bash
cd ~/nextcloud docker compose stop app - Take a safety copy of current DB files (if disk allows):bash
cp -a ~/nextcloud/db ~/nextcloud/db.bak-$(date -u +%Y%m%dT%H%M%SZ) - Restore from SQL dump (example):bash
# dump was created with: # docker exec -t nextcloud-db-1 pg_dump -U nextcloud nextcloud > nextcloud.sql cat /path/to/nextcloud.sql | docker exec -i nextcloud-db-1 psql -U nextcloud nextcloud - Start app and watch logs:bash
docker compose start app docker logs nextcloud-app-1 --tail 50 -f
Steps (restic file-level)
- Restore
~/nextcloud/dband~/nextcloud/configfrom snapshot to a temp path. - Stop stack:
docker compose down. - Replace directories carefully; fix ownership if required by the postgres image user.
docker compose up -dand runpg_isready.
Verify
bash
docker exec nextcloud-db-1 pg_isready -U nextcloud
curl -sI https://cloud.cadenceworks.tech | head -5Log in as a known user and open a recent file.