Code Monkey home page Code Monkey logo

docker-backups's Introduction

docker-backups

Schedule file and database backups as well as periodic cleanup of backups files.

Setup

  1. Clone this repository to your server with files that need to be backed up
git clone https://github.com/dylangmiles/docker-backups.git
git submodule update --init --recursive
  1. Create a .env file in the directory with the following settings:
# Cron schedule
SCHEDULE=* * * * *

# Label used for the backup filename. The result backup file name will use the format  YYMMDD_HH_mm_ss_NAME_tar.gz
NAME=test

# LOCATION ( local | aws | azure) 
LOCATION=aws

# The location where backups will be written to if file based
LOCAL_DESTINATION=./data/destination

# The local location that will be backed up
SOURCE=./data/source

# Type of database (db | mariadb)
DB=pg

# Database connection details
MYSQL_USER=root
MYSQL_PASSWORD=*********
MYSQL_HOST=host.docker.internal
MYSQL_PORT=3306

# Database connection details
PG_USER=postgres
PG_PASSWORD=*********
PG_HOST=host.docker.internal
PG_PORT=5432

# Delete back up on this day from last week
INCLUDE_PATTERN=$$(date +%Y%m%d -d "last week")_*.???.gz

# Keep the back up from last Sunday
EXCLUDE_PATTERN=$$(date +%Y%m%d -d "last Sunday")_*.???.gz

# Command print | delete
LOCAL_COMMAND=print

# AWS dry run remove. 0 - false | 1 - true (default)
AWS_DRYRUN=1

# AWS Storage
AWS_ACCESS_KEY=**************
AWS_SECRET_KEY=******************************
AWS_REGION=eu-west-1
AWS_DESTINATION=s3://bucketname/path

# AZURE dry run remove. 0 - false | 1 - true (default)
AZURE_DRYRUN=1


# Azure Storage
AZURE_APP_TENANT_ID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
AZURE_APP_ID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeef
AZURE_APP_SECRET=*************
AZURE_STORAGE_ACCOUNT=mystorageaccount
AZURE_STORAGE_BLOB_CONTAINER=mycontainer
AZURE_STORAGE_BLOB_PREFIX=pathincontainer/

# Email address where notifications are sent
[email protected]

# Email sending options
[email protected]
[email protected]
SMTP_HOST=smtp.mailserver.com
SMTP_PORT=587
[email protected]
SMTP_PASSWORD=*******
  1. Start the container
docker compose up -d

You can also manually run the backups from the command line

docker compose run --rm file-backup backup-run.sh
docker compose run --rm mariadb-backup backup-run.sh
docker compose run --rm file-delete delete-run.sh

NB: The file backup will ignore any directories with .file-backup-ignore in them.

docker-backups's People

Contributors

dylangmiles avatar

Watchers

 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.