Update documentation
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
# TrueNAS Piwigo App → Docker Migration
|
||||
|
||||
This repository contains scripts to backup a Piwigo instance running as a TrueNAS App (Kubernetes/k3s) and restore it to a Docker container.
|
||||
This repository contains scripts to backup a Piwigo instance running as a TrueNAS App and restore it to a Docker container.
|
||||
|
||||
**Updated for TrueNAS 27+ (Electric Eel)** - No kubectl/k3s required. Works with direct dataset access.
|
||||
|
||||
## Scripts
|
||||
|
||||
@@ -13,12 +15,13 @@ This repository contains scripts to backup a Piwigo instance running as a TrueNA
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### On TrueNAS Host
|
||||
- TrueNAS with Piwigo app installed
|
||||
- SSH access to TrueNAS (or use TrueNAS Shell)
|
||||
- `k3s kubectl` available (usually at `/usr/local/bin/k3s kubectl`)
|
||||
- `mariadb-dump` or `mysqldump` installed
|
||||
### On TrueNAS Host (27+)
|
||||
- TrueNAS 27+ with Piwigo app installed
|
||||
- SSH access to TrueNAS (or TrueNAS Shell)
|
||||
- `docker` available (for database dump via container)
|
||||
- **OR** `mariadb-dump`/`mysqldump` installed on host
|
||||
- Write access to backup destination dataset
|
||||
- Read access to Piwigo app datasets (configured in app settings)
|
||||
|
||||
### On Docker Host
|
||||
- Docker Engine installed
|
||||
@@ -38,26 +41,30 @@ ssh root@truenas.local
|
||||
# Copy the backup script to TrueNAS
|
||||
scp backup-piwigo-truenas.sh root@truenas.local:/tmp/
|
||||
|
||||
# Run the backup script
|
||||
# You can set environment variables to customize behavior
|
||||
# Run the backup script with your dataset paths
|
||||
APP_NAMESPACE=piwigo \
|
||||
BACKUP_DEST=/mnt/tank/backups/piwigo \
|
||||
PIWIGO_UPLOADS_PATH=/mnt/.ix-apps/app_mounts/piwigo/config/upload \
|
||||
PIWIGO_CONFIG_PATH=/mnt/.ix-apps/app_configs/piwigo/versions/1.4.17 \
|
||||
PIWIGO_GALLERIES_PATH=/mnt/.ix-apps/app_mounts/piwigo/config/galleries \
|
||||
DB_PASS=your_database_password \
|
||||
/tmp/backup-piwigo-truenas.sh
|
||||
```
|
||||
|
||||
**Environment Variables for Backup:**
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `APP_NAMESPACE` | `piwigo` | Kubernetes namespace of Piwigo app |
|
||||
| `BACKUP_DEST` | `/mnt/tank/backups/piwigo` | Destination dataset path |
|
||||
| `DB_HOST` | auto-detect | Database host |
|
||||
| `DB_HOST` | `localhost` | Database host (if using host tools) |
|
||||
| `DB_PORT` | `3306` | Database port |
|
||||
| `DB_NAME` | `piwigo` | Database name |
|
||||
| `DB_USER` | `piwigo` | Database user |
|
||||
| `DB_PASS` | auto-detect | Database password |
|
||||
| `PVC_UPLOADS` | auto-detect | Uploads PVC name |
|
||||
| `PVC_CONFIG` | auto-detect | Config PVC name |
|
||||
| `PVC_GALLERIES` | auto-detect | Galleries PVC name |
|
||||
| `DB_PASS` | **required** | Database password (or auto-detected) |
|
||||
| `DB_CONTAINER` | auto-detect | Database container name (e.g., `ep-piwigo-docker-piwigo-db-1`) |
|
||||
| `DB_PASSWORD_ENV` | auto-detect | Password env var in container (`MYSQL_PASSWORD`, `MYSQL_ROOT_PASSWORD`, `MARIADB_PASSWORD`, etc.) |
|
||||
| `PIWIGO_UPLOADS_PATH` | **required** | Host path to uploads dataset |
|
||||
| `PIWIGO_CONFIG_PATH` | **required** | Host path to config dataset |
|
||||
| `PIWIGO_GALLERIES_PATH` | optional | Host path to galleries dataset |
|
||||
| `RETENTION_COUNT` | `7` | Number of backups to keep |
|
||||
| `COMPRESSION_LEVEL` | `6` | gzip compression (1-9) |
|
||||
|
||||
@@ -128,18 +135,20 @@ Open your browser to `http://<docker-host>:8080`
|
||||
|
||||
## Detailed Workflow
|
||||
|
||||
### Backup Process (TrueNAS)
|
||||
### Backup Process (TrueNAS 27+)
|
||||
|
||||
The backup script performs these steps:
|
||||
|
||||
1. **Detection**: Finds Kubernetes namespace, database credentials, and PVCs
|
||||
2. **Manifests**: Exports all K8s resources (deployments, services, PVCs, secrets, etc.)
|
||||
3. **Database**: Dumps MariaDB/MySQL database with `mariadb-dump`/`mysqldump`
|
||||
4. **Files**: Creates temporary pods to copy data from PVCs:
|
||||
1. **Validate Paths**: Checks provided dataset paths or auto-detects common locations
|
||||
2. **Validate Database**: Tests connection via host tools OR docker exec
|
||||
3. **Database**: Dumps MariaDB/MySQL database using:
|
||||
- Host tools (`mariadb-dump`/`mysqldump`) if available
|
||||
- `docker exec` into database container if host tools not available
|
||||
4. **Files**: Copies data directly from host filesystem paths using `rsync`:
|
||||
- `uploads/` → Piwigo upload directory
|
||||
- `config/` → Piwigo local/config directory
|
||||
- `galleries/` → Piwigo galleries (if separate PVC)
|
||||
5. **Archive**: Creates compressed `.tar.gz` with checksum
|
||||
- `galleries/` → Piwigo galleries (if separate path)
|
||||
5. **Archive**: Creates compressed `.tar.gz` with SHA256 checksum
|
||||
6. **Cleanup**: Removes old backups per retention policy
|
||||
7. **Info**: Generates `RESTORE_INFO_<timestamp>.txt` with restore instructions
|
||||
|
||||
@@ -178,10 +187,8 @@ piwigo/
|
||||
|
||||
### Migration with Same Database Credentials
|
||||
|
||||
If you want to keep the same database passwords:
|
||||
|
||||
```bash
|
||||
# On TrueNAS, note the DB_PASS from backup output or secret
|
||||
# On TrueNAS, set DB_PASS
|
||||
# On Docker host, use same passwords:
|
||||
DB_ROOT_PASS=same_as_truenas \
|
||||
DB_PASS=same_as_truenas \
|
||||
@@ -211,27 +218,80 @@ PIWIGO_DATA_DIR=/data/piwigo \
|
||||
|
||||
---
|
||||
|
||||
## Finding TrueNAS 27+ Dataset Paths
|
||||
|
||||
In TrueNAS 27+, app data is stored in `.ix-apps` datasets. Find your paths:
|
||||
|
||||
```bash
|
||||
# List app mounts
|
||||
ls /mnt/.ix-apps/app_mounts/
|
||||
|
||||
# List app configs
|
||||
ls /mnt/.ix-apps/app_configs/
|
||||
|
||||
# For Piwigo, typical paths are:
|
||||
# /mnt/.ix-apps/app_mounts/piwigo/config/upload
|
||||
# /mnt/.ix-apps/app_configs/piwigo/versions/X.X.X
|
||||
# /mnt/.ix-apps/app_mounts/piwigo/config/galleries
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Database Credentials
|
||||
|
||||
### Option 1: Set DB_PASS directly (recommended)
|
||||
```bash
|
||||
DB_PASS=your_password ./backup-piwigo-truenas.sh
|
||||
```
|
||||
|
||||
### Option 2: Auto-detect from container
|
||||
The script checks these env vars in the database container:
|
||||
- `MYSQL_PASSWORD`
|
||||
- `MYSQL_ROOT_PASSWORD`
|
||||
- `MARIADB_PASSWORD`
|
||||
- `MARIADB_ROOT_PASSWORD`
|
||||
- Docker secret files (`*_FILE` variants)
|
||||
|
||||
### Option 3: Specify container and env var
|
||||
```bash
|
||||
DB_CONTAINER=ep-piwigo-docker-piwigo-db-1 \
|
||||
DB_PASSWORD_ENV=MYSQL_ROOT_PASSWORD \
|
||||
./backup-piwigo-truenas.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Backup Fails: "Database dump failed"
|
||||
|
||||
1. Check database credentials are correct
|
||||
2. Ensure `mariadb-dump` or `mysqldump` is installed on TrueNAS
|
||||
2. Ensure `mariadb-dump`/`mysqldump` is installed on TrueNAS **OR** docker is available
|
||||
3. Verify database is accessible from TrueNAS host:
|
||||
```bash
|
||||
mariadb -h <DB_HOST> -u <DB_USER> -p<DB_PASS> <DB_NAME> -e "SELECT 1"
|
||||
# If host tools available
|
||||
mariadb -h localhost -u piwigo -p<DB_PASS> piwigo -e "SELECT 1"
|
||||
|
||||
# If using docker
|
||||
docker exec ep-piwigo-docker-piwigo-db-1 mariadb -u piwigo -p<DB_PASS> -e "SELECT 1"
|
||||
```
|
||||
|
||||
### Backup Fails: "PVC not found"
|
||||
### Backup Fails: "Path does not exist"
|
||||
|
||||
1. Check PVC names in TrueNAS: `k3s kubectl get pvc -n piwigo`
|
||||
2. Set `PVC_UPLOADS`, `PVC_CONFIG`, `PVC_GALLERIES` explicitly
|
||||
1. Verify dataset paths in TrueNAS app configuration
|
||||
2. Check `/mnt/.ix-apps/app_mounts/` and `/mnt/.ix-apps/app_configs/`
|
||||
3. Set `PIWIGO_UPLOADS_PATH`, `PIWIGO_CONFIG_PATH`, `PIWIGO_GALLERIES_PATH` explicitly
|
||||
|
||||
### Backup Fails: "Cannot connect to database in container"
|
||||
|
||||
1. Check container name: `docker ps | grep -i mariadb`
|
||||
2. Verify password env var name: `docker inspect <container> | grep -i password`
|
||||
3. Try setting `DB_PASSWORD_ENV=MYSQL_ROOT_PASSWORD` (common for root password)
|
||||
|
||||
### Restore Fails: "Database not ready"
|
||||
|
||||
1. Check database container logs: `docker-compose logs db`
|
||||
2. Ensure `DB_ROOT_PASS` in `.env` matches what you passed to restore script
|
||||
3. Increase startup wait time in script if needed
|
||||
|
||||
### Piwigo Shows "Database Connection Failed"
|
||||
|
||||
@@ -242,14 +302,12 @@ PIWIGO_DATA_DIR=/data/piwigo \
|
||||
### Permission Errors on Files
|
||||
|
||||
```bash
|
||||
# Fix permissions manually
|
||||
docker run --rm -v /opt/piwigo/piwigo-data:/data alpine:latest \
|
||||
sh -c "chown -R 33:33 /data && chmod -R 755 /data"
|
||||
```
|
||||
|
||||
### Large Backup Times Out
|
||||
|
||||
For very large galleries, increase Docker Compose healthcheck timeouts or run restore in steps:
|
||||
```bash
|
||||
# Restore DB first
|
||||
SKIP_FILES=true ./restore-piwigo-docker.sh backup.tar.gz
|
||||
@@ -322,7 +380,7 @@ If you encounter issues:
|
||||
1. Check the log output from both scripts
|
||||
2. Verify all prerequisites are met
|
||||
3. Ensure network connectivity between containers
|
||||
4. Check TrueNAS app logs: `k3s kubectl logs -n piwigo -l app=piwigo`
|
||||
4. Check TrueNAS app logs in TrueNAS UI
|
||||
5. Check Docker logs: `docker-compose logs piwigo`
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user