Skip to content

Docs Self-hosting

Backups

What to back up on a Snapsbrew instance, and how to back up and restore a Docker install.

Snapsbrew keeps its data in four places. Back up all four.

What Where Why it is important
The database MySQL (the mysql volume in Docker) Accounts, templates, template versions, snaps, forms, tokens and the usage log.
The storage folder storage/ (the storage volume in Docker) Rendered images and uploads on the public disk, editor assets, uploaded spreadsheets, the Passport keys and the logs.
The .env file The root of the app All settings, and APP_KEY.
The bucket S3, Spaces or R2 Rendered images and uploads, if MEDIA_DISK is a bucket.

Redis holds the cache, the sessions and the queued jobs. If you lose Redis, users must sign in again and the queued jobs are lost. A backup of Redis is not necessary for most instances.

Keep APP_KEY safe

CAUTION: Keep a copy of APP_KEY with every backup. The app encrypts data with this key.

If APP_KEY changes or is lost:

  • The stored signed-URL keys cannot be decrypted, so the signed URLs stop working.
  • The two-factor secrets of the users cannot be decrypted.
  • The setup token changes. This is important only before the first account exists.

Keep .env out of a public place. It holds APP_KEY and all other secrets.

Keep the Passport keys

The OAuth flow of the MCP server signs tokens with the Passport keys. The keys are storage/oauth-private.key and storage/oauth-public.key, or the values of PASSPORT_PRIVATE_KEY and PASSPORT_PUBLIC_KEY. If you lose the keys, every MCP client that connected with OAuth must connect again.

Back up a Docker install

Docker Compose adds the project name to each volume name. The project name is the name of the folder by default. The examples use the project name snapsbrew, so the volumes are snapsbrew_mysql and snapsbrew_storage.

  1. Dump the database:

    Terminal

    docker compose exec -T mysql sh -c 'exec mysqldump --single-transaction -u root -p"$MYSQL_ROOT_PASSWORD" "$MYSQL_DATABASE"' > snapsbrew.sql
    
  2. Copy the storage volume to an archive:

    Terminal

    docker run --rm -v snapsbrew_storage:/data -v "$PWD":/backup alpine tar czf /backup/storage.tar.gz -C /data .
    
  3. Copy .env to the same safe place as the two files.

The mysqldump with --single-transaction makes a consistent copy while the app runs.

Restore a Docker install

  1. Stop the app containers:

    Terminal

    docker compose stop web horizon scheduler
    
  2. Load the database dump:

    Terminal

    docker compose exec -T mysql sh -c 'exec mysql -u root -p"$MYSQL_ROOT_PASSWORD" "$MYSQL_DATABASE"' < snapsbrew.sql
    
  3. Load the storage archive into the volume:

    Terminal

    docker run --rm -v snapsbrew_storage:/data -v "$PWD":/backup alpine sh -c 'cd /data && tar xzf /backup/storage.tar.gz'
    
  4. Put the saved .env back in the root of the app.

  5. Start the stack:

    Terminal

    docker compose up -d
    

Back up an install without Docker

  • Dump the database with mysqldump --single-transaction.
  • Copy the storage folder.
  • Copy .env.

Test the backup

Restore a backup on a test machine from time to time. Then make sure that you can sign in, open a template and render a snap.

Edit this page on GitHub