scp和cp 默认复制,如果为软链接,会将源文件一同复制过去
现象:
迁移docker目录时,默认是/var/lib/docker,先停docker,
复制到另外目录/backup/时,通过du -sh /backup/发现居然由50G变100G以上,而且还在不停增长
解决:
删除/backup/
重新cp时加-d参数,代表复制时在源文件中除了links不复制其他符号链接
rm -rf /backup/
cp -drf /var/lib/docker/ /backup/
英文翻译
dereference 解除引用
preserve 保留
ownership 所有权
]#cp --help
-d same as --no-dereference --preserve=links
-P, --no-dereference never follow symbolic links in SOURCE
-p same as --preserve=mode,ownership,timestamps
--preserve[=ATTR_LIST] preserve the specified attributes (default:
mode,ownership,timestamps), if possible
additional attributes: context, links, xattr,
all
--no-preserve=ATTR_LIST don't preserve the specified attributes
--parents use full source file name under DIRECTORY
网友评论