Giter Site home page Giter Site logo

docker-backup-db's Introduction

数据库备份工具

原理:在原生的docker镜像基础上,加入一备份工具,增强备份功能。 提供postgres, mysql5镜像,可直接使用,如有需要请提issues。

  • 可以自行构建docker镜像,支持不同的数据库及不同的版本,如mysql8, oracle, sqlserver2017+等等
  • 支持自定义命令
  • 可以把备份后的文件存入另一台服务器
  • 备份失败邮件通知
  • 服务端每日10点检查上传的备份文件,如未检查到发邮件通知
  • 每日凌晨自动备份
  • 可设置备份文件最大保存天数(最少3天)
  • 参考tls实现加密传输备份文件到服务端,rsa非对称交换密钥 + aes-256-gcm对称加密(每次随机密码+固定验证密码)

backup databases

Support all databases and the database images can be find in docker.

  • Support for custom backup commands.
  • Obsolete files will be deleted automatically.
  • You can copy the backup files to another server.
  • Send email when backup failed.
  • The server checks the backup files that are not uploaded at 10 o'clock every day. If the backup files are not checked, an email notice will be sent
  • Automatic backup in every night.
  • The maximum number of days to save backup files can be set (at least 3 days).
  • Reference to the TLS implementation of encryption transfer backup files to the server.

docker 环境变量说明

backup_server_ip 不填默认为二次备份的服务器
backup_server_port 二次备份服务器的端口
server_secret_key 服务端验证密码
backup_project_name 项目名称,一般就是数据库名称。
backup_command 备份命令,必须包含#{DATE}
max_save_days 备份文件最大保存天数
notice_email 异常通知的邮箱

server(You don't need this, maybe)

docker run -d \
--name backup-server \
--restart=always \
-p 9977:9977 \
-v /opt/backup-files:/app/backup-files \
-e backup_server_port=9977 \
-e server_secret_key=please_change_it \
-e max_save_days=30 \
-e [email protected] \
-e smtp_host=smtp.office365.com \
-e smtp_port=587 \
-e [email protected] \
-e smtp_password=password \
jeessy/backup-db:0.0.7

client (postgress)

docker run -d \
--name backup-db-name \
--restart=always \
-v /opt/backup-files:/app/backup-files \
-e backup_server_ip=192.168.1.76 \
-e backup_server_port=9977 \
-e server_secret_key=please_change_it \
-e backup_project_name=db-name \
-e backup_command="pg_dump -a \"host=192.168.1.11 port=5433 user=postgres password=password dbname=db-name\" > #{DATE}.sql" \
-e max_save_days=30 \
-e [email protected] \
-e smtp_host=smtp.office365.com \
-e smtp_port=587 \
-e [email protected] \
-e smtp_password=password \
jeessy/backup-db:postgres-0.0.7

client (mysql5)

docker run -d \
--name backup-db-name \
--restart=always \
-v /opt/backup-files:/app/backup-files \
-e backup_server_ip=192.168.1.76 \
-e backup_server_port=9977 \
-e server_secret_key=please_change_it \
-e backup_project_name=db-name \
-e backup_command=mysqldump -h192.168.1.9 -uroot -p123456 db-name > #{DATE}.sql \
-e max_save_days=30 \
-e [email protected] \
-e smtp_host=smtp.office365.com \
-e smtp_port=587 \
-e [email protected] \
-e smtp_password=password \
jeessy/backup-db:mysql5-0.0.7

build docker images (You may not need to build docker images, if you use postgres or mysql5)

# first git clone
# change Dockerfile
# build docker images
sudo docker build . -f Dockerfile_mysql -t jeessy/backup-db:mysql5-0.0.7
sudo docker build . -f Dockerfile_postgres -t jeessy/backup-db:postgres-0.0.7
# build server
sudo docker build . -f Dockerfile -t jeessy/backup-db:0.0.7

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.