成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

發現一款數據備份恢復神器!開源免費、快速高效、安全

開源
restic 是一個快速、高效和安全的備份程序。它支持三大操作系統(Linux、macOS、Windows)和一些較小的操作系統(FreeBSD、OpenBSD)。

[[405900]]

 簡介

restic 是一個快速、高效和安全的備份程序。它支持三大操作系統(Linux、macOS、Windows)和一些較小的操作系統(FreeBSD、OpenBSD)。它使用 go 編程語言編寫,使用 AES-256 對數據進行加密,并使用 Poly1305-AES 對數據進行身份驗證。

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

設計原則

Restic 是一個可以正確進行備份的程序,其設計遵循以下原則:

  •  簡單:備份應該是一個順暢的過程,否則您可能會想跳過它。Restic 應該易于配置和使用,以便在數據丟失的情況下,您可以直接恢復它。同樣,恢復數據不應該很復雜。
  •  快速:使用 restic 備份數據應僅受網絡或硬盤帶寬的限制,以便您可以每天備份文件。如果需要太多時間,沒有人會進行備份。恢復備份應該只傳輸要恢復的文件所需的數據,這樣這個過程也很快。
  •  可驗證:比備份更重要的是恢復,所以 restic 使您可以輕松驗證所有數據是否可以恢復。
  •   安全:Restic 使用加密技術來保證您數據的機密性和完整性。假設備份數據的存儲位置不是受信任的環境(例如,系統管理員等其他人可以訪問您的備份的共享空間)。Restic 旨在保護您的數據免受此類攻擊者的侵害。
  •  高效:隨著數據的增長,額外的快照應該只占用實際增量的存儲。更重要的是,在將重復數據實際寫入存儲后端之前,應該對其進行去重,以節省寶貴的備份空間。

安裝

CentOS 

  1. [root@centos7 ~]# yum install yum-plugin-copr -y  
  2. [root@centos7 ~]# yum copr enable copart/restic -y  
  3. Loaded plugins: copr, fastestmirror  
  4. copr done  
  5. [root@centos7 ~]# yum install restic -y 

如果上面的安裝出現錯誤,請執行下面的命令解決源的問題 

  1. [root@centos7 ~]# yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo  
  2. Loaded plugins: fastestmirror  
  3. adding repo from: https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo  
  4. grabbing file https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo to /etc/yum.repos.d/copart-restic-epel-7.repo  
  5. repo saved to /etc/yum.repos.d/copart-restic-epel-7.repo 

macOS 

  1. # brew  
  2. $ brew install restic  
  3. # macprots  
  4. $ sudo port install restic 

更多安裝方式請參考:https://restic.readthedocs.io/en/latest/020_installation.html#stable-releases

配置備份存儲庫

保存備份的位置稱為“存儲庫”。存儲庫可以存儲在本地,也可以存儲在某個遠程服務器或服務上。支持以下幾種存儲方式:

對于自動備份,restic 接受環境變量中的存儲庫位置RESTIC_REPOSITORY。Restic 還可以從通過--repository-file選項或環境變量指定的文件中讀取存儲庫位置RESTIC_REPOSITORY_FILE。

對于密碼,有幾個選項:

  •  設置環境變量 RESTIC_PASSWORD
  •  通過選項--password-file或環境變量指定帶有密碼的文件路徑 RESTIC_PASSWORD_FILE
  •  通過選項--password-command或環境變量 配置需要密碼時調用的程序RESTIC_PASSWORD_COMMAND

創建本地存儲庫

以創建本地存儲庫為例 

  1. [root@centos7 ~]# restic init --repo /restic/backup_dir  
  2. enter password for new repository:   
  3. enter password again:  
  4. created restic repository dff64d39c6 at /restic/backup_dir  
  5. Please note that knowledge of your password is required to access  
  6. the repository. Losing your password means that your data is  
  7. irrecoverably lost.  
  8. #提示很明白,讓你記住在此處輸入的密碼,丟掉密碼就是丟掉了數據 

其它存儲庫創建方式請參考官方文檔:https://restic.readthedocs.io/en/latest/030_preparing_a_new_repo.html

備份實操

