Rsync for perfect copy: softlinks become..dir

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I do a "clone" from one mounted disk to other disk mounted remotely.
I will cal them local and remote.
Local is slackware,and remote ubuntu
On local



df -h /mnt/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/fedora-root 49G 4.3G 43G 10% /mnt


On remote



 df -h /media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29
Filesystem Size Used Avail Use% Mounted on
/dev/mmcblk1p2 57G 7.2G 47G 14% /media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29


I see rsync is not done the things properly,after use this command
from local



cd /mnt
for i in * ;do rsync -avP --delete --ignore-errors $i/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/$i; done


I see for example on local



file bin
bin: symbolic link to usr/bin


and on remote..



file /media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/bin/
/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/bin/: directory


I want bin destroyed on remote and it must become(as on local) a symbolic link
Which option for rsync?
Using:



rsync -avPl
rsync -rvPl



doesn't work







share|improve this question






















  • Did you use rsync -l?
    – DopeGhoti
    Feb 7 at 22:49










  • Of course,and don't work
    – elbarna
    Feb 7 at 22:50










  • You say "of course", and yet in your question you say you used rsync -avP; -a does not imply -l which explicitly is used to copy links as links. I have tested this for another question involving rsync yesterday and it is fresh in my mind; I am not able to replicate your stated behavior of -l not copying a link as a link.
    – DopeGhoti
    Feb 7 at 22:51











  • I have added then,the -l,options,and bin on remote,is still a dir,so don't work
    – elbarna
    Feb 7 at 23:09














up vote
0
down vote

favorite












I do a "clone" from one mounted disk to other disk mounted remotely.
I will cal them local and remote.
Local is slackware,and remote ubuntu
On local



df -h /mnt/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/fedora-root 49G 4.3G 43G 10% /mnt


On remote



 df -h /media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29
Filesystem Size Used Avail Use% Mounted on
/dev/mmcblk1p2 57G 7.2G 47G 14% /media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29


I see rsync is not done the things properly,after use this command
from local



cd /mnt
for i in * ;do rsync -avP --delete --ignore-errors $i/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/$i; done


I see for example on local



file bin
bin: symbolic link to usr/bin


and on remote..



file /media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/bin/
/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/bin/: directory


I want bin destroyed on remote and it must become(as on local) a symbolic link
Which option for rsync?
Using:



rsync -avPl
rsync -rvPl



doesn't work







share|improve this question






















  • Did you use rsync -l?
    – DopeGhoti
    Feb 7 at 22:49










  • Of course,and don't work
    – elbarna
    Feb 7 at 22:50










  • You say "of course", and yet in your question you say you used rsync -avP; -a does not imply -l which explicitly is used to copy links as links. I have tested this for another question involving rsync yesterday and it is fresh in my mind; I am not able to replicate your stated behavior of -l not copying a link as a link.
    – DopeGhoti
    Feb 7 at 22:51











  • I have added then,the -l,options,and bin on remote,is still a dir,so don't work
    – elbarna
    Feb 7 at 23:09












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I do a "clone" from one mounted disk to other disk mounted remotely.
I will cal them local and remote.
Local is slackware,and remote ubuntu
On local



df -h /mnt/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/fedora-root 49G 4.3G 43G 10% /mnt


On remote



 df -h /media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29
Filesystem Size Used Avail Use% Mounted on
/dev/mmcblk1p2 57G 7.2G 47G 14% /media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29


I see rsync is not done the things properly,after use this command
from local



cd /mnt
for i in * ;do rsync -avP --delete --ignore-errors $i/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/$i; done


I see for example on local



file bin
bin: symbolic link to usr/bin


and on remote..



file /media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/bin/
/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/bin/: directory


I want bin destroyed on remote and it must become(as on local) a symbolic link
Which option for rsync?
Using:



rsync -avPl
rsync -rvPl



doesn't work







share|improve this question














I do a "clone" from one mounted disk to other disk mounted remotely.
I will cal them local and remote.
Local is slackware,and remote ubuntu
On local



df -h /mnt/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/fedora-root 49G 4.3G 43G 10% /mnt


On remote



 df -h /media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29
