0

I need to copy directory structure from one place to another. I need to copy only folders and symlinks.

I use command

find $SOURCE_PATH/ \( -type l -o -type d \)  -printf "%P\0" | rsync --files-from - --from0 -av  $SOURCE_PATH $USER@$DESTINATION_SERVER:/$DESTINATION_PATH/$SOURCE_PATH

Command is successful and it copy folder and links. My problem is because links point to the old destination.
my source path is app/cg/dev and destination path is tmp/app/cg/dev and now my links which i copied are pointing to app/cg/dev/somefolder . i need them to point on tmp/app/cg/dev/somefolder.

After i rsync all links, good way to correct them would be if i could read link path and than just concatenate my destination path. example

find . -type l | while read l; do
concatenate destination folder and readlink l
done

can someone help me write that code?

6
  • Did the original symlinks point to an absolute or relative path? Commented Sep 25, 2020 at 9:20
  • @AdminBee absolute, i rsync that structure, that folders and links are connected Commented Sep 25, 2020 at 10:36
  • Maybe you could convert absolute symbolic links to relative ones in the source and then recopy? Commented Sep 25, 2020 at 10:43
  • @roaima no i cannot do that. is there maybe option that instead rsync i create new link Commented Sep 25, 2020 at 11:39
  • Several of the answers on that link I've provided do seem to handle conversion of the symlinks in the manner that you say you need Commented Sep 25, 2020 at 12:16

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.