diff --git a/nextcloud/README.md b/nextcloud/README.md index d84c3d2..0c34dbd 100644 --- a/nextcloud/README.md +++ b/nextcloud/README.md @@ -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_OVERWRITEPROTOCOL – default: https; generates https links behind NPM's TLS termination 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_/preview ## 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) /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_/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 - -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_/preview /var/cache/nextcloud/preview - sudo mkdir /data/nextcloud/data/data/appdata_/preview - sudo chown -R 33:33 /var/cache/nextcloud/preview /data/nextcloud/data/data/appdata_/preview - ``` -4. Set `NEXTCLOUD_PREVIEW_DIR=/var/www/html/data/appdata_/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`. +```bash +rsync -a --exclude '/data/appdata_*' /data/nextcloud/data/ /backup/nextcloud/data/ +``` ## Network Notes diff --git a/nextcloud/compose.yaml b/nextcloud/compose.yaml index 30b86ec..5253dc4 100644 --- a/nextcloud/compose.yaml +++ b/nextcloud/compose.yaml @@ -27,7 +27,6 @@ services: restart: ${NEXTCLOUD_RESTART:-unless-stopped} volumes: - ${VOL_PATH:-/data}/nextcloud/data:/var/www/html - - ${VOL_CACHE:-/var/cache}/nextcloud/preview:${NEXTCLOUD_PREVIEW_DIR:-/mnt/nextcloud-preview} environment: - MYSQL_PASSWORD=${NEXTCLOUD_DB_PASSWORD:-ChangeThisPassword} - MYSQL_DATABASE=${NEXTCLOUD_DB:-nextcloud} @@ -53,7 +52,6 @@ services: restart: ${NEXTCLOUD_RESTART:-unless-stopped} volumes: - ${VOL_PATH:-/data}/nextcloud/data:/var/www/html - - ${VOL_CACHE:-/var/cache}/nextcloud/preview:${NEXTCLOUD_PREVIEW_DIR:-/mnt/nextcloud-preview} networks: - internal depends_on: diff --git a/nextcloud/sample.env b/nextcloud/sample.env index 0887490..583af8b 100644 --- a/nextcloud/sample.env +++ b/nextcloud/sample.env @@ -1,6 +1,6 @@ # Compose VOL_PATH=/data -# Regenerable data (previews, redis) — exclude from backups +# Regenerable data (redis) — exclude from backups VOL_CACHE=/var/cache NEXTCLOUD_IMAGE=nextcloud:35 NEXTCLOUD_RESTART=unless-stopped @@ -24,6 +24,3 @@ NEXTCLOUD_DOMAIN=cloud.example.com # Docker's default bridge range — covers NPM on the proxy network NEXTCLOUD_TRUSTED_PROXIES=172.16.0.0/12 NEXTCLOUD_OVERWRITEPROTOCOL=https -# Leave as-is for a fresh install. After install, set to -# /var/www/html/data/appdata_/preview (see README → Volume Notes) -NEXTCLOUD_PREVIEW_DIR=/mnt/nextcloud-preview