您的位置:首页 > 运维架构 > Linux

linux rsync 学习笔记

2011-09-04 20:46 363 查看
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

$ rsync -avr jia@172.16.2.84:/home/jia/jia_svn_test /home/jia

对本地两个两个目录同步:

$ rsync -avr filename1 filename2

# 将filename1 中的文件同步至filename2, 即 filename2中的文件与filename1 一致
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: