Code Monkey home page Code Monkey logo

db-backup-oss's Introduction

db-backup-oss

备份数据库,然后上传到阿里云OSS

支持数据库

  • Mongodb
  • Mysql
  • Postgresql

使用方式

一、以 Kubernetes CronJob 方式运行

k8s/<db_type>-cronjob.yaml中设置好所有带有TODO的参数项目,然后执行:

kubectl apply -f k8s/<db_type>-cronjob.yaml

提示: 目前提供的CronJob声明文件只支持kubernetes >= 1.8, 老版本(< 1.8)请参考文档

二、通过 Docker 使用

Mongodb

# 未标"必须"的都是选填项
docker run -it --rm \
  -e "DB_TYPE=mongodb" \ # 指定数据库类型为mongodb
  -e "MONGODB_HOST=localhost" \ # mongodb host,支持副本集如: mongo-0.mongo.db,mongo-1.mongo.db,mongo-2.mongo.db
  -e "MONGODB_PORT=27017" \  # mongodb 端口
  -e "MONGODB_USER=admin" \ # mongodb 用户名
  -e "MONGODB_PASS=password" \ # mongodb 密码
  -e "EXTRA_OPTS='--gzip --repair'" \ # 向添加 mongodump 额外参数
  -e "DATE_FORMAT=+%Y-%m-%d" \ # 当前日期作为目录名,日期格式
  -e "OSS_ENDPOINT=oss-cn-shenzhen.aliyuncs.com" \ # 必须;oss endpoint
  -e "OSS_BUCKET=backup-center" \ # 必须;oss bucket
  -e "OSS_FOLDER=/mongodb" \ # oss 上存放备份的主目录名
  -e "OSS_ACCESS_KEY_ID=oss_key_id" \ # 必须;oss access key id
  -e "OSS_ACCESS_KEY_SECRET=oss_key_secret" \ # 必须;oss access key secret
  -e "DB_NAME=blog-api,cms-backend" \ # 必须;需要备份的DB名,多个DB用逗号(,)分开
  -e "authenticationDatabase=admin" \ # 设置mongodb的 --authenticationDatabase 选项, 使用管理员账号备份多个数据库时可使用这个参数
  --link your-mongo-container:mongodb \ # 链接mongodb的contaienr后,会自动尝试获取 host、port、username、password 等。
  xuhao/db-backup-oss:latest

db-backup-oss's People

Contributors

xuhao avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.