Filesystem Size Used Avail Use% Mounted on
/dev/mmcblk1p2 57G 7.2G 47G 14% /media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29


I see rsync is not done the things properly,after use this command
from local



cd /mnt
for i in * ;do rsync -avP --delete --ignore-errors $i/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/$i; done


I see for example on local



file bin
bin: symbolic link to usr/bin


and on remote..



file /media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/bin/
/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/bin/: directory


I want bin destroyed on remote and it must become(as on local) a symbolic link
Which option for rsync?
Using:



rsync -avPl
rsync -rvPl



doesn't work









share|improve this question













share|improve this question




share|improve this question








edited Feb 7 at 23:47









Jeff Schaller

31.3k846105




31.3k846105










asked Feb 7 at 22:47









elbarna

3,80893477




3,80893477











  • Did you use rsync -l?
    – DopeGhoti
    Feb 7 at 22:49










  • Of course,and don't work
    – elbarna
    Feb 7 at 22:50










  • You say "of course", and yet in your question you say you used rsync -avP; -a does not imply -l which explicitly is used to copy links as links. I have tested this for another question involving rsync yesterday and it is fresh in my mind; I am not able to replicate your stated behavior of -l not copying a link as a link.
    – DopeGhoti
    Feb 7 at 22:51











  • I have added then,the -l,options,and bin on remote,is still a dir,so don't work
    – elbarna
    Feb 7 at 23:09
















  • Did you use rsync -l?
    – DopeGhoti
    Feb 7 at 22:49










  • Of course,and don't work
    – elbarna
    Feb 7 at 22:50










  • You say "of course", and yet in your question you say you used rsync -avP; -a does not imply -l which explicitly is used to copy links as links. I have tested this for another question involving rsync yesterday and it is fresh in my mind; I am not able to replicate your stated behavior of -l not copying a link as a link.
    – DopeGhoti
    Feb 7 at 22:51











  • I have added then,the -l,options,and bin on remote,is still a dir,so don't work
    – elbarna
    Feb 7 at 23:09















Did you use rsync -l?
– DopeGhoti
Feb 7 at 22:49




Did you use rsync -l?
– DopeGhoti
Feb 7 at 22:49












Of course,and don't work
– elbarna
Feb 7 at 22:50




Of course,and don't work
– elbarna
Feb 7 at 22:50












You say "of course", and yet in your question you say you used rsync -avP; -a does not imply -l which explicitly is used to copy links as links. I have tested this for another question involving rsync yesterday and it is fresh in my mind; I am not able to replicate your stated behavior of -l not copying a link as a link.
– DopeGhoti
Feb 7 at 22:51





You say "of course", and yet in your question you say you used rsync -avP; -a does not imply -l which explicitly is used to copy links as links. I have tested this for another question involving rsync yesterday and it is fresh in my mind; I am not able to replicate your stated behavior of -l not copying a link as a link.
– DopeGhoti
Feb 7 at 22:51













I have added then,the -l,options,and bin on remote,is still a dir,so don't work
– elbarna
Feb 7 at 23:09




I have added then,the -l,options,and bin on remote,is still a dir,so don't work
– elbarna
Feb 7 at 23:09










2 Answers
2






active

oldest

votes

















up vote
2
down vote













The -l (-links) option is implied by -a (--archive) but you also need -K (--keep-dirlinks) so that target directories are allowed to be symlinks. You may find that you also need --delete-before to correct the existing structure.



rsync -avKP --delete --ignore-errors src/ 192.168.0.75:dst/


Looking more closely at your original code, you're iterating across what I now see is the top level of your server, including /bin and /usr. In this instance /bin is a symlink to /usr/bin, but your code passes this to rsync with $i/, which equates to /bin/. So rsync never sees this as a symlink because your $i/ has already dereferenced it.



Removing your for loop and letting rsync handle the full directory tree itself will allow it to see the top-level symlink and transfer it correctly.






share|improve this answer






















  • sorry but doesn't work if the bin already exist on remote and is a directory
    – elbarna
    Feb 7 at 23:26











  • @elbarna please use the --delete-before option
    – roaima
    Feb 7 at 23:33










  • I used but nothing change
    – elbarna
    Feb 7 at 23:33

















