Backups and restoring
What to back up, how to do it, and how to check a backup actually restores.
What to back up
- The database
Products, orders, customers and settings. Everything that matters.
- The storage bucket
- Product photos and uploads.
- Your .env file
Especially
AUTH_SECRETS_KEY. Without the same key, staff two-factor and saved webhook secrets can't be read.- Your shop file
The
your-shop.jsonyou created the shop with.
You don't need to back up Meilisearch or imgproxy. Search is rebuilt from the database, and imgproxy keeps nothing.
Back up
- 1
Dump the database
A compressed dump you can restore anywhere:
Terminal$ pg_dump -Fc -d "$DATABASE_URL" -f shop-$(date +%F).dump - 2
Copy the bucket
Copy the bucket to somewhere else, with any S3 tool. With the MinIO client, for example:
Terminal$ mc mirror --overwrite shop/shop-media backup/shop-mediaA versioned backup bucket also keeps photos that were deleted or replaced.
- 3
Keep copies somewhere else
Store the dump, the bucket copy,
.envand your shop file away from the server, and keep more than one day's worth.
Restore
- 1
Restore the database
Terminal$ pg_restore --clean --if-exists --no-owner \ --role=shop -d "$DATABASE_URL" shop-2026-10-18.dump - 2
Restore the bucket
Copy the photos back. Use a bucket backup from the same day as the database, so every product's photos are there.
- 3
Start the app and rebuild search
Start the container as usual, then rebuild the search index:
Terminal$ docker exec vexon-commerce npm run search:reindex
Check a backup works
A backup you haven't restored is a guess. Every so often, restore the latest dump into a spare database and check the numbers of products, variants and orders match the live shop. For photos, restore a few files to a spare bucket and open them.