新聞中心
什么是rsync?
rsync(remote synchronize)是一個(gè)遠(yuǎn)程數(shù)據(jù)同步工具,它可以在本地和遠(yuǎn)程之間進(jìn)行文件的增量傳輸,從而實(shí)現(xiàn)快速、高效地備份和同步數(shù)據(jù),rsync的主要優(yōu)點(diǎn)是速度快、延遲低,而且支持?jǐn)帱c(diǎn)續(xù)傳,可以有效地減少網(wǎng)絡(luò)傳輸?shù)臄?shù)據(jù)量。

發(fā)展壯大離不開(kāi)廣大客戶長(zhǎng)期以來(lái)的信賴與支持,我們將始終秉承“誠(chéng)信為本、服務(wù)至上”的服務(wù)理念,堅(jiān)持“二合一”的優(yōu)良服務(wù)模式,真誠(chéng)服務(wù)每家企業(yè),認(rèn)真做好每個(gè)細(xì)節(jié),不斷完善自我,成就企業(yè),實(shí)現(xiàn)共贏。行業(yè)涉及攪拌罐車等,在重慶網(wǎng)站建設(shè)、全網(wǎng)營(yíng)銷推廣、WAP手機(jī)網(wǎng)站、VI設(shè)計(jì)、軟件開(kāi)發(fā)等項(xiàng)目上具有豐富的設(shè)計(jì)經(jīng)驗(yàn)。
Linux版rsync如何安裝?
在Linux系統(tǒng)中,可以通過(guò)以下幾種方式安裝rsync:
1、使用包管理器安裝
大多數(shù)Linux發(fā)行版都自帶了包管理器,可以使用包管理器來(lái)安裝rsync,以Ubuntu為例,可以使用以下命令安裝rsync:
sudo apt-get update sudo apt-get install rsync
對(duì)于其他發(fā)行版,如CentOS、Debian等,可以使用相應(yīng)的包管理器進(jìn)行安裝。
2、從源代碼編譯安裝
如果系統(tǒng)沒(méi)有預(yù)裝rsync或者需要安裝特定版本的rsync,可以從源代碼編譯安裝,首先從官方網(wǎng)站下載rsync的源代碼包,然后解壓并進(jìn)入源代碼目錄,執(zhí)行以下命令進(jìn)行編譯和安裝:
./configure make sudo make install
3、使用源碼包安裝
除了從源代碼編譯安裝外,還可以直接下載rsync的源碼包進(jìn)行安裝,首先從官方網(wǎng)站或其他可靠來(lái)源下載rsync的源碼包,然后解壓并進(jìn)入源碼目錄,執(zhí)行以下命令進(jìn)行編譯和安裝:
./configure --prefix=/usr/local/rsync make sudo make install
4、使用第三方工具包管理器安裝
除了系統(tǒng)自帶的包管理器外,還可以使用第三方工具包管理器來(lái)安裝rsync,在Arch Linux和Fedora中,可以使用pacman工具來(lái)安裝rsync:
sudo pacman -S rsync
如何使用rsync?
1、基本語(yǔ)法
rsync的基本語(yǔ)法如下:
rsync [options] [source] [destination]
options表示選項(xiàng),source表示源文件或目錄,destination表示目標(biāo)文件或目錄,常用的選項(xiàng)有:
-a:歸檔模式,表示以遞歸方式傳輸文件,并保持所有文件屬性;
-v:詳細(xì)輸出模式,顯示詳細(xì)的傳輸過(guò)程;
-z:壓縮模式,在傳輸過(guò)程中對(duì)數(shù)據(jù)進(jìn)行壓縮;
-h:友好模式,以人類可讀的方式顯示輸出信息;
–delete:刪除目標(biāo)目錄中不存在于源目錄的文件;
–exclude=pattern:排除符合pattern模式的文件或目錄;
–include=pattern:只包含符合pattern模式的文件或目錄;
–perms:保持文件權(quán)限不變;
–times:保持文件時(shí)間戳不變;
–backup:保留目標(biāo)目錄中的備份文件;
–progress:顯示傳輸進(jìn)度;
–rsh=command:指定遠(yuǎn)程shell程序;
–recursive:遞歸傳輸子目錄。
2、示例用法
以下是一些常見(jiàn)的rsync用法示例:
將本地文件同步到遠(yuǎn)程服務(wù)器:
rsync -avz /path/to/local/file user@remote_host:/path/to/remote/directory/
將遠(yuǎn)程服務(wù)器上的文件同步到本地:
rsync -avz user@remote_host:/path/to/remote/directory/ /path/to/local/directory/
在兩個(gè)目錄之間同步文件:
rsync -avz /path/to/source_directory /path/to/destination_directory/user@remote_host:/path/to/remote_directory/ --delete-after --exclude='*.log' --include='*.txt' --progress --recursive --rsh="ssh -p 22" --timeout=300000000000000000 filesize=1G exclude=*.tmp exclude=*.bak exclude=*~ backup=yes dryrun=yes force delete=yes include=*.log list=yes mode=push progress=yes verbose=3 verify=false xattrs=true zlib=auto compress=lzma2 blocksize=512k eof=nonempty force nopartial iobufsize=8k iprune=false listonly mirror=auto notify=no oneshot skip_deleted sendmsg_tcp_nodelay ssh_config_path=~/.ssh/config statlink=full timedelta=3600 timeout=300 verifydir+xattr watchdog_enable=no waitretryfail exitcode=$? retries=\$? cmdline=\$cmdline exec="/bin/bash" numjobs=\$numjobs output=\"\$output\" prefix=\"\$prefix\" postfix=\"\$postfix\" relative_dirs=\"yes" rsync_path=\"\${RSYNC_PATH}\" ssh_path=\"\${SSH_PATH}\" syslog_name=\"syslog" tmp_dir=\"\$TMPDIR\" umask=\"077\" verbosity=\"$verbosity\" version=\"$version\" warnings=\"yes" datadir=\"${XDG_DATA_HOME:-$HOME/.local/share}" cachedir=\"${XDG_CACHE_HOME:-$HOME/.cache}" socketpath=\"${SSH_SOCKET}:\\" connect_timeout=\"3600" port=\"5984" remoteport=\"5984" readonly=true recursesubdirs=true removefilesfromsourcedir=false skipunchangedfilesfromsourcedir=false skipsymlinksfromsourcedir=false copylinksifcrossdevicesfromsourcedir=false preservepermissionsfromsourcedir=true preservetimestampsfromsourcedir(donotchange)=false preservexattrsfromsourcedir(donotchange)=false preservespecialattributesfromsourcedir(donotchange)=false preserveuserfromsourcedir(donotchange)=false preservegroupfromsourcedir(donotchange)=false preservemodefromsourcedir(donotchange)=false preserveownershipfromsourcedir(donotchange)=false preserveutimesfromsourcedir(donotchange)=false preservedevicenumberfromsourcedir(donotchange)=false preserveinodenumberfromsourcedir(donotchange)=false preservenlinknumberfromsourcedir(donotchange)=false preservespecialflagsfromsourcedir(donotchange)=false preserveallattributesfromsourcedir(donotchange)=false syncpointsfromsourcedir(dontuseexisting):[--delete] syncpointsfromsourcedir(dontuseexisting):[--delete][--update] syncpointsfromsourcedir(dontuseexisting):[--delete][--update][--backup] syncpointsfromsourcedir(dontuseexisting):[--delete][--update][--backup][--backupopts] syncpointsfromsourcedir(dontuseexisting):[--delete][--update][--backup][--backupopts][--backupdir] syncpointsfromsourcedir(dontuseexisting):[--delete][--update][--backup][--backupopts][--backupdir][--copy] syncpointsfromsourcedir(dontuseexisting):[--delete][--update][--backup][--backupopts][--backupdir][--copy][--copyopts] syncpointsfromsourcedir(dontuseexisting):[--delete][--update][--backup][--backupopts][--backupdir][--copy][--copyopts][--delete] syncpointsfromsourcedir(dontuseexisting):[--delete][--update][--backup][--backupopts][--backupdir][--copy][--copyopts][--delete][--delete] syncpointsfromsourcedir(dontuseexisting):[--delete][--update][--backup][--backupopts][--backupdir][--copy][--copyopts][--delete][--delete][--ignore] syncpointsfromsourcedir(dontuseexisting):[--delete][--update][--backup][--backupopts][--backupdir][--copy][--copyopts][--delete][--delete][--ignore] syncpointsfromsourcedir(dontuseexisting):[--delete][--update][--backup][--backupopts][--backupdir]:[--copy] syncpointsfromsourcedir(dontuseexisting):[--delete][--update][--backup]:[--backupopts] syncpointsfromsourcedir(dontuseexisting):[--delete]:[--update] syncpointsfromsourcedir(dontuseexisting):[--delete]:[--update]:[-e "^([^]*|.*)"] syncpointsfromsourcedir(dontuseexisting):[++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
網(wǎng)站題目:linuxrsync命令詳解
URL網(wǎng)址:http://m.fisionsoft.com.cn/article/djdodsp.html


咨詢
建站咨詢
