在指定日期+时间重新创建Backblaze B2文件存档的程序

b2restore的Python项目详细描述


b2还原

b2restore是命令行 可与rclone一起使用的实用程序 手动还原Backblaze B2存档 任何给定的日期和时间。或者,您可以创建一个git 所有日期和时间快照的存储库。

安装

arch用户可以安装b2restore from the AUR

需要Python3.5或更高版本。注意b2restore is on PyPI以便您可以sudo pip install b2restore或:

$ git clone http://github.com/bulletmark/b2restore
$ sudo make install

创建初始rclone副本

此实用程序通常与rclone一起使用。 简单地rclone syncrclone copy来自 你要还原的桶。必须指定--b2-versions包括所有文件版本,例如:

mkdir b2files
rclone sync --b2-versions --fast-list --transfers=4 $* B2:mybucket b2files

上面的命令将所有文件和可用版本复制到 b2files目录。你只需要做一次。

在给定时间创建快照

给定上述rclone初始副本,您可以运行此实用程序 为感兴趣的时间创建目录树的快照 在。

例如,要重新创建最新文件的树,请在outdir

b2restore b2files outdir

例如,要在指定时间重新创建文件树:

b2restore -t 2018-01-01T09:10:00 b2files outdir

只要不断选择不同的时间以增量方式重新创建outdir 因为当时它存在。该实用程序为每个文件打印一行 在outdir中更新、创建或删除 内容。每个更新/创建/删除文件的日期和时间 上市的。目标文件都与 因此,outdir树创建得非常快,因为 不需要实际复制文件。这样你就方便了 尝试使用时间字符串快速查看文件差异。

与其使用-t/--time指定显式时间字符串,不如 可以选择使用-f/--filetime来指定任何一个特定的 文件的修改时间,在该时间重新创建文件的目标树。

请注意,此实用程序不会重新创建空目录层次结构。 将删除目标树中的所有空目录。

b2restore命令行选项
usage: b2restore [-h] [-t TIME | -f FILETIME] [-s] [-g] [-p PATH]
                 indir [outdir]

Program to recreate Backblaze B2 file archive at specified date and time.

positional arguments:
  indir                 input B2 archive containing all file versions (from
                        --b2-versions)
  outdir                output directory to recreate for given time

optional arguments:
  -h, --help            show this help message and exit
  -t TIME, --time TIME  set time YYYY-MM-DDTHH:MM.SS, default=latest
  -f FILETIME, --filetime FILETIME
                        set time based on specified file
  -s, --summary         just print a summary of files and versions
  -g, --gitkeep         preserve any top level git dir in outdir
  -p PATH, --path PATH  only process files under given path

创建所有快照的git存储库

而不是在给定的日期+时间内运行b2restore 您可以选择运行提供的 b2restore-create-git自动创建git存储库的实用程序 所有日期+时间的文件快照 初始副本。

因此,在执行上面的rclone初始复制之后,运行以下命令 创建完整git存储库的命令:

b2restore-create-git b2files outdir

然后cd outdir并运行git log等来查看历史。

b2restore-create-git命令行选项
Usage: b2restore-create-git [-options] indir outdir
Create git repository from given B2 rclone copy.
Options:
-t YYYY-MM-DDTHH:MM.SS (start git repo from given time)
-e YYYY-MM-DDTHH:MM.SS (end git repo before given time)
-p (only process files under given path)

测试运行实用程序

命令行实用程序b2restore-create-dummy-files包含在 方便在还原的文件树上测试b2restore,而不需要 实际上从你的b2档案中下载任何文件(!)。此实用程序 分析rclone lsl输出以重新创建b2 bucket目录,并 文件版本的层次结构。当然只会重新创建文件名, 文件内容设置为其实际字节大小,但使用随机字节 内容(如果指定-z,则为零填充;如果指定-z,则为零长度 指定-s)。

此实用程序几乎不需要从您的b2存档下载任何内容 跑得非常快。然后可以针对这个运行b2restore 虚拟存档以模拟版本之间更改的文件等。 了解b2restore的工作原理和功能也很好, 它是否适合你的需要而不需要你先表演 一个庞大的下载整个b2档案。

下面是一个用法示例:

rclone lsl --b2-versions B2:mybucket | b2restore-create-dummy-files allfiles
b2restore allfiles b2
du -shl b2 # (see how much storage tree of latest versions uses)
b2restore -t 2018-05-10T12:00.00 allfiles b2
du -shl b2 # (see how much storage tree of yesterdays versions uses)

b2restore-create-dummy-files命令行选项
Usage: b2restore-create-dummy-files [-options] outdir
Reads B2 file list (from lsl output) from standard input to create
dummy tree of files.
Options:
-z (zero fill files, not with random content which is default)
-s (set files to zero length, not their actual size)
-p (only process files under given path)

许可证

版权所有(c)2018 Mark Blakeney。这个程序在 GNU通用公共许可条款。 这个程序是免费软件:你可以重新发布和/或修改它 根据 免费的软件基础,许可证的版本3或更高版本 版本。 这个程序的发布是希望它会有用,但是 没有任何保证;甚至没有 适销性或适合某一特定目的的适销性。见GNU将军 有关详细信息,请访问http://www.gnu.org/licenses/上的公共许可证。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java什么类似于安卓中iOS的VOIP推送和呼叫工具包,用于呼叫   java广播接收器第二次不工作   从maven本地导入java   java如何在jdbc中执行oracle过程   java单击按钮时如何更改JButton上的图像?   java Univocity如何将3(n)行解析为一行(bean)   java消除了字符串中出现的所有特定模式   javascript为什么Js不能从我的web服务目录加载图像文件?   pdf如何在没有AdobeAcrobat的情况下在Java中自动创建字段   反思如何以编程方式创建java文件   AmazonWeb服务java。木卫一。IOException:尝试读取aws s3存储桶上的关闭流   java如何在kotlin中映射基于升序的数组列表和排序   java执行一个方法的时间片段出现   不使用'synchronized'关键字的java线程安全代码?   使用Java小程序在浏览器中滚动至顶部   避免“ZLIB输入流意外结束”的java计时要求