How to copy junction as-is instead of the folder it points to?
Asked Answered
P

3

9

I copy set of folders from server 1 to server 2. Amongst files I also have junction: folder with set of config files: on server 1 this junction points to... let's say c:\Config (that contains config1.cfg, config2.cfg)

On server 2 I also have c:\Config with the same set of files, but of course they contains their own settings that I do not want to overwrite.

So what I want to do is to copy junction AS-IS. Instead, I get copies of config1.cfg and config2.cfg from server 1 :(

How to solve this problem??

p.s.1. it's long to explain, but I cannot avoid of using junctions here (it has something to do with limitation of where configuration must be placed (subfolder-'junction' points to 'outside' folder))

p.s.2. OS is Windows Server 2003

Polychrome answered 12/11, 2009 at 17:30 Comment(3)
This isn't really a programming question.Censor
Sorry, i was not aware that only programming-related questions could be asked on stackoverflow. However, i can see tons of questions here, that are not related to programming... So what you were going to say was 'Nobody will reply to you here, don't waste your time'. Right? If so - thank you very much!Polychrome
you can use 7zip with tar method, it will convert junction to symbolic, is it acceptable? please check superuser.com/questions/128969/symbolic-links-and-7zip/…Hydrostat
C
0

Copying junctions don't make any sense from drive to drive - a junction points to a specific node on disk. What you really want is a Symlink, which points to a specific path in the filesystem, but unfortunately this doesn't exist on Server 2003. You're out of luck here, you'll have to just fix this up in a post-copy script.

Corvese answered 15/11, 2009 at 18:24 Comment(2)
I think he wants to copy the junction itself. So in other words to create a new junction that points to the same place as the old junction, instead of copying the junction target as a new folder.Perutz
The problem is that symlinks will also create deep-copies by default...Macegan
T
9

FastCopy is a small program that does.

Teofilateosinte answered 30/9, 2010 at 4:52 Comment(1)
The junctions in the source are copied in the destination and point to the same original location. It doesn't convert to new junctions in the destination drive.Mather
C
0

Copying junctions don't make any sense from drive to drive - a junction points to a specific node on disk. What you really want is a Symlink, which points to a specific path in the filesystem, but unfortunately this doesn't exist on Server 2003. You're out of luck here, you'll have to just fix this up in a post-copy script.

Corvese answered 15/11, 2009 at 18:24 Comment(2)
I think he wants to copy the junction itself. So in other words to create a new junction that points to the same place as the old junction, instead of copying the junction target as a new folder.Perutz
The problem is that symlinks will also create deep-copies by default...Macegan
F
0

You can recreate a list of junction points using the scripts.

https://github.com/andry81/contools/tree/HEAD/Scripts/Tools/admin/Junction

list-junction-points.bat

@echo off

for /F "usebackq eol= tokens=* delims=" %%i in (`@dir /A:L /B %* 2^>nul`) do echo.%%i
list-junction-points.bat /S c:\ > junction-points.lst

Then get junction points paths:

read-junction-points.bat

@echo off

for /F "usebackq eol= tokens=* delims=" %%i in ("%~1") do for /F "usebackq eol= tokens=4,* delims= " %%j in (`dir /A:L "%%i\.." 2^>nul ^| findstr /R /C:"\[.*\]"`) do if "%%~ni" == "%%j" ( set "J=%%k" & call echo.%%i*%%J:~1,-1%%)
read-junction-points.bat junction-points.lst > junction-paths.lst

Then recreate junction points (needs administrator privileges):

create-junction-points.bat

@echo off

for /F "usebackq eol= tokens=1,* delims=*" %%i in ("%~1") do ( echo."%%i" -^> "%%j" & mklink /j "%%i" "%%j" )
create-junction-points.bat junction-paths.lst 

Warning: The eol= actually is not empty and contains the 04 code character.

Junction point connection is required only on creation which requires administrator privileges.

Fiddle answered 15/10, 2023 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.