Coder Social home page Coder Social logo

rsync-time-machine's Introduction

Rsync Time Machine

I have been use Back In Time as time machine style backup for several years. It worked very well until I recently need to take periodical snapshots for a file server. Backintime cannot directly backup the remote machine, it must mount remote via sshfs, which is less efficient than running rsync through ssh, hence this script.

Features

  • Backup from remote host by running rsync through ssh.
  • Backup from local directories.
  • Support multiple source directories.
  • Use hardlinks to save space.
  • Smart remove old backups to emulate Apple Time Machine.
  • Easy to config multiple backup profiles.

This script does not attempt to remove old snapshots if there lacks enough free space.

Requirement

  • Python.
  • The backup destination file system must support hardlinks.
  • Rsync must be installed on the remote host if it is the backup source.

Usage

time-machine.py -c mybackup.conf

See time-machine.conf for config example. The config file splits into five sections:

  1. source: the backup source.

  2. dest: a local path to store all snapshots.

  3. smart_remove: specify how to keep old backups. It recognizes four options.

     keep_all
     keep_one_per_day
     keep_one_per_week
     keep_one_per_month
    

    The default values will be used if these options is empty or commented out.

  4. exclude: the rsync exclude patterns.

  5. free space: the minimum free space and inodes requirements. Backup will not start if there is not enough space or inodes. Again, default value will be used if option is not set.

Snapshots are named after GMT time stamp. A log file, time-machine.log, is generated under the root of backup destination folder. After run a backup job periodically for some time, the backup folder should look like:

├── 2013-12-31_22:17:01_GMT
├── 2014-12-31_22:17:01_GMT
├── 2015-05-31_22:17:01_GMT
├── 2015-06-30_22:17:01_GMT
├── 2015-07-31_22:17:01_GMT
├── 2015-08-31_22:17:01_GMT
├── 2015-09-30_22:17:01_GMT
├── 2015-10-31_22:17:01_GMT
├── 2015-11-30_22:17:01_GMT
├── 2015-12-31_22:17:01_GMT
├── 2016-01-31_22:17:01_GMT
├── 2016-02-29_22:17:01_GMT
├── 2016-03-20_22:17:01_GMT
├── 2016-03-27_22:17:01_GMT
├── 2016-03-31_22:17:01_GMT
├── 2016-04-03_22:17:01_GMT
├── 2016-04-04_22:17:01_GMT
├── 2016-04-05_22:17:01_GMT
├── 2016-04-06_22:17:01_GMT
├── 2016-04-07_22:17:01_GMT
├── 2016-04-08_10:17:01_GMT
├── 2016-04-08_12:17:01_GMT
├── 2016-04-08_14:17:01_GMT
├── 2016-04-08_16:17:01_GMT
├── 2016-04-08_18:17:01_GMT
├── 2016-04-08_20:17:01_GMT
├── 2016-04-08_22:17:01_GMT
├── 2016-04-09_00:17:01_GMT
├── 2016-04-09_02:17:01_GMT
├── 2016-04-09_04:17:01_GMT
├── 2016-04-09_06:17:01_GMT
├── 2016-04-09_08:17:01_GMT
├── 2016-04-09_10:17:01_GMT
├── latest -> /my/backup/destination/time-capsule/2016-04-09_10:14:13_GMT
└── time-machine.log

There is also a small tool for comparing snapshots. Files from two snapshots that share same inodes are considered unchanged. Execute make to compile then run:

cmpdir old-snapshot-directory new-snapshot-directory

License

See the LICENSE file for license rights and limitations (GNU GPL v2).

rsync-time-machine's People

Contributors

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