備份目錄data下的內容到存儲庫 

  1. [root@centos7 ~]# restic -r /restic/backup_dir --verbose backup ./data  
  2. open repository  
  3. enter password for repository:   
  4. repository dff64d39 opened successfully, password is correct  
  5. created new cache in /root/.cache/restic  
  6. lock repository  
  7. load index files  
  8. no parent snapshot found, will read all files  
  9. start scan on [./data]  
  10. start backup on [./data]  
  11. scan finished in 1.455s: 2922 files, 71.126 MiB  
  12. Files:        2922 new,     0 changed,     0 unmodified  
  13. Dirs:           99 new,     0 changed,     0 unmodified  
  14. Data Blobs:   2889 new  
  15. Tree Blobs:     99 new  
  16. Added to the repo: 72.083 MiB  
  17. processed 2922 files, 71.126 MiB in 0:05  #備份的文件數及大小  
  18. snapshot 4d20711e saved                   #創建了文件快照  
  19. --verbose #輸出過程信息 

也可以備份單個文件 

  1. [root@centos7 ~]# ls ./data  
  2. goInception-linux-amd64-v1.2.3.tar.gz  httpd-2.4.6-95.el7.centos.x86_64.rpm  mingongge.z02  
  3. httpd-2.4.46                           mingongge.file                        mingongge.zip  
  4. httpd-2.4.46.tar.gz                    mingongge.z01  
  5. [root@centos7 ~]# restic -r /restic/backup_dir --verbose backup ./data/mingongge.zip  
  6. open repository  
  7. enter password for repository:   
  8. repository dff64d39 opened successfully, password is correct  
  9. lock repository  
  10. load index files  
  11. no parent snapshot found, will read all files  
  12. start scan on [./data/mingongge.zip]  
  13. start backup on [./data/mingongge.zip]  
  14. scan finished in 0.249s: 1 files, 942.793 KiB  
  15. Files:           1 new,     0 changed,     0 unmodified  
  16. Dirs:            1 new,     0 changed,     0 unmodified  
  17. Data Blobs:      0 new  
  18. Tree Blobs:      2 new  
  19. Added to the repo: 750 B  
  20. processed 1 files, 942.793 KiB in 0:00  
  21. snapshot 3e5b7dea saved 

如果你再次執行第一步的備份命令,會發現它不再增加內容,只是為當前的數據再增加一個快照。其實,restic它具有掃描文件的功能(逐個文件掃描比對),所以restic只會備份存儲一次相同的數據。

文件檢測功能

掃描每個文件的全部內容,非常浪費資源,所以 restic 還使用基于文件元數據的更改檢測規則來確定文件自上次備份以來是否可能未更改,如果是,則不會再次掃描文件。

在Unix(包括 Linux 和 Mac)上,鑒于文件與先前備份中的文件位于同一位置,以下文件元數據屬性必須匹配才能假定其內容未更改:

  •  修改時間戳(mtime)
  •  元數據更改時間戳 (ctime)
  •  文件大小
  •  inode 編號(用于引用文件系統中的文件的內部編號)

所以,基于上述的原因,引入一些參數,如下: 

  1. --force         #關閉更改檢測,重新掃描全部文件  
  2. --ignore-ctime #要求 mtime 匹配,但允許 ctime 不同  
  3. --ignore-inode #要求 mtime 匹配,但允許 inode number 和 ctime 不同 

排除文件參數 

  1. --exclude   #指定一次或多次排除一個或多個項  
  2. --iexclude #與exclude相同,但忽略路徑的情況  
  3. --exclude-caches #指定一次排除包含特殊文件的文件夾  
  4. --exclude-file   #指定一次排除包含特殊文件的文件夾  
  5. --iexclude-file   #與exclude-file相同,但忽略路徑的情況  
  6. --exclude-if-present foo   #排除文件夾包含名為foo的文件  
  7. --exclude-larger-than size #指定一次以排除大于給定大小的文件 

更多相關的功能請參考:https://restic.readthedocs.io/en/latest/040_backup.html

存儲庫使用

既然數據備份到了存儲庫,所以,我們也需要去使用存儲庫,下面來介紹相關的操作。

列出存儲庫的所有快照

這個功能和平時在系統上使用ls命令相同,查看顯示的功能 

  1. [root@centos7 ~]# restic -r /restic/backup_dir/ snapshots  
  2. enter password for repository:   
  3. repository dff64d39 opened successfully, password is correct  
  4. ID        Time                 Host        Tags        Paths  
  5. -------------------------------------------------------------------------------  
  6. 4d20711e  2021-06-04 03:40:47  centos7                 /root/data  
  7. 3e5b7dea  2021-06-04 03:46:34  centos7                 /root/data/mingongge.zip  
  8. 94c62288  2021-06-04 03:51:21  centos7                 /root/data  
  9. -------------------------------------------------------------------------------  
  10. 3 snapshots  
  11. #還可以使用下面的參數進行過濾匹配查看  
  12. --path="dir_name"  
  13. --host hostname  
  14. #通過相同的過濾器(主機、路徑、標簽)對輸出進行分組  
  15. --group-by 

