-
-
Notifications
You must be signed in to change notification settings - Fork 8
Server Backup and Restore
BBS includes built-in tools for backing up the server itself — the database, configuration, SSH keys, and system config. This lets you recover from hardware failure, migrate to a new server, or restore a Docker container from scratch using S3.
Each server backup is a compressed .tar.gz archive containing:
| File | Description |
|---|---|
dump.sql |
Full MySQL dump (all tables except file catalog) |
env |
Configuration file (APP_KEY, DB credentials, S3 keys, SMTP, etc.) |
version |
BBS version at time of backup |
ssh-host-keys/ |
SSH host key pairs (prevents "host key changed" errors for agents) |
sudoers/ |
Sudoers files for www-data privileges |
cron |
Scheduler cron job definition |
clickhouse-file-catalog.csv |
ClickHouse catalog data (only with --with-catalogs flag) |
What is NOT backed up: Borg repository data (client backups). Repositories can be multi-terabyte and are already the backup. Use S3 Offsite Sync to protect repository data separately.
Critical: The
APP_KEYin.envencrypts all sensitive data — repository passphrases, S3 secret keys, SMTP passwords, API tokens. Without this key, encrypted data is permanently unrecoverable.
Daily backups run automatically via the scheduler cron job:
- Frequency: Once per day
-
Location:
/var/bbs/backups/ - Retention: 7 most recent backups (older ones deleted automatically)
-
Format:
bbs-backup-YYYY-MM-DD_HHMMSS.tar.gz
No configuration needed — automatic backups are enabled by default on every BBS installation.
Run a backup on demand:
sudo /var/www/bbs/bin/bbs-backupTo save to a custom directory:
sudo /var/www/bbs/bin/bbs-backup /root/pre-update-backup/| Flag | Description |
|---|---|
--with-catalogs |
Include ClickHouse file catalog data (can be large) |
--keep N |
Keep N most recent backups instead of the default 7 |
- Before major version updates
- Before server migrations
- Before any configuration changes involving
APP_KEY - Before disk maintenance
To protect against total server loss, sync your server backups to S3-compatible storage:
- Go to Storage in the sidebar, then click S3 Sync Settings
- Enter your S3 credentials (endpoint, region, bucket, access/secret keys)
- Check "Sync server backups to off-site storage daily"
- Click Save S3 Settings
Once enabled, the scheduler automatically uploads server backups to bucket/[prefix]/_server-backups/ daily after the backup completes. Only the 7 most recent backups are kept in S3.
- A fresh BBS installation (bare metal via
bbs-install, or a Docker container) - A backup
.tar.gzfile (from/var/bbs/backups/or downloaded from S3)
-
Install BBS on the new server:
sudo bash bbs-install --hostname backup.example.com
-
Copy the backup file to the server:
scp bbs-backup-2026-03-04_120000.tar.gz root@newserver:/tmp/
-
Run the restore:
sudo /var/www/bbs/bin/bbs-restore /tmp/bbs-backup-2026-03-04_120000.tar.gz
The restore script walks through 7 steps interactively:
- Version checkout — checks out the git tag matching the backup version
-
Restore
.env— prompts before overwriting (preservesAPP_KEYand encryption) - Import database — drops and recreates all tables from the backup dump
- Restore SSH host keys — so agents don't see "host key changed" errors
- Restore ClickHouse catalogs — file-level search index (if included in backup)
- Restore system config — sudoers and cron files
- Recreate Unix users — restores SSH users for all registered agents
After the restore, bbs-update runs automatically to fix permissions and apply any pending migrations.
- Log in to the web UI and verify clients, plans, and schedules
- Check Settings — hostname, email/SMTP, S3 credentials
- Verify agent connectivity (agents should reconnect automatically)
- If the hostname changed, update agent configurations to point to the new server
- If repository data is on the same disk, verify repositories are accessible
If you have S3 credentials configured with "Sync server backups" enabled, you can restore directly from S3 through the web UI — no need to manually download or transfer backup files. This works on both bare metal and Docker installations.
- Install BBS on the new server (bare metal via
bbs-install, or start a fresh Docker container) - Log in with the initial admin credentials
- Go to Storage → S3 Sync Settings
- Enter the same S3 credentials used by your previous server
- Click Save S3 Settings
- Scroll down to the Restore from S3 Backup card
- Click List Available Backups — you'll see all server backups stored in S3
- Click Restore on the backup you want
- Confirm in the warning dialog
- BBS downloads the backup from S3, restores the database and configuration, and displays new admin credentials
- Save the new credentials, then click Go to Login
After logging in, all your clients, repositories, backup plans, and settings from the backup will be restored. Repository data still needs to be restored separately (use the S3 Restore feature on each repository, or wait for agents to reconnect and create new backups).
Note: The restore replaces the entire database, so a new admin password is generated and displayed. The old password from the backup will not work.
- The selected backup is downloaded from S3 to a temporary directory
-
bbs-restore --yesruns non-interactively: restores.env, imports the database, restores SSH keys, recreates Unix users - Stale queued jobs from the backup are cleared (they reference repos/agents that may not exist on the new server)
- On bare metal, the code is checked out to match the backup version, then
bbs-updateupgrades to latest - On Docker, the version checkout is skipped (code is baked into the image) and migrations bring the schema up to date
- If the backup's database credentials differ from the running server (e.g. restoring a bare-metal backup onto Docker), the restore automatically keeps the working credentials
For scripted or automated restores, use the --yes flag to skip all interactive prompts:
sudo /var/www/bbs/bin/bbs-restore --yes /tmp/bbs-backup-2026-03-04_120000.tar.gzWhen --yes is used:
-
.envis overwritten without prompting - Database is dropped and reimported without prompting
- A new random admin password is generated and printed to stdout as
NEW_ADMIN_PASSWORD=<password>
This is what the web UI's "Restore from S3" feature uses internally.
Check disk space:
df -h /var/bbs/backups/Check MySQL connection:
sudo mysql -e "SHOW DATABASES;""Could not read DB credentials from .env":
- The backup's
.envfile is damaged or missing credentials - Try restoring
.envmanually:tar -xzf backup.tar.gz env
Database import fails:
- Check MySQL is running:
sudo systemctl status mysql(ormariadb) - Ensure the MySQL user has sufficient privileges
Version tag not found:
- The backup is from a version that doesn't have a git tag
- The restore continues with the current installed code and runs migrations
- Verify S3 credentials are correct (use Test Connection)
- Ensure the previous server had "Sync server backups" enabled
- Check the S3 path prefix matches what the previous server used
- Backups are stored at
bucket/[prefix]/_server-backups/
- If restoring to a new server with a different IP/hostname, agents need their server URL updated
- If restoring to the same server, agents should reconnect automatically within a few minutes
- SSH host keys are restored from the backup, so agents won't see "host key changed" errors
Related: S3 Offsite Sync | Docker Installation | Updating BBS | Storage Setup
📖 User Manual
Getting Started
Using BBS
- Dashboard
- Managing Clients
- Linux Agent Setup
- macOS Agent Setup
- Windows Agent Setup
- Repositories
- Storage Setup
- Backup Plans
- Restoring Files
- Database Backups
- Plugins
- Remote Storage
- S3 Offsite Sync
Monitoring
Administration
- Settings
- User Management
- Single Sign-On
- Two-Factor Authentication
- Updating BBS
- Server Backup and Restore
Reference