#Scheduled DB backup on my self hosted instance
1 messages · Page 1 of 1 (latest)
Hi @vernal snow. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To perform scheduled database backups on your self-hosted Convex instance, you will need to implement your own scheduling mechanism, as the built-in periodic backup feature described in the Convex dashboard is only available for the cloud-hosted product and not mentioned as available for self-hosted deployments in the knowledge sources.
For self-hosted Convex, you can use the CLI command to export your database:
npx convex export --path <your-backup-path>
To automate this process, you should set up an external scheduler (such as a cron job on your server) to run this command at your desired intervals. For example, you could add a line to your server's crontab to run the export daily or weekly.
Example crontab entry for daily backup at 2am:
0 2 * * * cd /path/to/your/convex/project && npx convex export --path /path/to/backup/dir/snapshot_$(date +\%s).zip
This will create a timestamped backup file each day.
Important notes:
- The backup will be a ZIP file containing all documents in all Convex tables, as well as file storage data if used.
- The backup does not include your deployment's code, configuration, or environment variables. You should back those up separately if needed.
- For restoring, you can use
npx convex import --replace-allafter stopping external traffic to your backend, as described in the upgrade and restore instructions for self-hosted Convex deployments Get-convex Self-hosted README and Convex Backup & Restore docs.