更多內容請參考:https://restic.readthedocs.io/en/latest/045_working_with_repos.html

檢測存儲庫數據 

  1. [root@centos7 ~]# restic -r /restic/backup_dir/ check  
  2. using temporary cache in /tmp/restic-check-cache-294136679  
  3. enter password for repository:   
  4. repository dff64d39 opened successfully, password is correct  
  5. created new cache in /tmp/restic-check-cache-294136679  
  6. create exclusive lock for repository  
  7. load indexes  
  8. check all packs  
  9. check snapshots, trees and blobs  
  10. [0:00] 100.00%  3 / 3 snapshots  
  11. no errors were found 

數據恢復

這個才是重點啊,恢復數據才是王炸。

創建模擬數據刪除的環境 

  1. [root@centos7 ~]# cd data/  
  2. [root@centos7 data]# ll  
  3. total 33796  
  4. -rw-r--r--  1 root root 13034487 Aug 30  2020 goInception-linux-amd64-v1.2.3.tar.gz  
  5. drwxr-sr-x 11 root   40     4096 Dec 24 22:35 httpd-2.4.46  
  6. -rw-r--r--  1 root root  9363314 Aug  5  2020 httpd-2.4.46.tar.gz  
  7. -rw-r--r--  1 root root  2846172 Oct 14  2020 httpd-2.4.6-95.el7.centos.x86_64.rpm  
  8. -rw-r--r--  1 root root        0 Jan 16 11:32 mingongge.file  
  9. -rw-r--r--  1 root root  4194304 Jan 16 16:24 mingongge.z01  
  10. -rw-r--r--  1 root root  4194304 Jan 16 16:24 mingongge.z02  
  11. -rw-r--r--  1 root root   965420 Jan 16 16:24 mingongge.zip  
  12. [root@centos7 data]# rm -rf ./*  
  13. [root@centos7 data]# ll  
  14. total 0 

恢復數據

直接從快照恢復誤刪除的數據 

  1. [root@centos7 ~]# restic -r /restic/backup_dir/ restore 4d20711e --target /root/  
  2. enter password for repository:   
  3. repository dff64d39 opened successfully, password is correct  
  4. restoring <Snapshot 4d20711e of [/root/data] at 2021-06-04 03:40:47.878873654 -0400 EDT by root@centos7> to /root/  
  5. [root@centos7 ~]# ll /root/data/  
  6. total 33796  
  7. -rw-r--r--  1 root root 13034487 Aug 30  2020 goInception-linux-amd64-v1.2.3.tar.gz  
  8. drwxr-sr-x 11 root   40     4096 Dec 24 22:35 httpd-2.4.46  
  9. -rw-r--r--  1 root root  9363314 Aug  5  2020 httpd-2.4.46.tar.gz  
  10. -rw-r--r--  1 root root  2846172 Oct 14  2020 httpd-2.4.6-95.el7.centos.x86_64.rpm  
  11. -rw-r--r--  1 root root        0 Jan 16 11:32 mingongge.file  
  12. -rw-r--r--  1 root root  4194304 Jan 16 16:24 mingongge.z01  
  13. -rw-r--r--  1 root root  4194304 Jan 16 16:24 mingongge.z02  
  14. -rw-r--r--  1 root root   965420 Jan 16 16:24 mingongge.zip 

上面的這種恢復方法相當指定從某某快照恢復數據,有時候快照較多,你不知道如何快速從哪個快照恢復的話,可以使用 latest 參數,去從最后一次備份的快照中恢復數據。 

  1. [root@centos7 ~]# rm -rf /root/data/*  
  2. [root@centos7 ~]# ll /root/data/  
  3. total 0  
  4. [root@centos7 ~]# restic -r /restic/backup_dir/ restore latest --target /root/  
  5. enter password for repository:   
  6. repository dff64d39 opened successfully, password is correct  
  7. restoring <Snapshot 94c62288 of [/root/data] at 2021-06-04 03:51:21.232686491 -0400 EDT by root@centos7> to /root/  
  8. [root@centos7 ~]# ll /root/data/  
  9. total 33796  
  10. -rw-r--r--  1 root root 13034487 Aug 30  2020 goInception-linux-amd64-v1.2.3.tar.gz  
  11. drwxr-sr-x 11 root   40     4096 Dec 24 22:35 httpd-2.4.46  
  12. -rw-r--r--  1 root root  9363314 Aug  5  2020 httpd-2.4.46.tar.gz  
  13. -rw-r--r--  1 root root  2846172 Oct 14  2020 httpd-2.4.6-95.el7.centos.x86_64.rpm  
  14. -rw-r--r--  1 root root        0 Jan 16 11:32 mingongge.file  
  15. -rw-r--r--  1 root root  4194304 Jan 16 16:24 mingongge.z01  
  16. -rw-r--r--  1 root root  4194304 Jan 16 16:24 mingongge.z02  
  17. -rw-r--r--  1 root root   965420 Jan 16 16:24 mingongge.zip 

