ubuntu 14.04: How to compress a directory which have symlinks?
Matthew Harrington
I have a php project of size 3.5GB in which there are symlinks of several files. I want to zip it and take backup to windows 10 PC from my ubuntu 14.04 laptop. Whenever, I make a zip file of it and take backup in PC and when i copy the backup zip file of my project back from windows PC to laptop and unzip it then the symlinks are not there instead the symlinks are shown as normal php files.
first image is with symlinks and seconds is without symlinks. What is the proper way to zip a large folder so that I will not loose any symlinks?
71 Answer
Actually, a simple search reveals an anwer. The standard zip utility that comes with Ubuntu (Info-ZIP) comes with an option that allows to store symlinks as symlinks. By default, symlinks are dereferenced, i.e., the actual file linked to is included in the zip, as you experienced. The command might look like:zip --symlinks -r foo.zip foo/(credit goes to the Server Fault site)
You may consider using compressed tar archive formats instead for this task. The tar archive format by design supports linux file system features including symbolic links, file permissions, whereas zip originally has its origins rather in the MS Windows environment.