Giter Site home page Giter Site logo

backuptoqiniu's Introduction

#备份网站数据到七牛云存储脚本

利用七牛python SDK上传,需要配置 backuptoqiniu.sh 作者:ccbikai
博客:http://miantiao.me/ 没有注册的同学需要注册七牛账号

  1. 安装七牛SDK,需要 python 环境:

    python setup.py install
    
  2. 配置 backuptoqiniu.sh

    ## 备份配置信息 ##
    
    # 备份名称,用于标记
    BACKUP_NAME="qiniu-backup"
    # 备份目录,多个请空格分隔
    BACKUP_SRC="/home/wwwroot/"
    # Mysql主机地址
    MYSQL_SERVER="127.0.0.1"
    # Mysql用户名
    MYSQL_USER="root"
    # Mysql密码
    MYSQL_PASS="mysqlpassword"
    # Mysql备份数据库,多个请空格分隔
    MYSQL_DBS="dbname"
    # 备份文件临时存放目录,一般不需要更改
    BACKUP_DIR="/tmp/backuptoqiniu/"
    
    ## 备份配置信息 End ##
    
    ## 七牛配置信息 ##
    
    #存放空间
    QINIU_BUCKET="<YOUR_APP_bucket>"
    #ACCESS_KEY
    QINIU_ACCESS_KEY="<YOUR_APP_ACCESS_KEY>"
    #SECRET_KEY
    QINIU_SECRET_KEY="<YOUR_APP_SECRET_KEY>"
    
    ## 七牛配置信息 End ##
    
  3. ./backuptoqiniu.sh 添加执行权限

    chmod +x backuptoqiniu.sh
    
  4. 执行 ./backuptoqiniu.sh 开始备份上传

  5. 利用 cron 定时执行,以下示例为每天凌晨02:00执行备份,请确认脚本路径

    crontab -e
    

    进入 cron 编辑,按 i 进入编辑模式,在最后输入以下内容

    0 2 * * * /root/backuptoqiniu/backuptoqiniu.sh
    

    esc 键,输入 :wq,回车保存文件,正常会出如下提示:

    crontab: installing new crontab
    

##多个网站备份

多个网站备份只需要将 backuptoqiniu.sh 拷贝一份,修改其中配置,运行新脚本,即可执行备份

##常见问题

  1. mysqldump: command not found,如果出现此错误,请参考以下方式解决 http://www.inbiji.com/biji/mysqldump-command-not-found.html

backuptoqiniu's People

Contributors

laoshu133 avatar kslr avatar

Watchers

James Cloos avatar 30551N@r 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.