0

I have a numbers of files and dirs under /data. I want to use rsync to create hardlinks in a backups directory. The /data/dir_1 ... dir_n/backups already exits.

Starting point...
/data/dir_1 ... dir_n/file_1 ... file_n

Ending point...
/data/dir_1 ... dir_n/backups/dir_1 ... dir_n/file_1 ... file_n (hardlinks back to /data/dir_1 ... dir_n/file_1 ... file_n)

Is this possible with just rsync?

Is this possible with just rsync and recursion to replicate for an entire directory hierarchy?

jww
  • 97,681
  • 90
  • 411
  • 885
kalaolani
  • 323
  • 1
  • 16
  • 1
    StackOverflow's scope is questions about *software development*. For questions about command-line usage of UNIX tools, consider [unix.se]. – Charles Duffy Feb 17 '18 at 22:30
  • The software I'm developing has this requirement. I wonder why there are Cassandra Operations questions on StackOverflow? This is an example of a reason why a friend of mine has told me to quit using StackOverflow. Software developers ought to know this stuff too. Thanks for the down vote. It's much appreciated. Cheers sir. – kalaolani Feb 17 '18 at 23:12
  • There this example.. https://stackoverflow.com/questions/984204/shell-command-to-tar-directory-excluding-certain-files-folders?rq=1 – kalaolani Feb 17 '18 at 23:13
  • And this one... https://stackoverflow.com/questions/11887766/rsync-create-symbolic-links-only?rq=1 – kalaolani Feb 17 '18 at 23:14
  • 2
    (1) Don't assume that the people commenting and the people downvoting are one and the same -- the downvote you thanked me for was not mine. (2) Site rules change over time. Just because something slipped through in the past doesn't make it acceptable; the only canonical sources for current site rules are the Help Center and consensus on meta. (3) It doesn't matter if a question is about something a developer "ought to know". The wording is *unique to software development* -- ie. it should be something but nobody *except* software developers needs to know. – Charles Duffy Feb 17 '18 at 23:40
  • ...to be clear re: source for said wording -- see https://stackoverflow.com/help/on-topic, fourth bullet point, and note that it's an "and", not an "or", connecting that to the other criteria. – Charles Duffy Feb 17 '18 at 23:41
  • 2
    Indeed... you are correct. That was indeed a bad assumption on my part. I will keep that in mind in the future Charles. My apologies for allowing my work stress to seep into StackOverflow and on to you. Per your suggestion, I've joined Unix & Linux StageExchange. Thank you for taking the time to explain. It is sincerely appreciated. – kalaolani Feb 17 '18 at 23:43

1 Answers1

5
rsync -av --link-dest=src_dir src_dir/ new_dir/
pts
  • 80,836
  • 20
  • 110
  • 183
  • Deleted my "non-answer" because this is the answer. Cheers. – kalaolani Feb 17 '18 at 23:28
  • 1
    Could try an rsync wrapper, if you want more than one such link tree for backup purposes: http://stromberg.dnsalias.org/~strombrg/Backup.remote.html#rsync – dstromberg Feb 18 '18 at 00:43