Skip to main content

Rsync

限制傳檔的網路頻寬
--bwlimit=30000

30000 = 30000 KB/ps = 30 MB/ps

本機內不同個資料夾做複製或同步
rsync -av --delete --exclude='path1/to/exclude' --exclude='path2/to/exclude' source destination
  • source/ 來源目錄+斜線 會複製目錄內的內容
  • source 來源目錄不加斜線 會複製整個目錄
  • --delete 來源檔案被刪除時也會同步到目的端 
遠端複製大檔案需要續傳
rsync --partial --progress --rsh=ssh <local_file> user@host:<remote_file>
複製 Linux 整個系統
mount /dev/sdb1 /mnt
rsync -aAXv / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /mnt
How does rsync work

https://michael.stapelberg.ch/posts/2022-07-02-rsync-how-does-it-work/ 

Other similar solutions
  • Syncthing - It is a free and open-source file syncing application used to sync files between multiple remote devices over the internet. It works on peer-to-peer architecture and exchanges the data automatically between two devices.
  • Restic - is a fast, open source, secure and cross-platform backup program. It allows saving multiple revisions of files and directories in an encrypted repository stored on different backends.
    • 備份資料加密
    • 差異備份 - snapshot
    • 支援目錄與檔案
    • 備份媒體支援 本地/SFTP/HTTP REST/AWS S3/Azure Storage/Google Cloud Storage/rclone