Giter Club home page Giter Club logo

hrsync's Introduction

hrsync

A shell script showing how to backup a directory with rsync detecting moved and renamed files.

Rsync is a great tool but lack detection of moved and renamed files, with this simple script is possible to avoid transfer of files which were only moved around or renamed.

The basic idea is to create a tree (inside source directory) of hard linked files representing the original filesystem structure of the source itself, letting rsync recostructing links in the initial phase of the transfer. After the initial run you will find a new directory (.rsync_shadow) inside source and target directories, please don't touch the tree inside if you want that the script will continue working.

Credits due to this brilliant article: Detecting File Moves & Renames with Rsync.

Some background info in this serverfault question: Handling renamed files or directories in rsync

I provide only this README as documentation. If you want to know more just look at the source code, it's really short!

Requirements

  • rsync >= 3.0 (on remote host also if you use remote target)
  • filesystem with support for hard links on both sides
  • source and target directory should be on different devices
  • source on local filesystem and optionally target on remote (via ssh)

Usage

  1. Both source and target on local filesystem: run the script with source and target directories as arguments:
cd <dir>
chmod +x ./hrsync
./hrsync /home/user/Documents /media/user/external/Documents
  1. Source on local filesystem and target on remote host (via ssh): run the script with source, target and remote host arguments:
cd <dir>
chmod +x ./hrsync
./hrsync /home/user/Documents /root/Documents [email protected]

Do your work on the source directory: add, delete and move files, then rerun the script. Target directory will be synced without transferring moved or renamed files.

Please note that this script is to be considered only an example, feel free to extend the idea for your own backup solution. Use it at your own risk, this is alpha software provided "as is" without any warranty in any case.

License

hrsync is © 2014 Daniele Paroli. It is free software, and may be redistributed under the terms specified in the LICENSE file.

hrsync's People

Contributors

dparoli avatar josef-friedrich avatar mmitch avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hrsync's Issues

documentation/clarification: how to implement hrsync from remote (only)

I found your idea/script very intreaging and would like to use it myself for my backup. Please excuse me raising an issue, I could not find any other way of contacting you.

currently the backup works like this:

  • files on remote (source) - device at home
  • backup on local (target) - device not at home
  • ta bash script on target, pulling the data from remote
  • rsync is connecting to remote via rsync module, not ssh

now, when I try to create source shadow it wont work because rsync cant handle remote target and source: "The source and destination cannot both be remote"

how did you overcome this? not using modules? only use rsync local? special rsync?

There are problems of using ssh (both systems are embedded NAS devices and I rather would not implement ssh-login via cert since it will break sooner or later when an update is installed)
It is also not viable to push the files from source to target since target needs to be in control of when to pull files

And I dont see much sense in creating the shadow dirs locally when the update is the important part and wont work because source/destination would be remote again...
Besides, running multiple scripts on different machines in the hope that they all start and finnish just right is asking for trouble...

Internet backup

Hi

I've tried to modify your script to perform backup over internet using ssh. No sucess,, so I guess that I dont fully understand your script.

Can you give me a hint how to do it??

Regards
lg

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.