Can I hard link files with rsync instead of copying them?
--------------------------------------------------
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Forest of Spells Looping
--
Chapters
00:00 Question
00:43 Accepted answer (Score 26)
01:22 Answer 2 (Score 2)
01:36 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
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Forest of Spells Looping
--
Chapters
00:00 Question
00:43 Accepted answer (Score 26)
01:22 Answer 2 (Score 2)
01:36 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.