restic on Windows

1.安装restic(使用winget)

打开Powershell或CMD,输入以下命令:

winget search restic
名称               ID                             版本   匹配        源
---------------------------------------------------------------------------
restic             restic.restic                  0.18.1             winget
resticprofile      creativeprojects.resticprofile 0.32.0 Tag: restic winget
restic-browser     emuell.restic-browser          v0.3.3 Tag: restic winget
Backrest           garethgeorge.Backrest          1.10.1 Tag: restic winget
Restic REST Server restic.server                  0.14.0             winget
PS C:\Users\X> winget install --exact --id restic.restic --scope Machine
已找到 restic [restic.restic] 版本 0.18.1
此应用程序由其所有者授权给你。
Microsoft 对第三方程序包概不负责,也不向第三方程序包授予任何许可证。
正在下载 https://github.com/restic/restic/releases/download/v0.18.1/restic_0.18.1_windows_amd64.zip
  ██████████████████████████████  10.7 MB / 10.7 MB
已成功验证安装程序哈希
正在提取存档...
已成功提取存档
正在启动程序包安装...
添加了命令行别名: "restic"
已修改路径环境变量;重启 shell 以使用新值。
已成功安装

 

以上,其中,添加了一个 --scoop machine 参数,这个参数表示为所有用户安装,如果没有添加这个参数,那么就默认为当前用户安装。

2. Initialize the repository (first time only):

restic init --repo D:\Backup\restic-repo

 根据提示输入密码即可。

3.备份:

restic -r D:/Backup/restic-repo --verbose=2 backup D:/Documents

 以上命令即备份 D:/Documents

4.查看备份:

restic -r D:/Backup/restic-repo snapshots
enter password for repository:
repository 3604a61c opened (version 2, compression level auto)
ID        Time                 Host        Tags        Paths         Size
-------------------------------------------------------------------------------
94975e75  2025-10-30 08:25:45  SPACE                   D:\Documents  41.321 KiB
3114ce27  2025-10-30 08:44:09  SPACE                   D:\Documents  41.321 KiB
-------------------------------------------------------------------------------
2 snapshots

 5.删除快照:

restic -r D:/Backup/restic-repo forget 94975e75
enter password for repository:
repository 3604a61c opened (version 2, compression level auto)
[0:00] 100.00%  1 / 1 files deleted

restic -r D:/Backup/restic-repo snapshots
enter password for repository:
repository 3604a61c opened (version 2, compression level auto)
ID        Time                 Host        Tags        Paths         Size
-------------------------------------------------------------------------------
3114ce27  2025-10-30 08:44:09  SPACE                   D:\Documents  41.321 KiB
-------------------------------------------------------------------------------
1 snapshots

restic -r D:/Backup/restic-repo prune
enter password for repository:
repository 3604a61c opened (version 2, compression level auto)
loading indexes...
[0:00] 100.00%  1 / 1 index files loaded
loading all snapshots...
finding data that is still in use for 1 snapshots
[0:00] 100.00%  1 / 1 snapshots
searching used packs...
collecting packs for deletion and repacking
[0:00] 100.00%  2 / 2 packs processed

to repack:             0 blobs / 0 B
this removes:          0 blobs / 0 B
to delete:             0 blobs / 0 B
total prune:           0 blobs / 0 B
remaining:            39 blobs / 50.267 KiB
unused size after prune: 0 B (0.00% of remaining size)

done

 6.验证所有数据都正确地存储在存储库中:

 

restic check -r D:/Backup/restic-repo
using temporary cache in C:\Users\X\AppData\Local\Temp\restic-check-cache-3358689233
create exclusive lock for repository
enter password for repository:
repository c42e0a65 opened (version 2, compression level auto)
created new cache in C:\Users\X\AppData\Local\Temp\restic-check-cache-3358689233
load indexes
[0:00] 100.00%  3 / 3 index files loaded
check all packs
check snapshots, trees and blobs
[0:00] 100.00%  3 / 3 snapshots
no errors were found

 

7.恢复快照:

restic -r D:/Backup/restic-repo restore 3114ce27 --target D:/f
enter password for repository:
repository 3604a61c opened (version 2, compression level auto)
[0:00] 100.00%  1 / 1 index files loaded
restoring snapshot 3114ce27 of [D:\Documents] at 2025-10-30 08:44:09.2127904 +0800 CST by SPACE\X@SPACE to D:/f
Summary: Restored 45 files/dirs (41.321 KiB) in 0:00

 

That's All.

 

posted @ 2026-02-03 16:46  陈书年  阅读(8)  评论(0)    收藏  举报