The Computer Oracle

Can I hard link files with rsync instead of copying them?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Magic Ocean Looping

--

Chapters
00:00 Can I Hard Link Files With Rsync Instead Of Copying Them?
00:32 Accepted Answer Score 26
01:04 Answer 2 Score 2
01:14 Thank you

--

Full question
https://superuser.com/questions/1360525/...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #rsync #cp #hardlink #incrementalbackup

#avk47



ACCEPTED ANSWER

Score 26


The answer has turned out to be yes, with rsync's --link-dest option. It's just not obvious because it's not a simple on/off flag like cp -l, because it takes a path argument.

So, cp -l a/ b/ can also be done like this:

rsync  -a  --link-dest=../a  a/  b/

Note that the destination needs to be ../a, because the path is relative to the relative to the target directory.
(So if you were syncing to b/c/, it would be ../../a.)




ANSWER 2

Score 2


I've been using https://github.com/rsnapshot/rsnapshot for a long time. It does exactly what you are describing.