Docs/ Databases/ Backups & Restore

Backups & Restore

Protect your data with automated backups. sh0 supports local, S3, and Cloudflare R2 storage destinations with configurable retention policies and one-click restore.

Manual Backups

You can trigger a backup at any time from the database detail page. Manual backups use the same engine-specific dump tools as scheduled backups.

  1. Navigate to your database within the stack.
  2. Click the Backups tab.
  3. Click Backup Now.
  4. Select a storage destination (or use the default).
  5. The backup runs in the background -- you can continue working.
Database backups tab -- showing the Backup Now button and storage destination selector

sh0 uses the native dump utility for each engine to ensure consistent backups:

EngineBackup ToolFormat
PostgreSQLpg_dumpCustom format (.dump) or SQL
MySQL / MariaDBmysqldumpSQL (.sql.gz)
MongoDBmongodumpBSON archive (.archive)
RedisRDB snapshotRDB file (.rdb)
Tip
Manual backups are useful before performing risky operations like version upgrades, schema migrations, or bulk data changes.

Scheduled Backups

Set up automated backups that run on a schedule. sh0 uses cron expressions for maximum flexibility.

  1. Open the database Backups tab.
  2. Click Configure Schedule.
  3. Enter a cron expression or select a preset (daily, every 6 hours, weekly).
  4. Choose the storage destination.
  5. Set a retention policy.
  6. Click Save.
Scheduled backup configuration -- cron expression input, preset buttons, and storage destination dropdown

Cron Expressions

Backup schedules use standard 5-field cron syntax. Here are common patterns:

Common Cron Patterns
# Every day at 2:00 AM
0 2 * * *

# Every 6 hours
0 */6 * * *

# Every Sunday at midnight
0 0 * * 0

# Every hour
0 * * * *

# Monday to Friday at 3:30 AM
30 3 * * 1-5

Storage Destinations

Backups can be stored locally on the server or uploaded to cloud object storage. Using remote storage is strongly recommended for disaster recovery.

Local Storage

By default, backups are stored on the server's local filesystem. This is the simplest option but provides no protection against disk failure or server loss.

Default backup location
/var/lib/sh0/backups/<stack-name>/<database-name>/
Warning
Local-only backups do not protect against hardware failure. For production databases, always configure at least one remote storage destination.

S3-Compatible Storage

sh0 supports any S3-compatible object storage provider, including AWS S3, Cloudflare R2, MinIO, Backblaze B2, and DigitalOcean Spaces.

To configure a storage provider:

  1. Go to Settings → Storage Providers.
  2. Click Add Provider.
  3. Enter the endpoint URL, access key, secret key, bucket name, and region.
  4. Click Test Connection to verify access.
  5. Click Save.
S3 storage provider configuration -- endpoint, credentials, bucket, and region fields with a Test Connection button
Tip
Cloudflare R2 offers free egress, making it an excellent choice for backup storage. Set the endpoint to https://<account-id>.r2.cloudflarestorage.com.

Retention

A schedule keeps a bounded number of backups for its source. The value you set is a count of backups to keep -- not a number of days. Retention only counts the backups that schedule created: manual backups are never counted and never removed, and when a source has several schedules, each one prunes only its own. The default is 7, and 0 means unlimited: backups are never removed automatically.

SettingDescription
Retention countHow many completed scheduled backups of this source to keep. Anything beyond that count is what a purge would remove.
Manual backupsNever counted towards the retention count, and never deleted automatically.
Value of 0 or lessDisables pruning for that schedule.
Automatic pruning -- fixed in 1.6.18
On 1.6.17 and earlier, nothing ever ran the pruning: the retention count was stored and shown, but scheduled backups accumulated until deleted by hand. From 1.6.18 pruning runs after every successful scheduled backup, with an hourly catch-up sweep for repositories that already overflowed. If you are still on an earlier version, keep removing old backups from the Backups tab and size your storage accordingly.

Restoring from a Backup

Restoring a backup replaces the current database contents with the backup data. sh0 handles stopping the database, restoring the data, and restarting the container.

  1. Open the database Backups tab.
  2. Find the backup you want to restore in the history list.
  3. Click the Restore button next to the backup.
  4. Confirm the restore operation in the dialog.
  5. Wait for the restore to complete -- the database will be temporarily unavailable.
Backup restore confirmation dialog -- warning about data replacement and a confirm button
Danger
Restoring a backup overwrites all current data in the database. Consider creating a fresh backup of the current state before restoring an older one.

Backup History & Status

The backup history table shows all backups for a database, including their status, size, duration, and storage location.

Backup history table -- showing timestamps, sizes, durations, statuses, and storage destinations for each backup

Each backup can have one of the following statuses:

  • Completed -- Backup finished successfully and is available for restore.
  • In Progress -- Backup is currently running.
  • Failed -- Backup encountered an error. Click the entry to view the error message.
  • Expired -- Backup was removed by the retention policy.

You can also download completed backups directly from the dashboard for offline storage or migration to another server.