Continuous synchronization of Nextcloud data with advanced error handling and retry functionality
1.6K
A security-optimized Docker container for automated Nextcloud synchronization with enterprise-grade reliability and modern package support. Built on Debian Trixie for enhanced compatibility and latest features.
nextcloud-desktop-cmd, ca-certificates)docker run -d \
--name nextcloud-sync \
-e NEXTCLOUD_USER="your_username" \
-e NEXTCLOUD_PASS="your_password" \
-e NEXTCLOUD_URL="your-nextcloud.example.com" \
-v /path/to/local/data:/media/nextclouddata \
dkuhnke/nextcloud-sync
version: '3.8'
services:
nextcloud-sync:
image: dkuhnke/nextcloud-sync
container_name: nextcloud-sync
restart: unless-stopped
environment:
- NEXTCLOUD_USER=your_username
- NEXTCLOUD_PASS=your_password
- NEXTCLOUD_URL=your-nextcloud.example.com
- NEXTCLOUD_SLEEP=300
- NEXTCLOUD_SYNC_RETRIES=4
- NEXTCLOUD_RUN_ONCE=false
volumes:
- ./data:/media/nextclouddata
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
| Variable | Description | Example |
|---|---|---|
NEXTCLOUD_USER | Nextcloud username | john.doe |
NEXTCLOUD_PASS | Nextcloud app password | your-secure-password |
NEXTCLOUD_URL | Nextcloud server URL | cloud.example.com |
| Variable | Description | Default | Example |
|---|---|---|---|
NEXTCLOUD_SLEEP | Sleep interval between syncs (seconds) | 300 | 600 |
NEXTCLOUD_SYNC_RETRIES | Number of retry attempts on failure | 4 | 10 |
NEXTCLOUD_RUN_ONCE | Run sync once and exit | false | true |
The container expects your local data directory to be mounted at /media/nextclouddata:
-v /your/local/path:/media/nextclouddata
This directory will be synchronized with your Nextcloud instance.
For a single synchronization without continuous operation:
docker run --rm \
-e NEXTCLOUD_USER="your_username" \
-e NEXTCLOUD_PASS="your_password" \
-e NEXTCLOUD_URL="your-nextcloud.example.com" \
-e NEXTCLOUD_RUN_ONCE=true \
-v /path/to/local/data:/media/nextclouddata \
dkuhnke/nextcloud-sync
Set a custom sync interval (e.g., every 10 minutes):
docker run -d \
-e NEXTCLOUD_SLEEP=600 \
# ... other environment variables
dkuhnke/nextcloud-sync
For unstable connections, increase retry attempts:
docker run -d \
-e NEXTCLOUD_SYNC_RETRIES=10 \
# ... other environment variables
dkuhnke/nextcloud-sync
The container runs as unprivileged nextcloud user (UID/GID 1001):
# Container automatically runs as nextcloud user
USER nextcloud
Instead of using your main password, create an app-specific password in Nextcloud:
NEXTCLOUD_PASSStore sensitive information securely:
# Using environment file
docker run --env-file .env dkuhnke/nextcloud-sync
For production environments, use Docker Secrets:
version: '3.8'
secrets:
nextcloud_user:
external: true
nextcloud_pass:
external: true
services:
nextcloud-sync:
image: dkuhnke/nextcloud-sync
secrets:
- nextcloud_user
- nextcloud_pass
environment:
- NEXTCLOUD_URL=cloud.example.com
# Secrets will be available in /run/secrets/
The migration to Debian Trixie brings significant compatibility and feature improvements:
| Aspect | Debian Bookworm | Debian Trixie | Improvement |
|---|---|---|---|
| Nextcloud Client | 3.7.3 | 3.16.4 | Latest features & fixes |
| Package Currency | Stable | Testing/Latest | More recent security patches |
| Compatibility | Legacy support | Modern features | Enhanced functionality |
| Package Selection | Standard | Curated minimal | Reduced installation footprint |
nextcloud user (UID 1001)nextcloud-desktop-cmd and ca-certificates installed# Follow logs in real-time
docker logs -f nextcloud-sync
# View last 100 lines
docker logs --tail 100 nextcloud-sync
Der Container bietet strukturierte Protokollierung mit Zeitstempeln:
[2025-08-25 10:30:00] š Starting Nextcloud Sync Container v2.7
[2025-08-25 10:30:00] User: john.doe
[2025-08-25 10:30:00] URL: cloud.example.com
[2025-08-25 10:30:00] Retries: 4
[2025-08-25 10:30:00] Run Once: false
[2025-08-25 10:30:01] ā
Environment validation successful
[2025-08-25 10:30:01] ā
Directory permissions validated
[2025-08-25 10:30:02] š Starting continuous sync mode (interval: 300s)
[2025-08-25 10:30:02] š Sync attempt 1/5
[2025-08-25 10:30:15] ā
Synchronization completed successfully
[2025-08-25 10:30:15] ā³ Waiting 300 seconds until next sync...
ā All 5 sync attempts failed
NEXTCLOUD_URL is correct and accessibleā Directory is not writable: /media/nextclouddata
/media/nextclouddataā Missing required environment variables: NEXTCLOUD_USER NEXTCLOUD_PASS
View container logs for troubleshooting:
docker logs -f nextcloud-sync 2>&1 | grep -E "(ERROR|WARN|ā)"
For large datasets, sync intervals can be adjusted:
# Longer intervals for large repositories
-e NEXTCLOUD_SLEEP=1800 # 30 minutes
# Clone the repository
git clone https://github.com/dkuhnke/nextcloud-sync.git
cd nextcloud-sync
# Build the Docker image
docker build -t nextcloud-sync .
# Run your custom build
docker run -d nextcloud-sync
nextcloud-desktop-cmd + ca-certificates onlyContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSEā file for details.
If you encounter any issues or have questions:
Author: dkuhnke
Version: 2.7
Last Updated: August 2025
Base: Debian Trixie - Latest features with enterprise reliability
GitHub: nextcloud-syncā
Content type
Image
Digest
sha256:05a80c98bā¦
Size
141 MB
Last updated
about 1 year ago
docker pull dkuhnke/nextcloud-sync