自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

如何在Linux下使用rsync

運(yùn)維 系統(tǒng)運(yùn)維 Linux
Rsync是一款通過網(wǎng)絡(luò)備份重要數(shù)據(jù)的工具/軟件。它同樣是一個在類Unix和Window系統(tǒng)上通過網(wǎng)絡(luò)在系統(tǒng)間同步文件夾和文件的網(wǎng)絡(luò)協(xié)議。Rsync可以復(fù)制或者顯示目錄并復(fù)制文件。Rsync默認(rèn)監(jiān)聽TCP 873端口,通過遠(yuǎn)程shell如rsh和ssh復(fù)制文件。

對于各種組織和公司,數(shù)據(jù)對他們是最重要的,即使對于電子商務(wù),數(shù)據(jù)也是同樣重要的。Rsync是一款通過網(wǎng)絡(luò)備份重要數(shù)據(jù)的工具/軟件。它同樣是一個在類Unix和Window系統(tǒng)上通過網(wǎng)絡(luò)在系統(tǒng)間同步文件夾和文件的網(wǎng)絡(luò)協(xié)議。Rsync可以復(fù)制或者顯示目錄并復(fù)制文件。Rsync默認(rèn)監(jiān)聽TCP 873端口,通過遠(yuǎn)程shell如rsh和ssh復(fù)制文件。Rsync必須在遠(yuǎn)程和本地系統(tǒng)上都安裝。

[[124979]]

rsync的主要好處是:

速度:最初會在本地和遠(yuǎn)程之間拷貝所有內(nèi)容。下次,只會傳輸發(fā)生改變的塊或者字節(jié)。

安全:傳輸可以通過ssh協(xié)議加密數(shù)據(jù)。

低帶寬:rsync可以在兩端壓縮和解壓數(shù)據(jù)塊。

語法:

  1. #rsysnc [options] source path destination path

示例: 1 - 啟用壓縮

  1. [root@localhost /]# rsync -zvr /home/aloft/ /backuphomedir
  2. building file list ... done
  3. .bash_logout
  4. .bash_profile
  5. .bashrc
  6. sent 472 bytes received 86 bytes 1116.00 bytes/sec
  7. total size is 324 speedup is 0.58

上面的rsync命令使用了-z來啟用壓縮,-v是可視化,-r是遞歸。上面在本地的/home/aloft/和/backuphomedir之間同步。

示例: 2 - 保留文件和文件夾的屬性

  1. [root@localhost /]# rsync -azvr /home/aloft/ /backuphomedir
  2. building file list ... done
  3. ./
  4. .bash_logout
  5. .bash_profile
  6. .bashrc
  7.  
  8. sent 514 bytes received 92 bytes 1212.00 bytes/sec
  9. total size is 324 speedup is 0.53

上面我們使用了-a選項,它保留了所有人和所屬組、時間戳、軟鏈接、權(quán)限,并以遞歸模式運(yùn)行。

示例: 3 - 同步本地到遠(yuǎn)程主機(jī)

  1. root@localhost /]# rsync -avz /home/aloft/ azmath@192.168.1.4:192.168.1.4:/share/rsysnctest/
  2. Password:
  3.  
  4. building file list ... done
  5. ./
  6. .bash_logout
  7. .bash_profile
  8. .bashrc
  9. sent 514 bytes received 92 bytes 1212.00 bytes/sec
  10. total size is 324 speedup is 0.53

上面的命令允許你在本地和遠(yuǎn)程機(jī)器之間同步。你可以看到,在同步文件到另一個系統(tǒng)時提示你輸入密碼。在做遠(yuǎn)程同步時,你需要指定遠(yuǎn)程系統(tǒng)的用戶名和IP或者主機(jī)名。

示例: 4 - 遠(yuǎn)程同步到本地

  1. [root@localhost /]# rsync -avz azmath@192.168.1.4:192.168.1.4:/share/rsysnctest/ /home/aloft/
  2. Password:
  3. building file list ... done
  4. ./
  5. .bash_logout
  6. .bash_profile
  7. .bashrc
  8. sent 514 bytes received 92 bytes 1212.00 bytes/sec
  9. total size is 324 speedup is 0.53

上面的命令同步遠(yuǎn)程文件到本地。

示例: 5 - 找出文件間的不同

  1. [root@localhost backuphomedir]# rsync -avzi /backuphomedir /home/aloft/
  2. building file list ... done
  3. cd+++++++ backuphomedir/
  4. >f+++++++ backuphomedir/.bash_logout
  5. >f+++++++ backuphomedir/.bash_profile
  6. >f+++++++ backuphomedir/.bashrc
  7. >f+++++++ backuphomedir/abc
  8. >f+++++++ backuphomedir/xyz
  9.  
  10. sent 650 bytes received 136 bytes 1572.00 bytes/sec
  11. total size is 324 speedup is 0.41

上面的命令幫助你找出源地址和目標(biāo)地址之間文件或者目錄的不同。

示例: 6 - 備份

rsync命令可以用來備份linux。

你可以在cron中使用rsync安排備份。

  1. 0 0 * * * /usr/local/sbin/bkpscript &> /dev/null

  1. vi /usr/local/sbin/bkpscript
  2.  
  3. rsync -avz -e ssh -p2093 /home/test/ root@192.168.1.150:/oracle/data/

via: http://linoxide.com/how-tos/rsync-copy/

作者:Bobbin Zachariah 譯者:geekpi 校對:wxy

責(zé)任編輯:林師授 來源: Linux中國
相關(guān)推薦

2023-09-24 19:29:44

LinuxWebP圖像

2022-03-09 14:43:38

LinuxDLNA

2011-01-11 14:04:26

2009-07-15 17:52:23

sqlite jdbc

2016-08-16 08:26:19

Linuxsignalsigaction

2017-01-05 12:21:00

LinuxPyCharm安裝

2011-03-09 15:54:34

LAMP

2022-09-01 13:12:53

LinuxTC網(wǎng)絡(luò)限流

2015-11-24 13:27:35

Linuxcool-retro-復(fù)古終端

2019-02-28 09:13:21

Linux用法交互模式

2019-03-28 08:00:00

Linux磁盤IO監(jiān)控存儲設(shè)備

2017-08-07 16:41:39

LinuxOpenCV

2014-03-20 10:31:02

Linuxbin

2017-05-08 18:10:54

2021-10-02 10:10:47

LinuxBusyBox命令

2019-09-16 19:00:48

Linux變量

2019-01-07 09:50:06

Linuxtarball命令

2019-11-26 16:58:51

Linuxpkgsrc

2023-01-17 07:40:59

LinuxAppImage應(yīng)用程序

2010-08-25 13:46:28

入侵檢測IDS
點贊
收藏

51CTO技術(shù)棧公眾號