日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux下的rsync远程增量备份详解

發布時間:2025/4/16 linux 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux下的rsync远程增量备份详解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Linux下的遠程增量備份詳解

  • 一、rsync工具介紹
  • 二、rsync備份方法
  • 三、測試備份結果
  • 四、測試增量備份

一、rsync工具介紹

二、rsync備份方法

三、測試備份結果

四、測試增量備份

一、rsync工具介紹

rsync是linux系統下的數據鏡像備份工具。使用快速增量備份工具Remote Sync可以遠程同步,支持本地復制,或者與其他SSH、rsync主機同步。

#rsync 用法rsync version 3.1.3 protocol version 31 Copyright (C) 1996-2018 by Andrew Tridgell, Wayne Davison, and others. Web site: http://rsync.samba.org/ Capabilities:64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,append, ACLs, xattrs, iconv, symtimes, preallocrsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the GNU General Public Licence for details.rsync is a file transfer program capable of efficient remote update via a fast differencing algorithm.Usage: rsync [OPTION]... SRC [SRC]... DESTor rsync [OPTION]... SRC [SRC]... [USER@]HOST:DESTor rsync [OPTION]... SRC [SRC]... [USER@]HOST::DESTor rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DESTor rsync [OPTION]... [USER@]HOST:SRC [DEST]or rsync [OPTION]... [USER@]HOST::SRC [DEST]or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST] rsync選項說明:-a 參數,相當于-rlptgoD,-r 是遞歸 -l 是鏈接文件,意思是拷貝鏈接文件;-p 表示保持文件原有權限;-t 保持文件原有時間;-g 保持文件原有用戶組;-o 保持文件原有屬主;-D 相當于塊設備文件; -z 傳輸時壓縮; -P 傳輸進度; -v 傳輸時的進度等信息,和-P有點關系,自己試試。可以看文檔; 參數詳解編輯 -v, --verbose 詳細模式輸出 -q, --quiet 精簡輸出模式 -c, --checksum 打開校驗開關,強制對文件傳輸進行校驗 -a, --archive 歸檔模式,表示以遞歸方式傳輸文件,并保持所有文件屬性,等于-rlptgoD -r, --recursive 對子目錄以遞歸模式處理 -R, --relative 使用相對路徑信息 -b, --backup 創建備份,也就是對于目的已經存在有同樣的文件名時,將老的文件重新命名為~filename。可以使用--suffix選項來指定不同的備份文件前綴。 --backup-dir 將備份文件(如~filename)存放在在目錄下。 -suffix=SUFFIX 定義備份文件前綴 -u, --update 僅僅進行更新,也就是跳過所有已經存在于DST,并且文件時間晚于要備份的文件。(不覆蓋更新的文件) -l, --links 保留軟鏈結 -L, --copy-links 像對待常規文件一樣處理軟鏈接 --copy-unsafe-links 僅僅拷貝指向SRC路徑目錄樹以外的鏈接 --safe-links 忽略指向SRC路徑目錄樹以外的鏈接 -H, --hard-links 保留硬鏈接 -p, --perms 保持文件權限 -o, --owner 保持文件屬主信息 -g, --group 保持文件屬組信息 -D, --devices 保持設備文件信息 -t, --times 保持文件時間信息 -S, --sparse 對稀疏文件進行特殊處理以節省DST的空間 -n, --dry-run顯示哪些文件將被傳輸 -W, --whole-file 拷貝文件,不進行增量檢測 -x, --one-file-system 不要跨越文件系統邊界 -B, --block-size=SIZE 檢驗算法使用的塊尺寸,默認是700字節 -e, --rsh=COMMAND 指定使用rsh、ssh方式進行數據同步 --rsync-path=PATH 指定遠程服務器上的rsync命令所在路徑信息 -C, --cvs-exclude 使用和CVS一樣的方法自動忽略文件,用來排除那些不希望傳輸的文件

二、rsync備份方法
1.要求
將control端的/data/tmp/下所有文件備份到node1端的user1用戶/data/backup/control/目錄下
#備份原路徑

