在 Windows 上打包文件并保留文件夹时间戳
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5397957/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pack files on windows and preserve folder timestamps
提问by BetaRide
I want to put a big folder on Windows box into one archive (tar, zip, gzip, whatever). Is there a tool that can preserver all folder timestamps?
我想将 Windows 盒子上的一个大文件夹放入一个存档(tar、zip、gzip 等)中。有没有可以保留所有文件夹时间戳的工具?
The timestamps have to be preserverd after unpacking the archive on a Linux box.
在 Linux 机器上解压存档后,必须保留时间戳。
Any ideas are welcome!
欢迎任何想法!
采纳答案by Erik
tar will do fine. gzip is for single file compression, zip won't preserve directory timestamps.
焦油会很好。gzip 用于单个文件压缩,zip 不会保留目录时间戳。
EDIT: Sample.
编辑:示例。
tar jcpf backup.tbz2 thedir
rm -rf thedir
tar jxpf backup.tbz2
Timestamps preserved.
时间戳被保留。
EDIT2:
编辑2:
cygwin tar
correctly preserves timestamps. Tested with tar jcf
on cygwin, tar jxf
on linux.
cygwintar
正确保留时间戳。tar jcf
在 cygwintar jxf
上测试,在 linux 上。
EDIT3:
WinRar preserves directory timestamps, linux unrar
restores them properly.
EDIT3:WinRar 保留目录时间戳,linuxunrar
正确恢复它们。
回答by Cheeso
DotNetZip preserves timestamps on folders, as well as files.
DotNetZip 保留文件夹和文件上的时间戳。
回答by BetaRide
It seams that there's no soluation to all my requirements:
看来我的所有要求都没有解决方案:
- Pack on Windows an preserve folder timestamps
- Unpack on Linux and preserve original folder timestamps
- I prefer a copy/paste aka portable installation of the tool, otherwise the deployment gets to complicated.
- A partial, drop in cygwin installation by just copying the necessary exe and dll files works, but doesn't preserve the folder timestamps.
- Full cygwin installation is not easily possible since the windows client machines are on terminal server (see http://www.cygwin.com/faq/faq.setup.html#faq.setup.setup-fails-on-ts)
- Zip doesn't work because unzip on ubuntu cannot preserver folder timestamps, even if the zip tool of choice does.
- 在 Windows 上打包保留文件夹时间戳
- 在 Linux 上解压并保留原始文件夹时间戳
- 我更喜欢复制/粘贴也就是该工具的便携式安装,否则部署会变得复杂。
- 只需复制必要的 exe 和 dll 文件即可在 cygwin 安装中进行部分删除,但不会保留文件夹时间戳。
- 完整的 cygwin 安装并不容易,因为 Windows 客户端机器在终端服务器上(参见http://www.cygwin.com/faq/faq.setup.html#faq.setup.setup-fails-on-ts)
- Zip 不起作用,因为在 ubuntu 上解压缩无法保留文件夹时间戳,即使选择的 zip 工具可以。