rsync without deleting between 2 folders

i'm looking for a command that can sync dir1 and dir2, without swapping and deleting the files in those directories.

The current command i'm using is

rsync -av --delete dir1 dir2

which deletes files that belong to dir2 but not dir1. In other words, it will create a duplicate dir1 in a fast way.

say, for example, i add 5 files to dir2 and would like to preserve the order of the command rsync. i want to sync it back to dir1. what options of rsync are available that can help me doing this?

assume i don't want to delete any files in both directories.

2

1 Answer

You can you this command

if [ -n "$(rsync -anv --delete dir1/ dir2/ | grep deleting)" ]; then \ rsync -av dir2/ dir1/; else rsync -av dir1/ dir2/; fi

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like