Skip to content

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 script
  • infra/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-available and sites-enabled configs
  • 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:

bash
/var/www/launchkitlabs/backups/launchkit-backup-YYYY-MM-DD-HHMMSS.tar.gz
/var/www/launchkitlabs/backups/launchkit-backup-YYYY-MM-DD-HHMMSS.sha256

Production layout

The default script paths match this deployment layout:

bash
/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/uploads

If your install uses different paths, override variables when running the script.

bash
BASE_DIR=/var/www/myapp \
BACKUP_DIR=/var/backups/myapp \
KEEP_BACKUPS=14 \
bash /var/www/myapp/infra/scripts/backup-launchkit.sh

Manual run

bash
bash /var/www/launchkitlabs/infra/scripts/backup-launchkit.sh

The 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:

bash
mkdir -p /var/www/launchkitlabs/logs

Cron example:

cron
0 2 * * * /var/www/launchkitlabs/infra/scripts/backup-launchkit.sh >> /var/www/launchkitlabs/logs/backup.log 2>&1

This 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:

bash
/var/www/launchkitlabs/infra/scripts/backup-launchkit.sh

Then 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:

bash
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:

  1. Connect to your VPS with SSH/SFTP
  2. Navigate to /var/www/launchkitlabs/backups/
  3. Download .tar.gz and matching .sha256 files to a secure local folder
  4. 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
  • rsync to 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
bash /var/www/launchkitlabs/infra/scripts/restore-launchkit.example.sh \
  /var/www/launchkitlabs/backups/launchkit-backup-YYYY-MM-DD-HHMMSS.tar.gz

By 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:

  1. Verify the checksum.
  2. Stop backend/frontend services.
  3. Restore PostgreSQL from the dump.
  4. Restore uploads.
  5. Restore shared env files.
  6. Restore Nginx site configs.
  7. Run sudo nginx -t.
  8. Reload Nginx.
  9. Restart services.
  10. Verify API health and frontend login.

Safety rules

  • Never commit .env backups 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.

LaunchKit Pro by LaunchKit Labs — buyer documentation. No secrets in this site.