0

I work on two different computers and want to keep certain directories synced between the computers. For example, I have a ~/scripts folder that has a lot of commonly used scripts in it. If I make a new script or modify a script on one computer, I want to make sure that change is sync'ed to the other computer.

The problem should be obvious: what happens when a file is added or deleted?

Since rsync does not know if the file has been added or deleted, the wrong behavior could occur and a valuable file with a lot of work in it could be deleted.

For example, let's say that I have files 1 and 2 on both machines and then working on machine A I add file 3, but for whatever reason I don't rsync. Later the same day I am working on machine B and run rsync. Since machine B lacks file 3, when I run rsync it will assume that B used to have 3 on it, but I deleted it, so it will delete file 3 on machine A, potentially destroying a lot of work.

It is not practical to try to sync after each time I add a file, because I will be busy doing things and forget sometimes.

The alternative is to never delete files while rsyncing, but then there will be proliferation of unwanted files. In this case, the only solution would be to have some kind of special delete command that would delete a file on both machines at the same time. But the problem here is that I have directories with automatically created files, like development directories where the compiler and makefiles are automatically creating and deleting files. If these directories are rsynced with no deletes, then there will be file proliferation.

How can I solve this problem?

Tyler Durden
  • 5,631

0 Answers0