part 1: 查看rsync 的manual
$ man rsync :
rsync(1) rsync(1)
NAME
rsync — a fast, versatile, remote (and local) file-copying tool
SYNOPSIS
Local: rsync [OPTION...] SRC... [DEST]
Access via remote shell:
Pull: rsync [OPTION...] [USER@]HOST:SRC... [DEST]
Push: rsync [OPTION...] SRC... [USER@]HOST:DEST
Access via rsync daemon:
Pull: rsync [OPTION...] [USER@]HOST::SRC... [DEST]
rsync [OPTION...] rsync://[USER@]HOST[:PORT]/SRC... [DEST]
Push: rsync [OPTION...] SRC... [USER@]HOST::DEST
rsync [OPTION...] SRC... rsync://[USER@]HOST[:PORT]/DEST
Usages with just one SRC arg and no DEST arg will list the source files instead of copying.
# rsync 的使用主要有两种模式, remote shell, rsync daemo, 这里主讲 remote shell 方式
part 2: rsync 的主要应用
以如下A、B两台计算机为例:
A: jia@jia-server-svn 172.16.2.142
B: jia@jia-server-001 172.16.2.84
在A 上:
push: 将 A上的文件、文件夹传递到 B上
$ rsync -avr ue_test jia@172.16.2.84:/home/jia
$ rsync -avr test jia@172.16.2.84:/home/jia
pull: 将B上的文件、文件夹传递到A上
$ rsync -avr jia@172.16.2.84:/home/jia/test.py /home/jia
$ man rsync :
rsync(1) rsync(1)
NAME
rsync — a fast, versatile, remote (and local) file-copying tool
SYNOPSIS
Local: rsync [OPTION...] SRC... [DEST]
Access via remote shell:
Pull: rsync [OPTION...] [USER@]HOST:SRC... [DEST]
Push: rsync [OPTION...] SRC... [USER@]HOST:DEST
Access via rsync daemon:
Pull: rsync [OPTION...] [USER@]HOST::SRC... [DEST]
rsync [OPTION...] rsync://[USER@]HOST[:PORT]/SRC... [DEST]
Push: rsync [OPTION...] SRC... [USER@]HOST::DEST
rsync [OPTION...] SRC... rsync://[USER@]HOST[:PORT]/DEST
Usages with just one SRC arg and no DEST arg will list the source files instead of copying.
# rsync 的使用主要有两种模式, remote shell, rsync daemo, 这里主讲 remote shell 方式
part 2: rsync 的主要应用
以如下A、B两台计算机为例:
A: jia@jia-server-svn 172.16.2.142
B: jia@jia-server-001 172.16.2.84
在A 上:
push: 将 A上的文件、文件夹传递到 B上
$ rsync -avr ue_test jia@172.16.2.84:/home/jia
$ rsync -avr test jia@172.16.2.84:/home/jia
pull: 将B上的文件、文件夹传递到A上
$ rsync -avr jia@172.16.2.84:/home/jia/test.py /home/jia
$ rsync -avr jia@172.16.2.84:/home/jia/jia_svn_test /home/jia
对本地两个两个目录同步:
$ rsync -avr filename1 filename2
# 将filename1 中的文件同步至filename2, 即 filename2中的文件与filename1 一致
本文详细介绍了rsync命令的使用方法,包括如何通过远程shell进行文件复制,以及其在本地文件同步中的应用。并通过实例展示了如何在两台计算机间进行文件的推送(push)和拉取(pull)操作。
2909

被折叠的 条评论
为什么被折叠?



