Backups
You need both the database and the media directory for a usable backup.
What to back up
- SQLite database
- Media directory
- Your
.envfile or secret-management equivalent - File ownership and permissions for the runtime directories
Backup example
Stop OpenPost first if you want the simplest backup path:
bash
sudo systemctl stop openpostIf your deployment keeps SQLite in WAL mode, copy the database together with any -wal and -shm files that exist. Those extra files can contain committed data that has not yet been checkpointed into the main .db file.
Database
bash
cp /var/lib/openpost/openpost.db openpost-backup-$(date +%Y%m%d).db
cp /var/lib/openpost/openpost.db-wal openpost-backup-$(date +%Y%m%d).db-wal 2>/dev/null || true
cp /var/lib/openpost/openpost.db-shm openpost-backup-$(date +%Y%m%d).db-shm 2>/dev/null || trueMedia
bash
tar -czf media-backup-$(date +%Y%m%d).tar.gz /var/lib/openpost/media/Secrets
bash
cp /opt/openpost/.env openpost-env-backup-$(date +%Y%m%d)Restart when the backup finishes:
bash
sudo systemctl start openpostRestore process
- Stop OpenPost.
- Restore the SQLite database files.
- Restore the media directory.
- Restore
.envor the equivalent secrets source. - Fix ownership and permissions.
- Start OpenPost.
- Confirm login, media access, and scheduled-post visibility.
Example restore
bash
sudo systemctl stop openpost
sudo mkdir -p /var/lib/openpost/media /opt/openpost
sudo cp openpost-backup-20260518.db /var/lib/openpost/openpost.db
sudo cp openpost-backup-20260518.db-wal /var/lib/openpost/openpost.db-wal 2>/dev/null || true
sudo cp openpost-backup-20260518.db-shm /var/lib/openpost/openpost.db-shm 2>/dev/null || true
sudo tar -xzf media-backup-20260518.tar.gz -C /
sudo cp openpost-env-backup-20260518 /opt/openpost/.env
sudo chown -R openpost:openpost /var/lib/openpost /opt/openpost
sudo chmod 600 /opt/openpost/.env
sudo systemctl start openpostMigrate to another server
- Install the new OpenPost binary or container deployment first.
- Stop OpenPost on both the old and new server.
- Copy the database, any
-waland-shmfiles, the media directory, and.env. - Restore ownership and permissions on the new server.
- Start OpenPost on the new server.
- Verify provider callbacks, media URLs, and scheduled posts before switching traffic.
If the hostname changes, update your reverse proxy, provider callback URLs, and OPENPOST_MEDIA_URL before making the new server live.
Test restore checklist
- Can you log in with an existing account?
- Do previously uploaded media items load?
- Are connected accounts still listed?
- Are drafts and scheduled posts present?
- Does the health endpoint respond?
- If the server hostname changed: do provider callbacks and public media URLs still point at the new host?
Notes
- Test restores, not just backups.
- Keep database and media snapshots reasonably aligned in time.
- Protect backup copies of
.env: encrypted provider tokens still depend onOPENPOST_ENCRYPTION_KEY.