Luke Liasi profile pictureLuke Liasi
Cloud backup
← Back to posts

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

  1. Define Connection URIs: Include the database connection string URIs in the configuration.
  2. Schedule Backups: Set up a Cron expression for scheduling or run on the script startup.
  3. Database Dump: The script connects to the databases and performs a dump.
  4. Compression and Upload: Dumps are compressed and uploaded to the connected S3 bucket.

Supported Databases

  • PostgreSQL
  • MySQL
  • MongoDB

Deployment

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.

Deploy on Railway