在指定日期+时间重新创建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 sync
或rclone 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存储库
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
而不是在给定的日期+时间内运行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)
测试运行实用程序
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)
许可证
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/上的公共许可证。