其它管理介紹

刪除快照

這里的快照和備份的文件名義是相同的,快照多了,可能就需要定期刪除,一般對于數據的備份時間要求基本上30天是一個周期,除了特別重要的數據可能更久一點,這個根據實際情況定。 

  1. [root@centos7 ~]# restic -r /restic/backup_dir/ snapshots  
  2. enter password for repository:  
  3. repository dff64d39 opened successfully, password is correct  
  4. ID        Time                 Host        Tags        Paths  
  5. -------------------------------------------------------------------------------  
  6. 4d20711e  2021-06-04 03:40:47  centos7                 /root/data  
  7. 3e5b7dea  2021-06-04 03:46:34  centos7                 /root/data/mingongge.zip  
  8. 94c62288  2021-06-04 03:51:21  centos7                 /root/data  
  9. -------------------------------------------------------------------------------  
  10. 3 snapshots  
  11. [root@centos7 ~]# restic -r /restic/backup_dir/ forget 4d20711e 
  12. enter password for repository:   
  13. repository dff64d39 opened successfully, password is correct  
  14. [0:00] 100.00%  1 / 1 files deleted  
  15. [root@centos7 ~]# restic -r /restic/backup_dir/ snapshots  
  16. enter password for repository:   
  17. repository dff64d39 opened successfully, password is correct  
  18. ID        Time                 Host        Tags        Paths  
  19. -------------------------------------------------------------------------------  
  20. 3e5b7dea  2021-06-04 03:46:34  centos7                 /root/data/mingongge.zip  
  21. 94c62288  2021-06-04 03:51:21  centos7                 /root/data  
  22. -------------------------------------------------------------------------------  
  23. 2 snapshots  
  24. #這個方式和恢復相同,都是指定快照ID 

這種方式的刪除,只是將快照刪除了,但是引用的文件仍然在存儲庫中,也就是說存儲庫的大小沒有變化,需要使用 prune 參數來清除數據。 

  1. [root@centos7 ~]# restic -r /restic/backup_dir/ prune  
  2. enter password for repository:  
  3. repository dff64d39 opened successfully, password is correct  
  4. loading indexes...  
  5. loading all snapshots...  
  6. finding data that is still in use for 2 snapshots  
  7. [0:00] 100.00%  2 / 2 snapshots  
  8. searching used packs...  
  9. collecting packs for deletion and repacking  
  10. [0:00] 100.00%  19 / 19 packs processed  
  11. to repack:            0 blobs / 0 B  
  12. this removes          0 blobs / 0 B  
  13. to delete:            0 blobs / 0 B  
  14. total prune:          0 blobs / 0 B  
  15. remaining:         2990 blobs / 72.175 MiB  
  16. unused size after prune: 0 B (0.00% of remaining size)  
  17. done 

還可以使用下面的命令同時執行上面兩步的操作,相當于合并操作 

  1. restic forget --keep-last 1 --prune  
  2. #--keep-last 1 不刪除最后一次的快照 

更多關于快照刪除請參考:https://restic.readthedocs.io/en/latest/060_forget.html

存儲庫的密碼管理

