nextcloud: drop preview cache volume, suggest appdata backup exclude

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
code
2026-10-01 19:27:13 +00:00
co-authored by Claude Opus 5.5
parent 930e95a52a
commit 6e00ae95bb
3 changed files with 6 additions and 25 deletions
+5 -19
View File
@@ -36,7 +36,6 @@ To test without NPM, open http://HOST_IP:8084. Set `NEXTCLOUD_DOMAIN=HOST_IP` an
NEXTCLOUD_PORT – default: 8084; host port for testing without NPM (NPM connects to nextcloud:80) NEXTCLOUD_PORT – default: 8084; host port for testing without NPM (NPM connects to nextcloud:80)
NEXTCLOUD_OVERWRITEPROTOCOL – default: https; generates https links behind NPM's TLS termination NEXTCLOUD_OVERWRITEPROTOCOL – default: https; generates https links behind NPM's TLS termination
VOL_CACHE – default: /var/cache; base path for regenerable data (exclude from backups) VOL_CACHE – default: /var/cache; base path for regenerable data (exclude from backups)
NEXTCLOUD_PREVIEW_DIR – default: /mnt/nextcloud-preview (unused placeholder); after install, set to /var/www/html/data/appdata_<instanceid>/preview
## Volume Notes ## Volume Notes
@@ -44,26 +43,13 @@ To test without NPM, open http://HOST_IP:8084. Set `NEXTCLOUD_DOMAIN=HOST_IP` an
/data – host path /var/cache/nextcloud/redis (Redis cache, file locks and sessions; safe to lose, users are logged out) /data – host path /var/cache/nextcloud/redis (Redis cache, file locks and sessions; safe to lose, users are logged out)
/var/www/html – host path /data/nextcloud/data (Nextcloud app, config and user files; shared by nextcloud and nextcloud-cron) /var/www/html – host path /data/nextcloud/data (Nextcloud app, config and user files; shared by nextcloud and nextcloud-cron)
/var/www/html/data/appdata_<instanceid>/preview – host path /var/cache/nextcloud/preview (generated thumbnails; only once NEXTCLOUD_PREVIEW_DIR is set) Back up `/data/nextcloud/data` and `/data/nextcloud/db` together. Leave out `/var/cache`, because Redis rebuilds its cache.
Back up `/data/nextcloud/data` and `/data/nextcloud/db` together. Leave out `/var/cache`: previews are regenerated on demand, and Redis rebuilds its cache. To keep backups small, exclude `data/data/appdata_*` (thumbnail previews and generated JS/CSS, often several GB). Nextcloud regenerates these on demand. It also holds a few things that aren't regenerated, such as theming uploads and the federation signing keys. If you rely on those, exclude only `data/data/appdata_*/preview`.
### Moving previews to VOL_CACHE ```bash
rsync -a --exclude '/data/appdata_*' /data/nextcloud/data/ /backup/nextcloud/data/
Previews are usually the largest regenerable data, often several GB. They live in a folder named after the instance ID, which Nextcloud only creates during install. That's why the preview mount points at a placeholder until you set `NEXTCLOUD_PREVIEW_DIR`. ```
1. Get the instance ID: `docker compose exec -u www-data nextcloud php occ config:system:get instanceid`
2. Stop the stack: `docker compose down`
3. Move existing previews and give them to www-data (UID 33):
```bash
sudo mkdir -p /var/cache/nextcloud
sudo mv /data/nextcloud/data/data/appdata_<instanceid>/preview /var/cache/nextcloud/preview
sudo mkdir /data/nextcloud/data/data/appdata_<instanceid>/preview
sudo chown -R 33:33 /var/cache/nextcloud/preview /data/nextcloud/data/data/appdata_<instanceid>/preview
```
4. Set `NEXTCLOUD_PREVIEW_DIR=/var/www/html/data/appdata_<instanceid>/preview` and start the stack
If you lose `/var/cache`, don't start with an empty folder: Nextcloud's file cache still lists the old previews. Recreate the folder (owned by 33:33), start the stack, then run `docker compose exec -u www-data nextcloud php occ files:scan-app-data preview`.
## Network Notes ## Network Notes
-2
View File
@@ -27,7 +27,6 @@ services:
restart: ${NEXTCLOUD_RESTART:-unless-stopped} restart: ${NEXTCLOUD_RESTART:-unless-stopped}
volumes: volumes:
- ${VOL_PATH:-/data}/nextcloud/data:/var/www/html - ${VOL_PATH:-/data}/nextcloud/data:/var/www/html
- ${VOL_CACHE:-/var/cache}/nextcloud/preview:${NEXTCLOUD_PREVIEW_DIR:-/mnt/nextcloud-preview}
environment: environment:
- MYSQL_PASSWORD=${NEXTCLOUD_DB_PASSWORD:-ChangeThisPassword} - MYSQL_PASSWORD=${NEXTCLOUD_DB_PASSWORD:-ChangeThisPassword}
- MYSQL_DATABASE=${NEXTCLOUD_DB:-nextcloud} - MYSQL_DATABASE=${NEXTCLOUD_DB:-nextcloud}
@@ -53,7 +52,6 @@ services:
restart: ${NEXTCLOUD_RESTART:-unless-stopped} restart: ${NEXTCLOUD_RESTART:-unless-stopped}
volumes: volumes:
- ${VOL_PATH:-/data}/nextcloud/data:/var/www/html - ${VOL_PATH:-/data}/nextcloud/data:/var/www/html
- ${VOL_CACHE:-/var/cache}/nextcloud/preview:${NEXTCLOUD_PREVIEW_DIR:-/mnt/nextcloud-preview}
networks: networks:
- internal - internal
depends_on: depends_on:
+1 -4
View File
@@ -1,6 +1,6 @@
# Compose # Compose
VOL_PATH=/data VOL_PATH=/data
# Regenerable data (previews, redis) — exclude from backups # Regenerable data (redis) — exclude from backups
VOL_CACHE=/var/cache VOL_CACHE=/var/cache
NEXTCLOUD_IMAGE=nextcloud:35 NEXTCLOUD_IMAGE=nextcloud:35
NEXTCLOUD_RESTART=unless-stopped NEXTCLOUD_RESTART=unless-stopped
@@ -24,6 +24,3 @@ NEXTCLOUD_DOMAIN=cloud.example.com
# Docker's default bridge range — covers NPM on the proxy network # Docker's default bridge range — covers NPM on the proxy network
NEXTCLOUD_TRUSTED_PROXIES=172.16.0.0/12 NEXTCLOUD_TRUSTED_PROXIES=172.16.0.0/12
NEXTCLOUD_OVERWRITEPROTOCOL=https NEXTCLOUD_OVERWRITEPROTOCOL=https
# Leave as-is for a fresh install. After install, set to
# /var/www/html/data/appdata_<instanceid>/preview (see README → Volume Notes)
NEXTCLOUD_PREVIEW_DIR=/mnt/nextcloud-preview