bi-directional sync with rsync
up vote
6
down vote
favorite
I am trying to setup bi-direction or two way sync with rsync. In my case I only need to delete the files when syncing from B to A. So, I was thinking of running rsync twice as follow :
rsync -rtuv ./A/ ./B/
rsync -rtuv --delete ./B/ ./A/
This problem with this solution is that when I run rsync (B->A) which would be right after running the rsync (A-B), Any new file that get created in between the sync will also get removed.
Is there a way I can specify a time stamp as condition that it only delete the file if it created before this date/time.
Updated:
I understand there is a unison solution but the problem with unison is required to install on both ends. I am syncing with a remote server and I can not install unison on the remote end.
rsync synchronization
add a comment |
up vote
6
down vote
favorite
I am trying to setup bi-direction or two way sync with rsync. In my case I only need to delete the files when syncing from B to A. So, I was thinking of running rsync twice as follow :
rsync -rtuv ./A/ ./B/
rsync -rtuv --delete ./B/ ./A/
This problem with this solution is that when I run rsync (B->A) which would be right after running the rsync (A-B), Any new file that get created in between the sync will also get removed.
Is there a way I can specify a time stamp as condition that it only delete the file if it created before this date/time.
Updated:
I understand there is a unison solution but the problem with unison is required to install on both ends. I am syncing with a remote server and I can not install unison on the remote end.
rsync synchronization
add a comment |
up vote
6
down vote
favorite
up vote
6
down vote
favorite
I am trying to setup bi-direction or two way sync with rsync. In my case I only need to delete the files when syncing from B to A. So, I was thinking of running rsync twice as follow :
rsync -rtuv ./A/ ./B/
rsync -rtuv --delete ./B/ ./A/
This problem with this solution is that when I run rsync (B->A) which would be right after running the rsync (A-B), Any new file that get created in between the sync will also get removed.
Is there a way I can specify a time stamp as condition that it only delete the file if it created before this date/time.
Updated:
I understand there is a unison solution but the problem with unison is required to install on both ends. I am syncing with a remote server and I can not install unison on the remote end.
rsync synchronization
I am trying to setup bi-direction or two way sync with rsync. In my case I only need to delete the files when syncing from B to A. So, I was thinking of running rsync twice as follow :
rsync -rtuv ./A/ ./B/
rsync -rtuv --delete ./B/ ./A/
This problem with this solution is that when I run rsync (B->A) which would be right after running the rsync (A-B), Any new file that get created in between the sync will also get removed.
Is there a way I can specify a time stamp as condition that it only delete the file if it created before this date/time.
Updated:
I understand there is a unison solution but the problem with unison is required to install on both ends. I am syncing with a remote server and I can not install unison on the remote end.
rsync synchronization
rsync synchronization
edited Jan 19 '16 at 16:34
asked Jan 18 '16 at 17:16
Raza
2,58241923
2,58241923
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
You could try osync which is designed for exactly this task. I once set up a complex sequence of rsync commands to do the job, but I now use osync.
https://github.com/deajan/osync
It uses rsync internally, so it should be suitable for any situation where you could use rsync.
1
Thanks, Mark. I was just about to answer my own question. I found very similar script called bsync (github.com/dooblem/bsync) basically it uses diff to figure out whats need to be sync. Since I am not expecting any conflicts in sync, I also modify this script a little so it run silently when runs with a cron job.
– Raza
Jan 19 '16 at 17:25
add a comment |
up vote
4
down vote
rsync
is the wrong tool for this task, for exactly the reasons that you have encountered. Instead, consider using unison
:
unison A/ B/
The first time you run this it will identify files that are uniquely in A
, and those that are uniquely in B
. It will also flag those that are in both places and ask you to identify which is to be overwritten.
The next time you run this it will copy changes from A
to B
and also B
to A
, flagging any files that have been changed in both places for manual resolution.
mkdir A B
date > A/date
who > B/who
unison A/ B/
# Lots of output from unison, showing synchronisation
ls A
date who
ls B
date who
date > A/date
unison A/ B/
# Lots of output from unison, showing synchronisation
There are a number of useful flags available for unison
which help automate the process by defining assumptions and thereby reducing the number of questions you're asked during the synchronisation.
2
I saw unison solution but the problem with that is I am required to install on both end. I am syncing with a remote and I can not install unison on the remote end.
– Raza
Jan 19 '16 at 16:14
1
It doesn't help the OP, but I was looking for unison. I see there are Debian packages and it supports ssh transport.
– Ted
Jan 2 '17 at 18:22
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You could try osync which is designed for exactly this task. I once set up a complex sequence of rsync commands to do the job, but I now use osync.
https://github.com/deajan/osync
It uses rsync internally, so it should be suitable for any situation where you could use rsync.
1
Thanks, Mark. I was just about to answer my own question. I found very similar script called bsync (github.com/dooblem/bsync) basically it uses diff to figure out whats need to be sync. Since I am not expecting any conflicts in sync, I also modify this script a little so it run silently when runs with a cron job.
– Raza
Jan 19 '16 at 17:25
add a comment |
up vote
3
down vote
accepted
You could try osync which is designed for exactly this task. I once set up a complex sequence of rsync commands to do the job, but I now use osync.
https://github.com/deajan/osync
It uses rsync internally, so it should be suitable for any situation where you could use rsync.
1
Thanks, Mark. I was just about to answer my own question. I found very similar script called bsync (github.com/dooblem/bsync) basically it uses diff to figure out whats need to be sync. Since I am not expecting any conflicts in sync, I also modify this script a little so it run silently when runs with a cron job.
– Raza
Jan 19 '16 at 17:25
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You could try osync which is designed for exactly this task. I once set up a complex sequence of rsync commands to do the job, but I now use osync.
https://github.com/deajan/osync
It uses rsync internally, so it should be suitable for any situation where you could use rsync.
You could try osync which is designed for exactly this task. I once set up a complex sequence of rsync commands to do the job, but I now use osync.
https://github.com/deajan/osync
It uses rsync internally, so it should be suitable for any situation where you could use rsync.
answered Jan 19 '16 at 16:53
Mark Perryman
513310
513310
1
Thanks, Mark. I was just about to answer my own question. I found very similar script called bsync (github.com/dooblem/bsync) basically it uses diff to figure out whats need to be sync. Since I am not expecting any conflicts in sync, I also modify this script a little so it run silently when runs with a cron job.
– Raza
Jan 19 '16 at 17:25
add a comment |
1
Thanks, Mark. I was just about to answer my own question. I found very similar script called bsync (github.com/dooblem/bsync) basically it uses diff to figure out whats need to be sync. Since I am not expecting any conflicts in sync, I also modify this script a little so it run silently when runs with a cron job.
– Raza
Jan 19 '16 at 17:25
1
1
Thanks, Mark. I was just about to answer my own question. I found very similar script called bsync (github.com/dooblem/bsync) basically it uses diff to figure out whats need to be sync. Since I am not expecting any conflicts in sync, I also modify this script a little so it run silently when runs with a cron job.
– Raza
Jan 19 '16 at 17:25
Thanks, Mark. I was just about to answer my own question. I found very similar script called bsync (github.com/dooblem/bsync) basically it uses diff to figure out whats need to be sync. Since I am not expecting any conflicts in sync, I also modify this script a little so it run silently when runs with a cron job.
– Raza
Jan 19 '16 at 17:25
add a comment |
up vote
4
down vote
rsync
is the wrong tool for this task, for exactly the reasons that you have encountered. Instead, consider using unison
:
unison A/ B/
The first time you run this it will identify files that are uniquely in A
, and those that are uniquely in B
. It will also flag those that are in both places and ask you to identify which is to be overwritten.
The next time you run this it will copy changes from A
to B
and also B
to A
, flagging any files that have been changed in both places for manual resolution.
mkdir A B
date > A/date
who > B/who
unison A/ B/
# Lots of output from unison, showing synchronisation
ls A
date who
ls B
date who
date > A/date
unison A/ B/
# Lots of output from unison, showing synchronisation
There are a number of useful flags available for unison
which help automate the process by defining assumptions and thereby reducing the number of questions you're asked during the synchronisation.
2
I saw unison solution but the problem with that is I am required to install on both end. I am syncing with a remote and I can not install unison on the remote end.
– Raza
Jan 19 '16 at 16:14
1
It doesn't help the OP, but I was looking for unison. I see there are Debian packages and it supports ssh transport.
– Ted
Jan 2 '17 at 18:22
add a comment |
up vote
4
down vote
rsync
is the wrong tool for this task, for exactly the reasons that you have encountered. Instead, consider using unison
:
unison A/ B/
The first time you run this it will identify files that are uniquely in A
, and those that are uniquely in B
. It will also flag those that are in both places and ask you to identify which is to be overwritten.
The next time you run this it will copy changes from A
to B
and also B
to A
, flagging any files that have been changed in both places for manual resolution.
mkdir A B
date > A/date
who > B/who
unison A/ B/
# Lots of output from unison, showing synchronisation
ls A
date who
ls B
date who
date > A/date
unison A/ B/
# Lots of output from unison, showing synchronisation
There are a number of useful flags available for unison
which help automate the process by defining assumptions and thereby reducing the number of questions you're asked during the synchronisation.
2
I saw unison solution but the problem with that is I am required to install on both end. I am syncing with a remote and I can not install unison on the remote end.
– Raza
Jan 19 '16 at 16:14
1
It doesn't help the OP, but I was looking for unison. I see there are Debian packages and it supports ssh transport.
– Ted
Jan 2 '17 at 18:22
add a comment |
up vote
4
down vote
up vote
4
down vote
rsync
is the wrong tool for this task, for exactly the reasons that you have encountered. Instead, consider using unison
:
unison A/ B/
The first time you run this it will identify files that are uniquely in A
, and those that are uniquely in B
. It will also flag those that are in both places and ask you to identify which is to be overwritten.
The next time you run this it will copy changes from A
to B
and also B
to A
, flagging any files that have been changed in both places for manual resolution.
mkdir A B
date > A/date
who > B/who
unison A/ B/
# Lots of output from unison, showing synchronisation
ls A
date who
ls B
date who
date > A/date
unison A/ B/
# Lots of output from unison, showing synchronisation
There are a number of useful flags available for unison
which help automate the process by defining assumptions and thereby reducing the number of questions you're asked during the synchronisation.
rsync
is the wrong tool for this task, for exactly the reasons that you have encountered. Instead, consider using unison
:
unison A/ B/
The first time you run this it will identify files that are uniquely in A
, and those that are uniquely in B
. It will also flag those that are in both places and ask you to identify which is to be overwritten.
The next time you run this it will copy changes from A
to B
and also B
to A
, flagging any files that have been changed in both places for manual resolution.
mkdir A B
date > A/date
who > B/who
unison A/ B/
# Lots of output from unison, showing synchronisation
ls A
date who
ls B
date who
date > A/date
unison A/ B/
# Lots of output from unison, showing synchronisation
There are a number of useful flags available for unison
which help automate the process by defining assumptions and thereby reducing the number of questions you're asked during the synchronisation.
edited Dec 5 at 23:34
Sparhawk
9,09063889
9,09063889
answered Jan 18 '16 at 22:56
roaima
42.3k551116
42.3k551116
2
I saw unison solution but the problem with that is I am required to install on both end. I am syncing with a remote and I can not install unison on the remote end.
– Raza
Jan 19 '16 at 16:14
1
It doesn't help the OP, but I was looking for unison. I see there are Debian packages and it supports ssh transport.
– Ted
Jan 2 '17 at 18:22
add a comment |
2
I saw unison solution but the problem with that is I am required to install on both end. I am syncing with a remote and I can not install unison on the remote end.
– Raza
Jan 19 '16 at 16:14
1
It doesn't help the OP, but I was looking for unison. I see there are Debian packages and it supports ssh transport.
– Ted
Jan 2 '17 at 18:22
2
2
I saw unison solution but the problem with that is I am required to install on both end. I am syncing with a remote and I can not install unison on the remote end.
– Raza
Jan 19 '16 at 16:14
I saw unison solution but the problem with that is I am required to install on both end. I am syncing with a remote and I can not install unison on the remote end.
– Raza
Jan 19 '16 at 16:14
1
1
It doesn't help the OP, but I was looking for unison. I see there are Debian packages and it supports ssh transport.
– Ted
Jan 2 '17 at 18:22
It doesn't help the OP, but I was looking for unison. I see there are Debian packages and it supports ssh transport.
– Ted
Jan 2 '17 at 18:22
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f256128%2fbi-directional-sync-with-rsync%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown