This question already has an answer here:
I'm working on a system to automatically back up my computer using
rsync and the Google Drive app (I have a Macintosh computer). (This app creates a directory whose contents are saved to the Google Drive cloud.) The idea of the backup system is to (automatically) copy files to the Google Drive directory (using
rsync, preferably) then upload the directory to the cloud.
This system has a major drawback, however: memory waste. Every file that I backup has to be copied to a second location in my computer, doubling the space the file uses. It would be much more memory efficient to make hard links instead of copies. I would like to duplicate my directory tree using hard links, then update the duplicate when the original changes.
Can I use
rsync to make hard links instead of copies? I think this might be possible with the
link--dest= option, but I can't figure it out.
Edit: A few clarifications, in response to feedback.
- This question has been listed as a duplicate of rsync --link-dest not working as expected with symlinks. I don't understand why the questions are the same. I gather that the similarity has to do with using the
--link-dest=option to create hardlinks. But this is what I don't understand how to do! So I'm not satisfied with the duplicate question. It seems like using
--link-dest=to make hardlinks only works if you already have a backup to compare it to.
- I'm not computer proficient compared to the users of this site. If the answer to my question is something like "this is easy, just read the man page for
rsyncmore carefully" or something like that, I'll do it.
- I'm perfectly happy using some other bash utility to achieve the functionality I'm looking for! I just happen to like
rsync, but I'm open to other options. JdeBP has suggested using
pax, for example.