# Backups

A complete restore needs three things:

1. The SQLite file in `data/` (default `data/picture.db`, plus `-wal`/`-shm` if present)
2. The `images/` tree (`originals`, `optimized`, `thumbs`, `display`)
3. `.env` (secrets and paths) and any local notes about `ADMIN_PATH` / `SITE_URL`

The application code can be reinstalled from this repository. Photograph files cannot.

## Create a backup

From the project root, with the same environment the site uses:

```bash
python -m scripts.backup
```

This writes `backups/<timestamp>/` containing the database, `images/`, and a copy of `.env` named `env.backup`.

You can also copy those paths with your host’s file manager or `rsync`.

Suggested rhythm: daily database + `.env`, daily or weekly `images/` (images change only when you upload or replace photographs).

## Restore

1. Stop the application process.
2. Restore `data/picture.db` (and WAL files if you copied them).
3. Restore the `images/` directories in place.
4. Restore `.env`.
5. Start the application again.

If you restore onto a new machine, keep `SITE_URL` accurate and rebuild `static/dist` with `npm run build` if that folder is missing.

## PostgreSQL

If you later switch `DATABASE_URL`, dump and restore with `pg_dump` / `pg_restore` instead of copying `data/picture.db`. Keep backing up `images/` and `.env` the same way.