我們可以使用key命令來為同一個存儲庫設置多個密碼,還可以使用 add、list、remove、passwd 來管理密碼。

  •  查看密碼 
  1. [root@centos7 ~]# restic -r /restic/backup_dir/ key list  
  2. enter password for repository:   
  3. repository dff64d39 opened successfully, password is correct 
  4.  ID        User  Host     Created  
  5. ---------------------------------------------  
  6. *d216779f  root  centos7  2021-06-04 03:28:34  
  7. --------------------------------------------- 
  •  新增密碼 
  1. [root@centos7 ~]# restic -r /restic/backup_dir/ key add  
  2. enter password for repository:   
  3. repository dff64d39 opened successfully, password is correct  
  4. enter new password:   
  5. enter password again:   
  6. saved new key as <Key of root@centos7, created on 2021-06-04 04:43:18.024358447 -0400 EDT m=+18.001857421>  
  7. [root@centos7 ~]# restic -r /restic/backup_dir/ key list  
  8. enter password for repository:   
  9. repository dff64d39 opened successfully, password is correct  
  10.  ID        User  Host     Created  
  11. ---------------------------------------------  
  12. *d216779f  root  centos7  2021-06-04 03:28:34  
  13.  33d0b428  root  centos7  2021-06-04 04:43:18  
  14. --------------------------------------------- 
  •  刪除 
  1. [root@centos7 ~]# restic -r /restic/backup_dir/ key remove 33d0b428  
  2. enter password for repository:  
  3. repository dff64d39 opened successfully, password is correct  
  4. removed key 33d0b428cba5c62585f1190432e61d46b88b4a6418c693d09ec47db596eace1f  
  5. [root@centos7 ~]# restic -r /restic/backup_dir/ key list 
  6. enter password for repository:   
  7. repository dff64d39 opened successfully, password is correct  
  8.  ID        User  Host     Created  
  9. ---------------------------------------------  
  10. *d216779f  root  centos7  2021-06-04 03:28:34  
  11. --------------------------------------------- 
  •  更改密碼 
  1. [root@centos7 ~]# restic -r /restic/backup_dir/ key passwd  
  2. enter password for repository:   
  3. repository dff64d39 opened successfully, password is correct  
  4. enter new password:   
  5. enter password again:   
  6. saved new key as <Key of root@centos7, created on 2021-06-04 04:51:13.658184739 -0400 EDT m=+27.022974479>  
  7. [root@centos7 ~]# restic -r /restic/backup_dir/ key list  
  8. enter password for repository:   
  9. repository dff64d39 opened successfully, password is correct  
  10.  ID        User  Host     Created  
  11. ---------------------------------------------  
  12. *a62168f6  root  centos7  2021-06-04 04:51:13  
  13. ---------------------------------------------  
  14. #密碼已更新完成,ID變化上可以看出來 

常見問題

https://restic.readthedocs.io/en/latest/faq.html

更多相關的功能,及其操作,有興趣的讀者可以自行安裝體驗。民工哥我一圈體驗下來,感覺這個restic 確實是一款非常強大、快速、安全高效的備份神器,關鍵的關鍵是開源免費,太香了,強裂推薦。 

 

責任編輯:龐桂玉 來源: 民工哥技術之路
相關推薦

2021-01-08 15:49:31

數據恢復軟件軟件技術

2024-08-16 08:31:05

2020-05-26 14:15:09

開源網盤 免費

2023-09-06 08:19:53

2022-07-12 09:35:59

JSON可視化工具

2015-08-25 09:23:00

2023-06-08 08:46:37

Motrix下載工具

2020-08-28 10:40:13

PythonFaker數據

2019-02-25 10:18:43

工具代碼測試

2015-08-07 09:44:36

開源數據中心

2025-03-17 09:19:45

2011-09-16 10:35:13

Android應用數獨經典游戲

2021-08-25 11:10:41

GitHub命令Linux

2022-10-09 10:11:30

Python爬蟲神器

2017-03-06 11:02:59

產品軟件Power Desig

2023-09-13 13:32:04

數據庫開源

2021-04-27 09:00:59

PythonAidLearning編程神器

2022-04-14 11:09:17

開源項目搜索

2020-12-18 08:38:22

開源前端mitojs

2024-05-22 09:36:42

開源NET
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产亚洲一区二区在线观看 | 亚洲v日韩v综合v精品v | 国产污视频在线 | 日本黄色免费片 | 中文字幕啪啪 | 国产精品区二区三区日本 | 日韩在线成人 | 国产美女特级嫩嫩嫩bbb片 | 天堂成人国产精品一区 | 久久久久久av | 久久久久免费精品国产小说色大师 | 欧美精品二区 | 精一区二区 | 水蜜桃久久夜色精品一区 | 日韩一区二区三区在线观看视频 | 欧美视频网 | 婷婷色综合 | 欧美一区二区三区的 | 中文字幕91| 国产一区二区久久 | 成人在线免费网站 | 日韩久久久久久 | 亚洲视频一区二区三区 | 欧美日韩成人一区二区 | 国产日产欧产精品精品推荐蛮挑 | 国产一区在线免费 | 日本一区二区三区免费观看 | 中文字幕 在线观看 | 国产精品1区2区3区 一区中文字幕 | 久久精品国产一区 | 欧美乱做爰xxxⅹ久久久 | 男女羞羞网站 | 免费欧美 | 国产欧美一区二区三区在线看 | 久国产精品 | 成人久久久久 | 美女久久视频 | 99精品国自产在线 | 欧美成年人视频在线观看 | 伊人在线| 成人影院av |