Backup

rsync 根據日期創建目錄

  • May 3, 2020

我正在使用 rsync 和 crontab 來安排每晚的備份。

但是,要進行完整備份而不是增量備份。

我在我的腳本文件中使用以下 rsync。

rsync -razv dev@xx.xx.xx.xx:repos /home/backup_sys_user/repos_backup

我想創建下面的結構:

/repos_backup/10.10.2010
            /11.10.2010
            /12.10.2010

無論如何,rsync 可以做到這一點。我知道是否可以使用創建目錄,--backup-dir=DIR但這僅用於增量。我想做一個完整的備份。

非常感謝您的任何建議,

DATE=`date +%m.%d.%Y`
rsync -razv dev@xx.xx.xx.xx:repos /home/backup_sys_user/repos_backup/$DATE

但是,您可能希望使用 –link-dest 來創建帶有硬連結的備份,然後,刪除舊備份仍會為您留下完整副本,但是,您只會佔用更改文件的磁碟空間.

karmawhore 通常是正確的,但您可能需要查看 rsnapshot,而不是手動使用“–link-dest”:

http://rsnapshot.org/

此外,對於大量文件,我建議使用 3.x 範圍內的 rsync 版本,因為有以下關鍵改進:

- A new incremental-recursion algorithm is now used when rsync is talking
 to another 3.x version.  This starts the transfer going more quickly
 (before all the files have been found), and requires much less memory.
 See the --recursive option in the manpage for some restrictions.

引用自:https://serverfault.com/questions/189499