Self-hosting
Backups
What to back up, how to dump the database and copy storage safely, how to restore, and a script to run nightly.
Your tags, people, albums, corrections and settings live in the database. libraries' media lives in storage. Back up both. The models can always be downloaded again.
What to back up
| What | Where | Why |
|---|---|---|
| The database | The pgdata18 volume | Everything about your media, every library's settings, your accounts |
| Storage | ${MEDIA_DIR}/storage | libraries' originals and renditions |
.env | Next to the Compose file | The database password and storage keys |
| The Compose file | compose.yml | Any changes you've made to it |
You don't need to back up the models' volume (model_cache): they're downloaded again on demand.
The database
Dump it with pg_dump, from inside its container, in PostgreSQL's custom format:
mkdir -p backups
docker compose exec -T postgres \
pg_dump -U tagging -d mediadb -Fc > backups/hubstruct-$(date +%F).dump
This is safe to run while Hubstruct is running: the dump is a consistent snapshot. Use your own POSTGRES_USER and POSTGRES_DB if you changed them.
Check a dump is readable:
docker compose exec -T postgres pg_restore --list < backups/hubstruct-2026-11-02.dump | head
Storage
Garage's two folders must be copied together, and while nothing is writing, so the metadata and the blocks agree. Stop the storage service for the copy:
docker compose stop storage
rsync -a --delete data/storage/ /mnt/backup/hubstruct-storage/
docker compose start storage
While storage is stopped, pages show placeholders instead of pictures, and uploads wait. For a large library, take a filesystem snapshot (ZFS, Btrfs, LVM) of MEDIA_DIR instead, which takes seconds, and copy from the snapshot.
A nightly script
#!/bin/sh
# Hubstruct: the database, then storage, kept for 14 days.
set -eu
cd /opt/hubstruct
mkdir -p backups
docker compose exec -T postgres \
pg_dump -U tagging -d mediadb -Fc > "backups/hubstruct-$(date +%F).dump"
docker compose stop storage
rsync -a --delete data/storage/ /mnt/backup/hubstruct-storage/
docker compose start storage
find backups -name 'hubstruct-*.dump' -mtime +14 -delete
Run it from cron at a quiet hour:
0 3 * * * /opt/hubstruct/backup.sh >> /var/log/hubstruct-backup.log 2>&1
Then copy backups/ and the storage copy somewhere off the machine.
Restoring
To restore the database from a dump, stop what uses it, recreate the database, and load the dump:
docker compose stop console api worker
docker compose exec -T postgres dropdb -U tagging mediadb
docker compose exec -T postgres createdb -U tagging mediadb
docker compose exec -T postgres pg_restore -U tagging -d mediadb --no-owner < backups/hubstruct-2026-11-02.dump
docker compose up -d
To restore storage, stop the storage service, copy both folders back into MEDIA_DIR/storage, and start it again.
Before every update
Updates can change the database, and the migrator applies those changes on start. Take a fresh dump before every update; see Updating.