語法:#rsysnc [options] source path destination path示例:
1 - 啟用壓縮[root@localhost /]# rsync -zvr /home/aloft/ /backuphomedirbuilding file list ... done.bash_logout.bash_profile.bashrcsent 472 bytes received 86 bytes 1116.00 bytes/sectotal size is 324 speedup is 0.58上面的rsync命令使用了-z來啟用壓縮,-v是視覺化,-r是遞迴。上面在本地的/home/aloft/和/backuphomedir之間同步。示例:
2 - 保留檔案和資料夾的屬性[root@localhost /]# rsync -azvr /home/aloft/ /backuphomedirbuilding file list ... done./.bash_logout.bash_profile.bashrcsent 514 bytes received 92 bytes 1212.00 bytes/sectotal size is 324 speedup is 0.53上面我們使用了-a選項,它保留了所有人和所屬組、時間戳、軟連結、許可權,並以遞迴模式執行。示例:
3 - 同步本地到遠端主機root@localhost /]# rsync -avz /home/aloft/ [email protected]:192.168.1.4:/share/rsysnctest/Password:building file list ... done./.bash_logout.bash_profile.bashrcsent 514 bytes received 92 bytes 1212.00 bytes/sectotal size is 324 speedup is 0.53上面的命令允許你在本地和遠端機器之間同步。你可以看到,在同步檔案到另一個系統時提示你輸入密碼。在做遠端同步時,你需要指定遠端系統的使用者名稱和IP或者主機名。示例: 4 - 遠端同步到本地[root@localhost /]# rsync -avz [email protected]:192.168.1.4:/share/rsysnctest/ /home/aloft/Password:building file list ... done./.bash_logout.bash_profile.bashrcsent 514 bytes received 92 bytes 1212.00 bytes/sectotal size is 324 speedup is 0.53上面的命令同步遠端檔案到本地。示例: 5 - 找出檔案間的不同[root@localhost backuphomedir]# rsync -avzi /backuphomedir /home/aloft/building file list ... donecd+++++++ backuphomedir/>f+++++++ backuphomedir/.bash_logout>f+++++++ backuphomedir/.bash_profile>f+++++++ backuphomedir/.bashrc>f+++++++ backuphomedir/abc>f+++++++ backuphomedir/xyzsent 650 bytes received 136 bytes 1572.00 bytes/sectotal size is 324 speedup is 0.41上面的命令幫助你找出源地址和目標地址之間檔案或者目錄的不同。示例: 6 - 備份rsync命令可以用來備份linux。你可以在cron中使用rsync安排備份。
語法:#rsysnc [options] source path destination path示例:
1 - 啟用壓縮[root@localhost /]# rsync -zvr /home/aloft/ /backuphomedirbuilding file list ... done.bash_logout.bash_profile.bashrcsent 472 bytes received 86 bytes 1116.00 bytes/sectotal size is 324 speedup is 0.58上面的rsync命令使用了-z來啟用壓縮,-v是視覺化,-r是遞迴。上面在本地的/home/aloft/和/backuphomedir之間同步。示例:
2 - 保留檔案和資料夾的屬性[root@localhost /]# rsync -azvr /home/aloft/ /backuphomedirbuilding file list ... done./.bash_logout.bash_profile.bashrcsent 514 bytes received 92 bytes 1212.00 bytes/sectotal size is 324 speedup is 0.53上面我們使用了-a選項,它保留了所有人和所屬組、時間戳、軟連結、許可權,並以遞迴模式執行。示例:
3 - 同步本地到遠端主機root@localhost /]# rsync -avz /home/aloft/ [email protected]:192.168.1.4:/share/rsysnctest/Password:building file list ... done./.bash_logout.bash_profile.bashrcsent 514 bytes received 92 bytes 1212.00 bytes/sectotal size is 324 speedup is 0.53上面的命令允許你在本地和遠端機器之間同步。你可以看到,在同步檔案到另一個系統時提示你輸入密碼。在做遠端同步時,你需要指定遠端系統的使用者名稱和IP或者主機名。示例: 4 - 遠端同步到本地[root@localhost /]# rsync -avz [email protected]:192.168.1.4:/share/rsysnctest/ /home/aloft/Password:building file list ... done./.bash_logout.bash_profile.bashrcsent 514 bytes received 92 bytes 1212.00 bytes/sectotal size is 324 speedup is 0.53上面的命令同步遠端檔案到本地。示例: 5 - 找出檔案間的不同[root@localhost backuphomedir]# rsync -avzi /backuphomedir /home/aloft/building file list ... donecd+++++++ backuphomedir/>f+++++++ backuphomedir/.bash_logout>f+++++++ backuphomedir/.bash_profile>f+++++++ backuphomedir/.bashrc>f+++++++ backuphomedir/abc>f+++++++ backuphomedir/xyzsent 650 bytes received 136 bytes 1572.00 bytes/sectotal size is 324 speedup is 0.41上面的命令幫助你找出源地址和目標地址之間檔案或者目錄的不同。示例: 6 - 備份rsync命令可以用來備份linux。你可以在cron中使用rsync安排備份。