使用 7zip 进行增量备份

gya*_*guy 21 backup incremental-backup 7-zip

我用谷歌搜索过,但找不到 7zip 命令行实用程序用于进行增量备份的命令。那么有人可以分享命令吗?

谢谢

顺便说一句,我找到了这个链接:http : //wmug.co.uk/wmug/b/sean/archive/2009/03/20/powershell-amp-7zip-incremental-backup-solution.aspx。但它似乎是用于差异备份,即使它说是增量备份。

Art*_*mGr 13

应该很简单,使用它来创建和增量更新存档:

7zr u -up0q3r2x2y2z1w2 {archive}.7z {path}
Run Code Online (Sandbox Code Playgroud)

此页面提供更新选项的参考。

它们翻译如下:

  • p0 - 如果“文件存在于存档中,但与通配符不匹配”,则从存档中删除该文件。
  • q3- 如果“文件存在于存档中,但不存在于磁盘上”,则从存档中删除该文件,并在提取时将其从文件系统中删除
  • r2 - 如果“文件在存档中不存在,但在磁盘上存在”,则将文件打包到存档中。
  • x2 - 如果“存档中的文件比磁盘上的文件新”,则“将文件从磁盘压缩到新存档”。
  • y2 - 如果“存档中的文件比磁盘上的文件旧”,则将较新的文件打包到存档中。
  • z1 - 如果“存档中的文件与磁盘上的文件相同”,则重新使用该文件的打包版本。
  • w2 - 如果文件大小不同,则将修改后的文件打包到存档中。

请注意,只有压缩是增量的:也就是说,7-Zip 只会压缩更新,重用未更新的压缩文件。带有存档的文件仍会由 7-Zip重新创建

  • 它不是增量备份。此命令进行差异备份并创建包含自上次完整备份以来更改的新存档。增量备份跟踪自上次增量备份以来的更改(差异的差异)。 (7认同)

Jav*_*ier 10

如果您要进行增量备份,则需要提供 7-zip 和修改后的文件列表(使用-i@fileList),并且您需要以某种方式详细说明此类列表。在已删除问题的存档.org镜像中,通过拇指驱动器离线增量备份,您可以找到使用 md5 签名的 Unix 命令行来创建文件列表。

7-zip 更新操作允许使用自基本/主要存档以来发生的差异(包括已删除的文件)创建辅助存档。这被正确命名为差异备份(如问题本身所述)。

我在WPCTips "Differential Backups with 7-zip"(archived)上找到了一篇关于这个主题的优秀文章。他们建议使用 GUI 程序 (Toucan),或者在命令行中使用这个秘籍:

7z u {base archive.7z} -u- -"up0q3r2x2y2z0w2!{differential.7z}" {folder to archive}
Run Code Online (Sandbox Code Playgroud)

这与7zr u -up0q3r2x2y2z1w2 {archive}.7z {path}ArtemGr 提出的有点不同:

  • -u- 告诉主存档不应该被修改
  • "-up0q3r2x2y2z0w2!{differential.7z}"指定目标差异存档,以及针对每个条件/状态对每个文件执行的操作:添加文件系统中新的或修改过的文件,删除仅在 7zip 存档中的文件,忽略其余文件。
    注意“!” bash除非被引用,否则字符将被拦截。

以防万一你对那个神秘的细节感到好奇 p0q3r2x2y2z0w2

<state> | State condition
p | File exists in archive, but is not matched with wildcard.   Exists, but is   not matched 
q | File exists in archive, but doesn't exist on disk.
r | File doesn't exist in archive, but exists on disk.
x | File in archive is newer than the file on disk.
y | File in archive is older than the file on disk.
z | File in archive is same as the file on disk
w | Can not be detected what file is newer (times are the same, sizes are different)

<action> | Description 
0 | Ignore file (don't create item in new archive for this file) 
1 | Copy file (copy from old archive to new) 
2 | Compress (compress file from disk to new archive) 
3 | Create Anti-item (item that will delete file or directory during extracting). This feature is supported only in 7z format. 
Run Code Online (Sandbox Code Playgroud)

  • 感谢 Javier 的回答,欢迎使用超级用户。这里有一个汇总链接的策略,以防它们消失 - 您能解释一下该命令是如何实现增量备份的吗?(特别是`up0q3r2x2y2z0w2`部分!)谢谢:-) (2认同)

小智 5

您可以通过及时更改方向轻松进行增量备份。即,您始终将最新备份作为完整副本保留,并将差异文件保留在过去。

# create the difference step into the past
7z u {base archive.7z} {folder to archive} -mx=9 -u- -up1q1r3x1y1z0w1!{decrement.7z}

# update the Archive to the latest files
7z u {base archive.7z} {folder to archive} -mx=9 -up0q0x2
Run Code Online (Sandbox Code Playgroud)

基础存档始终包含最新版本,通过逐步应用“递减”,您可以重新创建旧版本。通过编写一些脚本,您可以对递减文件应用正确的编号。