My automated database backup solution
This post is an overview of my backup solution for PostgreSQL, MySQL, and MongoDB databases to AWS S3.
Find the code here: https://github.com/lukeliasi/database-backups-s3
How It Works
- Define Connection URIs: Include the database connection string URIs in the configuration.
- Schedule Backups: Set up a Cron expression for scheduling or run on the script startup.
- Database Dump: The script connects to the databases and performs a dump.
- Compression and Upload: Dumps are compressed and uploaded to the connected S3 bucket.
You can deploy this script in just a few clicks on platforms such as Railway or Fly.io. Simply clone the repo, connect your account to the service, configure your databases and it should be up and running in no time or run it elsewhere by simply running
docker compose up.