Self-hosting
Storage
The storage service (Garage), where its files live on the host, its keys, and getting files out of it.
Hubstruct keeps files in S3-compatible object storage: the originals and renditions of libraries, and the pictures it makes itself, such as album, tag and person mosaics. Self-hosted, that's the storage service: Garage, a small, single-node object store.
Where the files are
Garage keeps two folders on the host, under MEDIA_DIR (./data by default, next to the Compose file):
| Folder | Holds |
|---|---|
${MEDIA_DIR}/storage/meta | Garage's metadata: which objects exist and where their blocks are |
${MEDIA_DIR}/storage/data | The blocks: your files' bytes, split and deduplicated |
Both are needed. The data folder is unreadable without the metadata. And because Garage stores files in its own block format, the data folder holds your media's bytes but not browsable photos.
To keep media on a big disk, set MEDIA_DIR in .env:
MEDIA_DIR=/mnt/media/hubstruct
Put meta on fast storage if you can, since it's small and read constantly. To do so, edit the two volume lines of the storage service in the Compose file.
Its keys
Garage makes its bucket and access key on its first start, from .env:
| Variable | Means |
|---|---|
S3_RPC_SECRET | Garage's internal secret: 64 hex characters |
S3_ACCESS_KEY | The access key: GK and 24 hex characters |
S3_SECRET_KEY | The secret key: 64 hex characters |
S3_BUCKET | The bucket's name: hubstruct by default |
The API and the worker use these to reach storage at http://storage:3900. Storage isn't published on the host: only Hubstruct's services can reach it.
Getting files out
One at a time: open a media's original full size from its page, and save it from your browser.
In bulk, use any S3 client against Garage, from a container on the same network. For example, with the AWS CLI:
docker run --rm -it --network hubstruct_default \
-e AWS_ACCESS_KEY_ID="$S3_ACCESS_KEY" \
-e AWS_SECRET_ACCESS_KEY="$S3_SECRET_KEY" \
-v "$PWD/export:/export" \
amazon/aws-cli --endpoint-url http://storage:3900 --region garage \
s3 sync s3://hubstruct/libraries/<library id>/originals /export
Originals are stored under the media's id, without the file name. The file names are in the database, and in the API's media listing.
Using other S3 storage
Hubstruct speaks plain S3, so it can use other S3-compatible storage, such as MinIO, Cloudflare R2, Backblaze B2 or AWS S3, instead of Garage. Remove the storage service, and set the API's and worker's S3_ENDPOINT, S3_REGION, S3_BUCKET, S3_ACCESS_KEY and S3_SECRET_KEY to your provider's. The bucket must exist, and the key must be able to read, write, list and delete in it.
Backing it up
See Backups.