1. 程式人生 > 其它 >強烈推薦這個開源備份工具,程式設計師人手必備的工具!

強烈推薦這個開源備份工具,程式設計師人手必備的工具!

強烈推薦這個開源備份工具,程式設計師人手必備的工具!

前言

備份軟體已經是一個老生常談的話題了,今天,要和大家分享一個備份工具——restic。

Restic是一種快速、高效、免費和開源的備份應用程式,它通過AES-256加密保護你的資料,Restic 還利用重複資料刪除來幫助節省備份空間。此外,Restic 與大多數主要的雲提供商相容,支援三大作業系統(Linux、macOS、Windows)和一些較小的作業系統(FreeBSD、OpenBSD)。

目前,Restic已經在Github上標星 14.6K,累計分支 999 個

Github地址:https://github.com/restic/restic

首先,你可以從原始碼編譯restic或從釋出頁面下載它。一旦安裝好restic,就可以開始備份:

$ restic init --repo /tmp/backup
enter password for new backend:
enter password again:
created restic backend 085b3c76b9 at /tmp/backup
Please note that knowledge of your password is required to access the repository.
Losing your password means that your data is irrecoverably lost.

並新增一些資料:

$ restic --repo /tmp/backup backup ~/work
enter password for repository:
scan [/home/user/work]
scanned 764 directories, 1816 files in 0:00
[0:29] 100.00%  54.732 MiB/s  1.582 GiB / 1.582 GiB  2580 / 2580 items  0 errors  ETA 0:00
duration: 0:29, 54.47MiB/s
snapshot 40dc1520 saved

接下來,你可以restic restore用於恢復檔案,要獲取所有備份快照的列表,可以使用以下的命令:

restic -r b2:bucketname:/ snapshots

例如:

$ restic -r b2:g534fbucket:/ snapshots
enter password for repository: 
ID Date Host Tags Directory
----------------------------------------------------------------------
d864c465 2018-03-27 15:20:42 client /home/curt/Documents

如果你要恢復整個快照,就執行以下命令:

restic -r b2:bucketname:/ restore snapshotID --target restoreDirectory

例如:

$ restic -r b2:g534fbucket:/ restore d864c465 --target ~
enter password for repository: 
restoring <Snapshot d864c465 of [/home/curt/Documents] at 2018-03-27 15:20:42.833131988 -0400 EDT by curt@client> to /home/curt

如果該目錄仍然存在於你的系統上,請確保為restoreDirectory指定不同的位置。例如:

restic -r b2:g534fbucket:/ restore d864c465 --target /tmp

要恢復單個檔案,請執行如下命令:

$ restic -r b2:g534fbucket:/restore snapshotID --target restoreDirectory --include filename

例如:

$ restic -r b2:g534fbucket:/ restore d864c465 --target /tmp --include file1.txt
enter password for repository: 
restoring <Snapshot d864c465 of [/home/curt/Documents] at 2018-03-27 15:20:42.833131988 -0400 EDT by curt@client

Github地址:https://github.com/restic/restic