使用rsync复制文件和文件夹
查看帮助文件:
man rsync
rsync的格式:
如果不遵循下面显示的命令格式,则rsync可能无法按预期复制和同步内容。
rsync option source_location destination_location
例如,要将文件从/var/www/html/file复制到/var/log/test,我们将运行以下命令
rsync options /var/www/html/file /var/log/test
rsync的命令选项列表
-a, --archive archive mode -v, --verbose increase verbosity -z, --compress compress file data during the transfer -t, --times preserve modification times -p, --perms preserve permissions -h, --human-readable output numbers in a more human-readable format -l, --links copy symlinks as symlinks -e, --rsh=COMMAND specify the remote shell to use --numeric-ids don't map uid/gid values by user/group name --delete delete extraneous files from dest dirs
将目录/tmp/local/public 复制到/var/www/html:
rsync -avzh /var/local/public//var/www/html
将本地内容复制到远程主机,使用以下格式:
rync -avzh /var/local/content admin@1921.168.241.2:/var/remote/content
在Ubuntu上安装rsync
sudo apt-get update sudo apt-get -y install rsync
日期:2020-07-07 20:55:42 来源:oir作者:oir