refractor code,

This commit is contained in:
root
2026-05-21 12:35:49 -04:00
parent e74681e810
commit f009ca10c6
158 changed files with 215801 additions and 5884 deletions
+65
View File
@@ -103,6 +103,7 @@ The test container runs:
- `npm run db:generate`
- `npm run type-check`
- `npm run build`
- `npm run test:api:integration`
### Production
@@ -240,6 +241,70 @@ npm run docker:prod:logs
npm run docker:prod:logs:api
```
#### Backup production data
Create a timestamped backup directory under `./backups`:
```bash
npm run docker:prod:backup
```
Or choose a different parent directory:
```bash
bash scripts/docker-prod-backup.sh /srv/rentaldrivego-backups
```
Each backup contains:
- `postgres.dump` — logical PostgreSQL backup in custom format
- `api-uploads.tar.gz` — uploaded files from `/var/lib/rentaldrivego/storage`
- `traefik-letsencrypt.tar.gz` — Traefik ACME certificate state, when available
- `volumes/*.tar.gz` — raw Docker volume archives for the default production volumes
- `manifest.txt` — basic metadata
By default, the backup also archives these named production volumes when they exist:
- `${DOCKER_PROD_PROJECT_NAME:-rentaldrivego-prod}_api_uploads`
- `${DOCKER_PROD_PROJECT_NAME:-rentaldrivego-prod}_pgmanage_prod_data`
- `${DOCKER_PROD_PROJECT_NAME:-rentaldrivego-prod}_postgres_prod_data`
- `${DOCKER_PROD_PROJECT_NAME:-rentaldrivego-prod}_redis_prod_data`
To include extra named volumes from the same server, pass them as additional arguments:
```bash
bash scripts/docker-prod-backup.sh /srv/rentaldrivego-backups \
gitlab-l3gq_gitlab-config \
gitlab-l3gq_gitlab-data \
gitlab-l3gq_gitlab-logs \
pgmanage_data \
traefik-gcjk_portainer_data \
traefik-gcjk_traefik-letsencrypt
```
You can also provide extra volume names through `DOCKER_EXTRA_BACKUP_VOLUMES`.
#### Restore production data
Restore is destructive: it overwrites the production database, uploaded files, and, when present in the backup, Traefik ACME state.
```bash
bash scripts/docker-prod-restore.sh ./backups/rentaldrivego-prod-YYYYMMDDTHHMMSSZ --yes
```
The restore script:
1. Stops public app services
2. Restores the PostgreSQL dump
3. Replaces uploaded files
4. Restores Traefik ACME state if the archive exists
5. Restores raw volume archives from `volumes/` except the ones already covered by the database and upload restore steps
6. Starts Traefik and the production stack again
If the backup contains raw archives for volumes used by other stacks such as GitLab or Portainer, stop those containers before running restore. The script will refuse to overwrite a volume that is currently attached to a running container.
Before running restore on a live server, take a fresh backup first.
#### Stop the stack
```bash