A couple of questions about using rsync?

I cannot find a reliable file synchronization program for my Mac, so I used the Rsync command line between two folders.

I am using "rsync -r destination source".

- Uses these synchronization files in both directions or only synchronizes the source with the destination? -If the file was previously synchronized between two folders, but deleted because it is no longer needed, is it deleted for both the source and the destination, or will it always be copied to where it is missing?

+4
source share
2 answers

No, rsync synchronizes the contents of the remote directory with the local directory. In this regard, this is a one-way approach. If you wish, you can force delete local files that no longer exist in the remote folder.

If you want to save the most recent changes on both machines, you will need to provide a more complex rsync spell and configure both machines as rsync servers. I suppose this will lead to troubles in the end, especially if you want to be authoritarian about removal.

In either case, you can use the -u option (or --update ), which skips any files that are newer at the endpoint. You need to worry about timestamps and this will not handle conflicts or merges. However ... It could be that simple:

 rsync -u -r target1 target2 rsync -u -r target2 target1 

This will not do anything about the exception. You have no way of knowing that a missing file on one target was deleted there instead of a new file that was created on another target.

That's why the version control was created ... And for people who are afraid of version control, there are services like DropBox.

+4
source

The answer to the original question:

1) It only synchronizes files in one direction, depending on the pull or push mechanism. for the push and pull mechanism, see the manual page on the "man rsync" page.

therefore, for the rest of your question, do not assume that it works as if in a way.

2) The file is deleted only in the destination directory. For more information about this, use the rsync --help command, see the --delete option, which removes extraneous files from target servers and other options for deletion.

3) Invalid files will only be copied to the destination directory if you click files on a remote computer / directory /

example example for the push mechanism: -

 rsync -avz /home/local_dir/abc.txt remoteuser@192.168.xx.xx :/home/remoteuser/ 

if a file with the name abc.txt is already present in the target directory, then it will be updated depending on the old version of abc.txt on the local side or not. And if abc.txt is not in the remote directory, a complete new file will be created called abc.txt with the contents of the local version of abc.txt

sample example for traction mechanism: -

 rsync -avz remoteuser@192.168.xx.xx :/home/remoteuser/abc.txt /home/local_dir/ 

if a file with the name abc.txt is already present in the local directory, then it will be updated depending on the old version of abc.txt on the side or not. And if abc.txt is not in the local directory, a complete new file will be created called abc.txt with the contents of the local version of abc.txt

+1
source

All Articles