up vote
0
down vote













I found a nice "workaround"



Instead of did



cd /mnt
for i in * ;do rsync -avXHhP --delete --ignore-errors $i/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/$i; done


I do



rsync --avXHhP --delete --ignore-errors /mnt/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29 ; done


And work,the dir are identical even on symlinks



Edit: I correct with -avXHhP,which is more good for backup bootable






share|improve this answer


















  • 2




    Oh I see what you were doing. In your original case rsync couldn't have seen the top level symlink because you had already dereferenced it. This is a consequence of your script, not of rsync.
    – roaima
    Feb 8 at 0:09











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422669%2frsync-for-perfect-copy-softlinks-become-dir%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













The -l (-links) option is implied by -a (--archive) but you also need -K (--keep-dirlinks) so that target directories are allowed to be symlinks. You may find that you also need --delete-before to correct the existing structure.



rsync -avKP --delete --ignore-errors src/ 192.168.0.75:dst/


Looking more closely at your original code, you're iterating across what I now see is the top level of your server, including /bin and /usr. In this instance /bin is a symlink to /usr/bin, but your code passes this to rsync with $i/, which equates to /bin/. So rsync never sees this as a symlink because your $i/ has already dereferenced it.



Removing your for loop and letting rsync handle the full directory tree itself will allow it to see the top-level symlink and transfer it correctly.






share|improve this answer






















  • sorry but doesn't work if the bin already exist on remote and is a directory
    – elbarna
    Feb 7 at 23:26











  • @elbarna please use the --delete-before option
    – roaima
    Feb 7 at 23:33










  • I used but nothing change
    – elbarna
    Feb 7 at 23:33














up vote
2
down vote













The -l (-links) option is implied by -a (--archive) but you also need -K (--keep-dirlinks) so that target directories are allowed to be symlinks. You may find that you also need --delete-before to correct the existing structure.



rsync -avKP --delete --ignore-errors src/ 192.168.0.75:dst/


Looking more closely at your original code, you're iterating across what I now see is the top level of your server, including /bin and /usr. In this instance /bin is a symlink to /usr/bin, but your code passes this to rsync with $i/, which equates to /bin/. So rsync never sees this as a symlink because your $i/ has already dereferenced it.



Removing your for loop and letting rsync handle the full directory tree itself will allow it to see the top-level symlink and transfer it correctly.






share|improve this answer






















  • sorry but doesn't work if the bin already exist on remote and is a directory
    – elbarna
    Feb 7 at 23:26











  • @elbarna please use the --delete-before option
    – roaima
    Feb 7 at 23:33










  • I used but nothing change
    – elbarna
    Feb 7 at 23:33












up vote
2
down vote










up vote
2
down vote









The -l (-links) option is implied by -a (--archive) but you also need -K (--keep-dirlinks) so that target directories are allowed to be symlinks. You may find that you also need --delete-before to correct the existing structure.



rsync -avKP --delete --ignore-errors src/ 192.168.0.75:dst/


Looking more closely at your original code, you're iterating across what I now see is the top level of your server, including /bin and /usr. In this instance /bin is a symlink to /usr/bin, but your code passes this to rsync with $i/, which equates to /bin/. So rsync never sees this as a symlink because your $i/ has already dereferenced it.



Removing your for loop and letting rsync handle the full directory tree itself will allow it to see the top-level symlink and transfer it correctly.






share|improve this answer














The -l (-links) option is implied by -a (--archive) but you also need -K (--keep-dirlinks) so that target directories are allowed to be symlinks. You may find that you also need --delete-before to correct the existing structure.



rsync -avKP --delete --ignore-errors src/ 192.168.0.75:dst/


Looking more closely at your original code, you're iterating across what I now see is the top level of your server, including /bin and /usr. In this instance /bin is a symlink to /usr/bin, but your code passes this to rsync with $i/, which equates to /bin/. So rsync never sees this as a symlink because your $i/ has already dereferenced it.



Removing your for loop and letting rsync handle the full directory tree itself will allow it to see the top-level symlink and transfer it correctly.







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 8 at 13:10

























answered Feb 7 at 23:20









roaima

39.6k545108




