Backups & Restore
LaunchKit Pro includes a backup and restore foundation for self-hosted deployments. It is designed for VPS installs such as Contabo, Hetzner, DigitalOcean, or any Ubuntu server running PostgreSQL locally.
WARNING
Local backups are useful, but they are not enough for production. Enable your VPS provider's automatic backups when available and keep at least one offsite copy.
What is included
The infra package includes:
infra/scripts/backup-launchkit.sh— app-level backup scriptinfra/scripts/restore-launchkit.example.sh— guarded restore example and checklist
The backup script can archive:
- PostgreSQL database dump via
pg_dump - Uploads directory, if present
- Shared backend env file
- Shared frontend env file
- Nginx
sites-availableandsites-enabledconfigs - Deployment scripts from the app base folder, if present
- Current release symlink targets for backend, frontend, and docs
- SHA-256 checksum for the final archive
Default backup output:
/var/www/launchkitlabs/backups/launchkit-backup-YYYY-MM-DD-HHMMSS.tar.gz
/var/www/launchkitlabs/backups/launchkit-backup-YYYY-MM-DD-HHMMSS.sha256Production layout
The default script paths match this deployment layout:
/var/www/launchkitlabs/apps/api/current
/var/www/launchkitlabs/apps/frontend/current
/var/www/launchkitlabs/apps/docs/current
/var/www/launchkitlabs/shared/backend/.env
/var/www/launchkitlabs/shared/frontend/.env.production
/var/www/launchkitlabs/logs
/var/www/launchkitlabs/uploadsIf your install uses different paths, override variables when running the script.
BASE_DIR=/var/www/myapp \
BACKUP_DIR=/var/backups/myapp \
KEEP_BACKUPS=14 \
bash /var/www/myapp/infra/scripts/backup-launchkit.shManual run
bash /var/www/launchkitlabs/infra/scripts/backup-launchkit.shThe script uses restrictive file permissions (umask 077) because env files inside the archive contain secrets. It does not print env contents or database URLs.
Daily cron
Create the log directory if needed:
mkdir -p /var/www/launchkitlabs/logsCron example:
0 2 * * * /var/www/launchkitlabs/infra/scripts/backup-launchkit.sh >> /var/www/launchkitlabs/logs/backup.log 2>&1This keeps the latest 7 archives by default. Set KEEP_BACKUPS=14 or another value if your disk budget allows.
Optional systemd timer
Cron is the simplest option. If you prefer systemd timers, create a oneshot service that runs:
/var/www/launchkitlabs/infra/scripts/backup-launchkit.shThen schedule it with a daily timer. Keep logs in /var/www/launchkitlabs/logs/backup.log or journald.
Pull backups to your Mac (optional)
From your Mac, use scp or rsync over SSH to copy archives locally:
scp user@your-vps:/var/www/launchkitlabs/backups/launchkit-backup-*.tar.gz ~/Backups/launchkit/Verify checksum files alongside archives. Keep local copies private — they contain database dumps and .env files with secrets.
This does not replace GitHub source control — it protects runtime data and server configuration.
Windows (WinSCP)
Use WinSCP or similar SFTP client:
- Connect to your VPS with SSH/SFTP
- Navigate to
/var/www/launchkitlabs/backups/ - Download
.tar.gzand matching.sha256files to a secure local folder - Do not upload backup archives to public cloud without encryption
Offsite backups
For production, combine the script with at least one offsite strategy:
- Contabo Auto Backup or provider snapshots
- S3, Cloudflare R2, Backblaze B2, or Google Drive sync
rsyncto another VPS
Cloud upload is not implemented by default because the starter kit should not require a paid storage provider. Add it only after you choose and configure your storage destination.
Restore guidance
Use the guarded example script as a checklist:
bash /var/www/launchkitlabs/infra/scripts/restore-launchkit.example.sh \
/var/www/launchkitlabs/backups/launchkit-backup-YYYY-MM-DD-HHMMSS.tar.gzBy default it prints the restore plan and exits without changing production data. Restoring is destructive, so test the archive on staging before relying on it.
Restore flow:
- Verify the checksum.
- Stop backend/frontend services.
- Restore PostgreSQL from the dump.
- Restore uploads.
- Restore shared env files.
- Restore Nginx site configs.
- Run
sudo nginx -t. - Reload Nginx.
- Restart services.
- Verify API health and frontend login.
Safety rules
- Never commit
.envbackups or extracted backup folders into Git. - Never paste secrets into support tickets, logs, screenshots, or public docs.
- Encrypt archives before uploading them to third-party storage.
- Test restore before relying on backups.
- Keep provider/VPS snapshots enabled for production.