Giter Site home page Giter Site logo

database-backups-s3's Introduction

Database S3 backups

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

Deploy on Railway

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=<ACCESS_KEY_ID>
AWS_SECRET_ACCESS_KEY=<SECRET_ACCESS_KEY>
AWS_S3_BUCKET=<S3_BUCKET>
AWS_S3_REGION=<S3_REGION>
AWS_S3_ENDPOINT=<S3_ENDPOINT>
DATABASES="mysql://user:password@host:port/database,postgresql://user:password@host:port/database,mongodb://user:password@host:port"

Environment variables

Key Description Optional Default Value
DATABASES Comma-separated connection strings list of database URIs that should be backed up. No []
RUN_ON_STARTUP Boolean value that indicates if the script should run immediately on startup. Yes false
CRON Cron expression for scheduling when the backup job will run for all databases. See Crontab.guru for help setting up schedules. Yes
AWS_ACCESS_KEY_ID AWS access key ID. No
AWS_SECRET_ACCESS_KEY AWS secret access key. No
AWS_S3_BUCKET Name of the S3 bucket. No
AWS_S3_REGION Region of the S3 bucket. No
AWS_S3_ENDPOINT Endpoint for the S3 service. No

database-backups-s3's People

Contributors

lukeliasi avatar

Watchers

Pablo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.