39.6k545108











  • sorry but doesn't work if the bin already exist on remote and is a directory
    – elbarna
    Feb 7 at 23:26











  • @elbarna please use the --delete-before option
    – roaima
    Feb 7 at 23:33










  • I used but nothing change
    – elbarna
    Feb 7 at 23:33
















  • sorry but doesn't work if the bin already exist on remote and is a directory
    – elbarna
    Feb 7 at 23:26











  • @elbarna please use the --delete-before option
    – roaima
    Feb 7 at 23:33










  • I used but nothing change
    – elbarna
    Feb 7 at 23:33















sorry but doesn't work if the bin already exist on remote and is a directory
– elbarna
Feb 7 at 23:26





sorry but doesn't work if the bin already exist on remote and is a directory
– elbarna
Feb 7 at 23:26













@elbarna please use the --delete-before option
– roaima
Feb 7 at 23:33




@elbarna please use the --delete-before option
– roaima
Feb 7 at 23:33












I used but nothing change
– elbarna
Feb 7 at 23:33




I used but nothing change
– elbarna
Feb 7 at 23:33












up vote
0
down vote













I found a nice "workaround"



Instead of did



cd /mnt
for i in * ;do rsync -avXHhP --delete --ignore-errors $i/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/$i; done


I do



rsync --avXHhP --delete --ignore-errors /mnt/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29 ; done


And work,the dir are identical even on symlinks



Edit: I correct with -avXHhP,which is more good for backup bootable






share|improve this answer


















  • 2




    Oh I see what you were doing. In your original case rsync couldn't have seen the top level symlink because you had already dereferenced it. This is a consequence of your script, not of rsync.
    – roaima
    Feb 8 at 0:09















up vote
0
down vote













I found a nice "workaround"



Instead of did



cd /mnt
for i in * ;do rsync -avXHhP --delete --ignore-errors $i/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/$i; done


I do



rsync --avXHhP --delete --ignore-errors /mnt/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29 ; done


And work,the dir are identical even on symlinks



Edit: I correct with -avXHhP,which is more good for backup bootable






share|improve this answer


















  • 2




    Oh I see what you were doing. In your original case rsync couldn't have seen the top level symlink because you had already dereferenced it. This is a consequence of your script, not of rsync.
    – roaima
    Feb 8 at 0:09













up vote
0
down vote










up vote
0
down vote









I found a nice "workaround"



Instead of did



cd /mnt
for i in * ;do rsync -avXHhP --delete --ignore-errors $i/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/$i; done


I do



rsync --avXHhP --delete --ignore-errors /mnt/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29 ; done


And work,the dir are identical even on symlinks



Edit: I correct with -avXHhP,which is more good for backup bootable






share|improve this answer














I found a nice "workaround"



Instead of did



cd /mnt
for i in * ;do rsync -avXHhP --delete --ignore-errors $i/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29/$i; done


I do



rsync --avXHhP --delete --ignore-errors /mnt/ 192.168.0.75:/media/ubuntu/1c34a414-9fa2-4bfe-a57c-7f82f1b31b29 ; done


And work,the dir are identical even on symlinks



Edit: I correct with -avXHhP,which is more good for backup bootable







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 8 at 0:28

























answered Feb 7 at 23:34









elbarna

3,80893477




3,80893477







  • 2




    Oh I see what you were doing. In your original case rsync couldn't have seen the top level symlink because you had already dereferenced it. This is a consequence of your script, not of rsync.
    – roaima
    Feb 8 at 0:09













  • 2




    Oh I see what you were doing. In your original case rsync couldn't have seen the top level symlink because you had already dereferenced it. This is a consequence of your script, not of rsync.
    – roaima
    Feb 8 at 0:09








2




2




Oh I see what you were doing. In your original case rsync couldn't have seen the top level symlink because you had already dereferenced it. This is a consequence of your script, not of rsync.
– roaima
Feb 8 at 0:09





Oh I see what you were doing. In your original case rsync couldn't have seen the top level symlink because you had already dereferenced it. This is a consequence of your script, not of rsync.
– roaima
Feb 8 at 0:09













 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422669%2frsync-for-perfect-copy-softlinks-become-dir%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay