How to back up and restore a self-hosted forum
A practical backup and restore guide for self-hosted forums: what to save, how to snapshot SQLite and MySQL safely, and how to prove your restore actually works.
Every forum has exactly one irreplaceable asset: its history. Posts, accounts, attachments, private messages and years of accumulated answers cannot be re-downloaded. Everything else — themes, plugins, even the server — can be rebuilt. The data cannot.
This guide is a complete, testable backup and restore procedure for a self-hosted forum. It works for any PHP forum; the examples use SQLite and MySQL, the two backends bulletinbored supports.
What you need to back up
A forum is more than its database. Capture all three together:
- The database — users, threads, posts, settings.
- Uploaded files — attachments and avatars, usually under
uploads/. - Configuration —
config.json(or your equivalent), which holds the database path and connection details.
If you back up only the database, you will restore a forum with broken attachments. If you back up only the files, you will restore a forum with no posts. Back up both, and keep the config with them so the restore is self-describing.
Backing up SQLite safely
SQLite is a file, but you should not just copy it while the forum is running. A copy taken mid-write can be inconsistent. Use SQLite’s online backup instead:
sqlite3 /var/www/forum/data/database.sqlite ".backup '/backups/forum-$(date +%F).sqlite'"
The .backup command takes a consistent snapshot even while the application is writing.
If you prefer a plain file copy, checkpoint the write-ahead log first and copy the
database and its -wal and -shm files together — but the .backup route is simpler
and safer.
A minimal daily script:
#!/usr/bin/env bash
set -euo pipefail
FORUM=/var/www/forum
DEST=/backups/forum
STAMP=$(date +%F-%H%M)
mkdir -p "$DEST"
sqlite3 "$FORUM/data/database.sqlite" \
".backup '$DEST/db-$STAMP.sqlite'"
tar -czf "$DEST/uploads-$STAMP.tar.gz" -C "$FORUM" uploads
cp "$FORUM/config.json" "$DEST/config-$STAMP.json"
# Keep 14 days
find "$DEST" -type f -mtime +14 -delete
Run it from cron once a day, and after any major change.
Backing up MySQL safely
For a MySQL or MariaDB backend, use a logical dump:
mysqldump --single-transaction --quick \
--default-character-set=utf8mb4 \
-u forum_user -p forum_db \
| gzip > "/backups/forum/db-$(date +%F-%H%M).sql.gz"
--single-transaction gives you a consistent snapshot for InnoDB tables without locking
the forum for writes. Add your uploads and config exactly as in the SQLite example.
Store credentials in a protected option file rather than on the command line, so the password does not appear in process listings.
Keep backups off the server
A backup on the same disk as the forum is not a backup — it is a copy that disappears with the server. Get at least one copy off the machine:
- copy to another host you control;
- push to object storage (S3-compatible, Backblaze, etc.);
- or pull them from a separate machine on a schedule.
Encrypt backups if the destination is shared, and restrict who can read them. A forum backup contains personal data: emails, private messages, IP logs if you keep them.
Test restores — or you have no backups
This is the part almost everyone skips. A backup you have never restored is a guess. Schedule a restore drill:
- Create a scratch server or directory. Never test over production.
- Take the latest backup set (database + uploads + config).
- Restore the database. For SQLite, copy the snapshot into place. For MySQL, import the dump.
- Restore uploads into the same relative path.
- Point a config at the restored data and start the forum.
- Verify: log in, open an old thread, load an attachment, search, post a test message.
If that list works, your backup is real. If it does not, you found the problem at a good time.
Restoring SQLite
# Stop the web server or put the forum in maintenance mode first.
cp /backups/forum/db-2026-11-22-0300.sqlite /var/www/forum/data/database.sqlite
chown www-data:www-data /var/www/forum/data/database.sqlite
tar -xzf /backups/forum/uploads-2026-11-22-0300.tar.gz -C /var/www/forum
cp /backups/forum/config-2026-11-22-0300.json /var/www/forum/config.json
Make sure the web server can write to data/ and uploads/. Remove any stale -wal and
-shm files that belonged to the old database before starting.
Restoring MySQL
gunzip -c /backups/forum/db-2026-11-22-0300.sql.gz | mysql -u forum_user -p forum_db
Then restore uploads and config as above and clear any caches the forum uses.
A backup checklist
- Database snapshot taken consistently (
.backupormysqldump --single-transaction) -
uploads/archived, including avatars -
config.jsoncopied alongside - At least one copy stored off the server
- Backups encrypted and access-restricted
- Retention policy defined (e.g. 14 daily + 4 weekly)
- Restore tested on a scratch environment
- Restore steps written down where you can find them at 2 a.m.
The bottom line
The best backup system is the one you will actually run and test. A single-file SQLite database makes this dramatically easier: the entire forum state is a handful of files you can copy, verify and restore in minutes.
If you are still choosing a platform, treat backup simplicity as a feature. It is one of the reasons bulletinbored defaults to SQLite with no external services — the less there is to back up, the more likely you are to do it.
- Read about SQLite forum software.
- Compare footprints in lightweight forum software for small servers.
- Planning a move? See migrating a forum to a simpler stack.
- Install from scratch with the one-minute guide.