2

How can I create a .zip compressed archive in Windows from the command-line that preserves symlinks?

I'm trying to create .zip file in PowerShell that includes a relative symlink from one file to another file in that archive, but I either encounter an error or the shortcut turns into a non-symlink file after extraction.

mkdir test
cd test
echo 'foo' > bar
cmd /C mklink bar_link bar
cd ..
Compress-Archive -DestinationPath test.zip -Path test

What are the commands I should use to create a .zip file from a directory that contains a relative symlink to a file in the directory to be archived?

1 Answers1

2

Since Windows 10 (some 17*** build, end of 2017), the 'tar' command has been added natively. So now for preserving symlinks I would suggest something like:

tar -cvzf mybackup.tar.gz folder-to-backup

Then, after unpacking

tar -xvzf mybackup.tar.gz

the extracted folder folder-to-backup has all symlinks remaining.