Giter Club home page Giter Club logo

backup_servers's Introduction

backup_servers

Synopsis

Wrapper for rsync, parallelize backup. Used to backup 200 servers in production on usb disk 1To.

This script is written in bash.

Config

It use a simple bash config file (eg: /etc/backup_servers.conf), here are the default values:

  • BACKUP_DIR=""
  • SERVERS=""
  • DIRS=""
  • PARALLEL=1
  • RSYNC="rsync -au --force --numeric-ids --relative --stats"
  • RSYNC_OPT=""

Or arguments on the command line:

backup_servers --backup-dir /home/backup --dirs /etc --servers my.server.com

The variable DIRS is used by runing ls -1d DIRS on the server via ssh. Only exiting directories will be listed wich permit you to have one global directory policy for all servers. You can use as well any $(shell command) to get the list of directories passed to ls.

Example

  # /etc/backup_servers.conf:
  
  BACKUP_DIR=/home/backup
  PARALLEL=4
  SERVERS=$(mysql sys -NBe "SELECT host FROM server")
  # If you want specifics directories list per server, you can get it from a file on the server
  DIRS='$(if [ -e /etc/backup_servers.dirs ]; then cat /etc/backup_servers.dirs; else echo "/etc /home"; fi)'
  RSYNC_OPT="-z --rsync-path='nice +19 rsync' --bwlimit 1024"

You can then test your config with arguments to change values of the config file:

backup_servers --conf /etc/backup_servers.conf --servers myserver.mydomain.loc --dirs /etc --debug

Or run the backup in rsync dry mode:

backup_servers --conf /etc/backup_servers.conf -n

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.