All Templates / Automation

Database S3 backups

Database S3 backups

A simple script to automatically back up multiple databases to S3.

Deploy Database S3 backups

database-backups-s3

lukeliasi/database-backups-s3

Just deployed

Database S3 backups

This script provides a simple all-in-one automated way to back up your databases to AWS S3.

Supported databases:

  • postgres
  • mysql
  • mongodb

Features

  • Define multiple databases of different types in your configuration, and the script will automatically handle the backup process for all of them in one execution.
  • Backups can be initiated either upon the script execution or on a scheduled basis using a cron job.
  • Backups are compressed to reduce file size.

How it works

  1. Define database connection URI strings for each database you want backed up and the backup schedule
  2. The script will connect to the database(s) and do a dump
  3. The dump is compressed and uploaded to your defined AWS S3 Bucket
  4. Finally, the dumps are cleaned up on the local file system

Configuration

Create a .env file in the root directory with the following variables:

RUN_ON_STARTUP=true
CRON=0 0 * * *
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_S3_BUCKET=
AWS_S3_REGION=
AWS_S3_ENDPOINT=
DATABASES="mysql://user:password@host:port/database,postgresql://user:password@host:port/database,mongodb://user:password@host:port"

Environment variables

KeyDescriptionOptionalDefault Value
DATABASESComma-separated connection strings list of database URIs that should be backed up.No[]
RUN_ON_STARTUPBoolean value that indicates if the script should run immediately on startup.Yesfalse
CRONCron expression for scheduling when the backup job will run for all databases. See Crontab.guru for help setting up schedules.Yes
AWS_ACCESS_KEY_IDAWS access key ID.No
AWS_SECRET_ACCESS_KEYAWS secret access key.No
AWS_S3_BUCKETName of the S3 bucket.No
AWS_S3_REGIONRegion of the S3 bucket.No
AWS_S3_ENDPOINTEndpoint for the S3 service.No

Template Content

Deploy Now

Details

Luke Liasi

Created on Aug 9, 2023

47 total projects

14 active projects

100% success on recent deploys

JavaScript, Dockerfile

Automation



More templates in this category

View Template
Postgres S3 backups

Postgres S3 backups

A simple NodeJS app to back up your PostgreSQL database to S3 via a cron


Railway Templates

View Template
Tier

Tier

A single tool to configure,orchestrate and manage your entire pricing stack


View Template
Trigger.dev

Trigger.dev

Open source background jobs framework for TypeScript.


Jan Henning