Giter VIP home page Giter VIP logo

rclone-mysql-backup's Introduction

Deploy on Railway

Backup MySQL to Cloudflare R2

This Docker app runs a single time, dumping a MySQL database with mydumper and using rclone to push that data to Cloudflare R2.

You schedule the container to run at whatever interval you want backups to happen.

Setup

The container needs the environment variables related to MySQL:

  • MYSQL_HOST: The host to connect to, for example localhost or 127.0.0.1.
  • MYSQL_DATABASE: The name of the database to dump.
  • MYSQL_PORT: The port to connect to, defaults to 3306
  • MYSQL_USER: Username for MySQL
  • MYSQL_PASSWORD: Password for MySQL

And these variables related to Cloudflare R2:

  • R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY: An S3-compatible access key
  • R2_ENDPOINT: The S3 API URL for your R2 account
  • R2_BUCKET: The name of the bucket to upload to
  • R2_PATH: A folder within the R2 bucket to upload to, defaults to "mysql-backup"

Railway-specific guide

Tip

You can also deploy MySQL with these backups enabled if you don't have a database yet.

If you're running this container in Railway, you can use shared variables for all the MySQL variables (replace MySQL in each expression with the name of your database service):

  • MYSQL_HOST: ${{MySQL.MYSQLHOST}}
  • MYSQL_DATABASE: ${{MySQL.MYSQL_DATABASE}}
  • MYSQL_PORT: ${{MySQL.MYSQLPORT}}
  • MYSQL_USER: ${{MySQL.MYSQLUSER}}
  • MYSQL_PASSWORD: ${{MySQL.MYSQLPASSWORD}}

Then, in settings, set restart to never and input a cron schedule to backup as often as you'd like.

Restoring from a backup

  1. Install mydumper and rclone
  2. Create the same rclone config file that this container does
  3. Run rclone copy remote:$R2_BUCKET/$R2_PATH ./$LOCAL_FOLDER_TO_CREATE
  4. Run myloader -h $MYSQL_HOST -u $MYSQL_USER -p $MYSQL_PASSWORD -d $LOCAL_FOLDER_TO_CREATE

FAQ

Using something other than Cloudflare R2

You can fork this repo and modify the rclone config file to work for any storage destination that rclone supports (which is pretty much everything).

Does this work with MariaDB?

Yes! mydumper and myloader are compatible with MariaDB as well.

rclone-mysql-backup's People

Contributors

dbanty avatar renovate[bot] avatar

Stargazers

Nick Manning avatar  avatar

Watchers

 avatar

rclone-mysql-backup's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

dockerfile
Dockerfile
  • docker/dockerfile 1
  • rclone/rclone 1.67.0
  • mydumper/mydumper v0.16.3-2

  • Check this box to trigger a request for Renovate to run again on this repository

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.