#備份原路徑[root@control tmp]# pwd /data/tmp [root@control tmp]# ll total 0 -rw-r--r--. 1 root root 0 Apr 30 14:10 file0.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file10.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file11.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file12.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file13.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file14.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file15.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file16.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file17.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file18.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file19.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file1.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file20.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file2.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file3.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file4.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file5.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file6.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file7.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file8.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file9.py

2.進行遠程增量備份

[root@control ansible]# rsync -avz /data/tmp/ user1@node1:/data/backup/control/ [root@control ansible]# rsync -avz /data/tmp/ root@node1:/data/backup/control/ sending incremental file list ./ file0.py file1.py file10.py file11.py file12.py file13.py file14.py file15.py file16.py file17.py file18.py file19.py file2.py file20.py file3.py file4.py file5.py file6.py file7.py file8.py file9.pysent 1,151 bytes received 418 bytes 3,138.00 bytes/sec total size is 0 speedup is 0.00

三、測試備份結果

在node1查看備份結果

[root@node1 control]# pwd /data/backup/control [root@node1 control]# ll total 0 -rw-r--r--. 1 root root 0 Apr 30 14:10 file0.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file10.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file11.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file12.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file13.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file14.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file15.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file16.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file17.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file18.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file19.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file1.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file20.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file2.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file3.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file4.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file5.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file6.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file7.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file8.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file9.py[

四、測試增量備份
1.在control端備份源目錄新增文件

[root@control tmp]# touch test{1..3} [root@control tmp]# ls file0.py file11.py file13.py file15.py file17.py file19.py file20.py file3.py file5.py file7.py file9.py test2 file10.py file12.py file14.py file16.py file18.py file1.py file2.py file4.py file6.py file8.py test1 test3 [root@control tmp]# ll total 0 -rw-r--r--. 1 root root 0 Apr 30 14:10 file0.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file10.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file11.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file12.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file13.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file14.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file15.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file16.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file17.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file18.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file19.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file1.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file20.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file2.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file3.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file4.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file5.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file6.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file7.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file8.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file9.py -rw-r--r--. 1 root root 0 May 1 19:36 test1 -rw-r--r--. 1 root root 0 May 1 19:36 test2 -rw-r--r--. 1 root root 0 May 1 19:36 test3 [root@control tmp]# rsync -avz /data/tmp/ root@node1:/data/backup/control/ sending incremental file list ./ test1 test2 #只同步了新增的三個文件 test3sent 549 bytes received 76 bytes 1,250.00 bytes/sec total size is 0 speedup is 0.00

2.在control端備份源目錄修改文件內容

[root@control tmp]# echo 123 >> file1.py [root@control tmp]# rsync -avz /data/tmp/ root@node1:/data/backup/control/ sending incremental file list file1.py #只同步了修改內容的文件sent 486 bytes received 35 bytes 1,042.00 bytes/sec total size is 4 speedup is 0.01

3.在control端備份源目錄修改文件權限

[root@control tmp]# chmod o+rwx file8.py [root@control tmp]# rsync -avz /data/tmp/ root@node1:/data/backup/control/ sending incremental file listsent 449 bytes received 19 bytes 936.00 bytes/sec total size is 4 speedup is 0.01

備份端node1查看

[root@node1 control]# ll total 4 -rw-r--r--. 1 root root 0 Apr 30 14:10 file0.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file10.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file11.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file12.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file13.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file14.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file15.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file16.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file17.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file18.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file19.py -rw-r--r--. 1 root root 4 May 1 19:38 file1.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file20.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file2.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file3.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file4.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file5.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file6.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file7.py -rw-r--rwx. 1 root root 0 Apr 30 14:10 file8.py -rw-r--r--. 1 root root 0 Apr 30 14:10 file9.py -rw-r--r--. 1 root root 0 May 1 19:36 test1 -rw-r--r--. 1 root root 0 May 1 19:36 test2 -rw-r--r--. 1 root root 0 May 1 19:36 test3

總結

以上是生活随笔為你收集整理的Linux下的rsync远程增量备份详解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。