Giter Club home page Giter Club logo

ops_backup's Introduction

功能

用于对目录、文件执行备份;  
同时根据配置项决定是否压缩,以及保留的备份份数;  
适用于linux、windows系统;  

原理

使用rsync命令对目录、文件进行备份;  
使用tarfile对目录、文件进行压缩归档;  
使用rm(window是del/rd)对备份目录进行清理;  

配置说明

[linux]      ## 每个备份任务的唯一ID  
srcfiles = /home/superman/cmdb;/home/superman/ops_backup ## 备份目录(文件)  
destdir = /tmp/superman  ## 备份目录(文件)存放目录  
func = 备份CMDB以及本py脚本所在目录 ## 功能说明  
excludes = .svn-base;.svn  ## 需要排除的目录(文件)  
zip = 1  ## 是否压缩:1压缩,0不压缩
keep = 10  ## 保留份数  
timeout = 600 ## 执行备份任务预估所需时间,超过此时间会终止任务,不配置则会一直执行备份直至完成  
  
[windows]  ## 同上  
func = 备份PYTHON资源 ## 同上  
srcfiles = E:\python资源    ## 同上  
destdir = d:\superman  ## 同上    
excludes = .svn-base;.svn  ## 同上    
zip = 1  ## 同上    
keep = 10  ## 同上    

用法

python backup.py   
Usage: backup.py [options]  
  
Options:  
  -h, --help            show this help message and exit  
  -i ID, --id=ID        which id to backup, if none, backup all  
  -c CONFFILE, --conf=CONFFILE  
                        configure file  
  -l, --list            list all the configure  
  -d, --debug           if open debug module  

用法示例

$ python backup.py -i linux  
[FILE-1]  
  FROM: /home/superman/cmdb  
    TO: /tmp/albert/20170507172644185  
  KEEP: 10  
   ZIP: 1  
=> backup result: SUCCESS  
=> tar result: SUCCESS  
[FILE-2]  
  FROM: /home/superman/ops_backup  
    TO: /tmp/superman/20170507172644185  
  KEEP: 10  
   ZIP: 1  
=> backup result: SUCCESS  
=> tar result: SUCCESS  
=> Delete: /tmp/superman/20170507160105311  

ops_backup's People

Contributors

qiueer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ops_backup's Issues

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.