b2restore


Nameb2restore JSON
Version 1.15 PyPI version JSON
download
home_page
SummaryProgram to recreate Backblaze B2 file archive at specified date+time
upload_time2023-12-29 22:57:53
maintainer
docs_urlNone
author
requires_python>=3.7
licenseGPLv3
keywords backblaze b2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## B2RESTORE
[![PyPi](https://img.shields.io/pypi/v/b2restore)](https://pypi.org/project/b2restore/)
[![AUR](https://img.shields.io/aur/version/b2restore)](https://aur.archlinux.org/packages/b2restore/)

[b2restore](http://github.com/bulletmark/b2restore) is a command line
utility which can be used with [rclone](https://rclone.org/) to
manually restore a [Backblaze B2](https://www.backblaze.com/b2/) archive
for any given date and time. Alternatively, you can create a git
repository of all date and time snapshots (subject to the
[limitations](#limitations) described below).

## Installation

Arch users can install [b2restore from the
AUR](https://aur.archlinux.org/packages/b2restore/).

Python 3.7 or later is required. Note [b2restore is on
PyPI](https://pypi.org/project/b2restore/) so just ensure that
[`python-pipx`](https://pypa.github.io/pipx/) is installed then type the
following to install:

```bash
$ pipx install b2restore
```

To upgrade:

```bash
$ pipx upgrade b2restore
```

To remove:

```bash
$ pipx uninstall b2restore
```

## Creation of initial rclone copy

This utility is typically used with [rclone](https://rclone.org/).
Simply `rclone sync` or `rclone copy` the B2 bucket or sub-paths from
the bucket which you want to restore. You **MUST** specify
`--b2-versions` to include all file versions, e.g:

```
rclone sync --b2-versions --fast-list B2:mybucket b2files
```

The above command will copy all files and available versions to the
created `b2files` directory. You only need to do this once.

## Creation of snapshot at given time

Given the above `rclone` initial copy, you run this utility to
create a snapshot of the directory tree for the time you are interested
in.

E.g. to recreate the tree of latest files, in `outdir`:

```
b2restore b2files outdir
```

E.g. to recreate the tree of files at a specified time:

```
b2restore -t 2018-01-01T09:10.00 b2files outdir
```

Just keep selecting different times to incrementally recreate `outdir`
as it existed at that time. The utility prints a line for each file
updated, created, or deleted in `outdir` compared to the previous
contents. The date and time of each updated/created/deleted file is also
listed. The target files are all hard-linked from the files in the
source directory so the `outdir` tree is created very quickly since
files do not need to be actually copied. Thus you can conveniently
experiment with the time string to quickly see file differences.

Rather than specifying an explicit time string using `-t/--time`, you
can instead choose to use `-f/--filetime` to specify any one specific
file's modification time at which to recreate the target tree of files.

You may wish to manually `git commit` each snapshot you create in the
outdir tree between your manually time-selected runs. If so, you will
need to add the `-g` switch to prevent `b2restore` from deleting your
top level `.git/` repo on each run.

Note that this utility does not recreate empty directory hierarchies.
All empty directories in the target tree are deleted.

## Limitations

If you want to restore a snapshot of your files for a specific
date/time, then unfortunately the metadata returned by
[rclone](https://rclone.org/) from [Backblaze
B2](https://www.backblaze.com/b2/) is not sufficient to create a
completely legitimate snapshot. However, all files restored for a
specific date/time will contain correct contents, the only issue is that
there may be some files which were actually deleted by that date but
those files may still be present. An example best illustrates the issue:

Say you run a rclone backup every night at 0000 am to B2:mybucket.

1. On 01-Jan you create a file `a.txt`.
2. On 02-Jan you delete file `a.txt`.
3. On 03-Jan you create file `a.txt` again (but with different content to 01-Jan).
4. On 04-Jan you retrieve the latest archive using `rclone sync
   --b2-versions --fast-list B2:mybucket b2files`.

If you run `b2restore b2files outdir` then you will get the latest
03-Jan version of `a.txt` in `outdir`. If you then run `b2restore -t<time>
b2files outdir` for 01-Jan, then you will get `a.txt` with the correct
content from 01-Jan. However, if run that command for 02-Jan, then you
will still see the `a.txt` file and content corresponding to 01-Jan
(when it actually should be deleted for that day). If you are only using
b2restore to find and restore one or more files for specific date/times, then
this is not a serious practical problem. There may be some extra files
around, but all files are correct for the specified date/time.

## Command line options

```
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

options:
  -h, --help            show this help message and exit
  -t TIME, --time TIME  set time YYYY-MM-DD[THH: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
```

## Creation of git repository of all snapshots

Rather than run `b2restore` for the given date + times you are
interested in, you can instead choose to run the provided
`b2restore-create-git` utility to automatically create a git repository
of snapshots of files for all the dates + times inherent in the `rclone`
initial copy.

So after performing the `rclone` initial copy above, run the following
command to create a complete git repository:

```
b2restore-create-git b2files outdir
```

Then `cd outdir` and run `git log` etc to view the history.

### b2restore-create-git command line options

```
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)
```

## Test run utility

A command line utility `b2restore-create-dummy-files` is included to
facilitate testing `b2restore` on your restored file tree without
actually downloading any files from your B2 archive(!). This utility
parses `rclone lsl` output to recreate your B2 bucket directory and
hierarchy of file versions. Only the file names are recreated of course,
the file contents are set to their actual byte size but with random byte
contents (or zero filled if you specify `-z`, or to zero length if you
specify `-s`).

This utility requires almost nothing to download from your B2 archive
and runs extremely quickly. You can then run `b2restore` against this
dummy archive to simulate what files are changed between versions, etc.
It is also good to get a feel for how `b2restore` works, what it does,
and whether it suits your needs without requiring you to first perform
an onerous huge download of your entire B2 archive.

Here is an example usage:

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

### b2restore-create-dummy-files command line options

```
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)
```

## License

Copyright (C) 2018 Mark Blakeney. This program is distributed under the
terms of the GNU General Public License.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or any later
version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License at <http://www.gnu.org/licenses/> for more details.

<!-- vim: se ai syn=markdown: -->

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "b2restore",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "backblaze,b2",
    "author": "",
    "author_email": "Mark Blakeney <mark.blakeney@bullet-systems.net>",
    "download_url": "https://files.pythonhosted.org/packages/34/08/f4b8c59b55b248e421cf412c543fc6379eddf0ca7ca5847066c331fb2fc8/b2restore-1.15.tar.gz",
    "platform": null,
    "description": "## B2RESTORE\n[![PyPi](https://img.shields.io/pypi/v/b2restore)](https://pypi.org/project/b2restore/)\n[![AUR](https://img.shields.io/aur/version/b2restore)](https://aur.archlinux.org/packages/b2restore/)\n\n[b2restore](http://github.com/bulletmark/b2restore) is a command line\nutility which can be used with [rclone](https://rclone.org/) to\nmanually restore a [Backblaze B2](https://www.backblaze.com/b2/) archive\nfor any given date and time. Alternatively, you can create a git\nrepository of all date and time snapshots (subject to the\n[limitations](#limitations) described below).\n\n## Installation\n\nArch users can install [b2restore from the\nAUR](https://aur.archlinux.org/packages/b2restore/).\n\nPython 3.7 or later is required. Note [b2restore is on\nPyPI](https://pypi.org/project/b2restore/) so just ensure that\n[`python-pipx`](https://pypa.github.io/pipx/) is installed then type the\nfollowing to install:\n\n```bash\n$ pipx install b2restore\n```\n\nTo upgrade:\n\n```bash\n$ pipx upgrade b2restore\n```\n\nTo remove:\n\n```bash\n$ pipx uninstall b2restore\n```\n\n## Creation of initial rclone copy\n\nThis utility is typically used with [rclone](https://rclone.org/).\nSimply `rclone sync` or `rclone copy` the B2 bucket or sub-paths from\nthe bucket which you want to restore. You **MUST** specify\n`--b2-versions` to include all file versions, e.g:\n\n```\nrclone sync --b2-versions --fast-list B2:mybucket b2files\n```\n\nThe above command will copy all files and available versions to the\ncreated `b2files` directory. You only need to do this once.\n\n## Creation of snapshot at given time\n\nGiven the above `rclone` initial copy, you run this utility to\ncreate a snapshot of the directory tree for the time you are interested\nin.\n\nE.g. to recreate the tree of latest files, in `outdir`:\n\n```\nb2restore b2files outdir\n```\n\nE.g. to recreate the tree of files at a specified time:\n\n```\nb2restore -t 2018-01-01T09:10.00 b2files outdir\n```\n\nJust keep selecting different times to incrementally recreate `outdir`\nas it existed at that time. The utility prints a line for each file\nupdated, created, or deleted in `outdir` compared to the previous\ncontents. The date and time of each updated/created/deleted file is also\nlisted. The target files are all hard-linked from the files in the\nsource directory so the `outdir` tree is created very quickly since\nfiles do not need to be actually copied. Thus you can conveniently\nexperiment with the time string to quickly see file differences.\n\nRather than specifying an explicit time string using `-t/--time`, you\ncan instead choose to use `-f/--filetime` to specify any one specific\nfile's modification time at which to recreate the target tree of files.\n\nYou may wish to manually `git commit` each snapshot you create in the\noutdir tree between your manually time-selected runs. If so, you will\nneed to add the `-g` switch to prevent `b2restore` from deleting your\ntop level `.git/` repo on each run.\n\nNote that this utility does not recreate empty directory hierarchies.\nAll empty directories in the target tree are deleted.\n\n## Limitations\n\nIf you want to restore a snapshot of your files for a specific\ndate/time, then unfortunately the metadata returned by\n[rclone](https://rclone.org/) from [Backblaze\nB2](https://www.backblaze.com/b2/) is not sufficient to create a\ncompletely legitimate snapshot. However, all files restored for a\nspecific date/time will contain correct contents, the only issue is that\nthere may be some files which were actually deleted by that date but\nthose files may still be present. An example best illustrates the issue:\n\nSay you run a rclone backup every night at 0000 am to B2:mybucket.\n\n1. On 01-Jan you create a file `a.txt`.\n2. On 02-Jan you delete file `a.txt`.\n3. On 03-Jan you create file `a.txt` again (but with different content to 01-Jan).\n4. On 04-Jan you retrieve the latest archive using `rclone sync\n   --b2-versions --fast-list B2:mybucket b2files`.\n\nIf you run `b2restore b2files outdir` then you will get the latest\n03-Jan version of `a.txt` in `outdir`. If you then run `b2restore -t<time>\nb2files outdir` for 01-Jan, then you will get `a.txt` with the correct\ncontent from 01-Jan. However, if run that command for 02-Jan, then you\nwill still see the `a.txt` file and content corresponding to 01-Jan\n(when it actually should be deleted for that day). If you are only using\nb2restore to find and restore one or more files for specific date/times, then\nthis is not a serious practical problem. There may be some extra files\naround, but all files are correct for the specified date/time.\n\n## Command line options\n\n```\nusage: b2restore [-h] [-t TIME | -f FILETIME] [-s] [-g] [-p PATH]\n                 indir [outdir]\n\nProgram to recreate Backblaze B2 file archive at specified date and time.\n\npositional arguments:\n  indir                 input B2 archive containing all file versions (from\n                        --b2-versions)\n  outdir                output directory to recreate for given time\n\noptions:\n  -h, --help            show this help message and exit\n  -t TIME, --time TIME  set time YYYY-MM-DD[THH:MM[.SS]], default=latest\n  -f FILETIME, --filetime FILETIME\n                        set time based on specified file\n  -s, --summary         just print a summary of files and versions\n  -g, --gitkeep         preserve any top level git dir in outdir\n  -p PATH, --path PATH  only process files under given path\n```\n\n## Creation of git repository of all snapshots\n\nRather than run `b2restore` for the given date + times you are\ninterested in, you can instead choose to run the provided\n`b2restore-create-git` utility to automatically create a git repository\nof snapshots of files for all the dates + times inherent in the `rclone`\ninitial copy.\n\nSo after performing the `rclone` initial copy above, run the following\ncommand to create a complete git repository:\n\n```\nb2restore-create-git b2files outdir\n```\n\nThen `cd outdir` and run `git log` etc to view the history.\n\n### b2restore-create-git command line options\n\n```\nUsage: b2restore-create-git [-options] indir outdir\nCreate git repository from given B2 rclone copy.\nOptions:\n-t YYYY-MM-DDTHH:MM.SS (start git repo from given time)\n-e YYYY-MM-DDTHH:MM.SS (end git repo before given time)\n-p (only process files under given path)\n```\n\n## Test run utility\n\nA command line utility `b2restore-create-dummy-files` is included to\nfacilitate testing `b2restore` on your restored file tree without\nactually downloading any files from your B2 archive(!). This utility\nparses `rclone lsl` output to recreate your B2 bucket directory and\nhierarchy of file versions. Only the file names are recreated of course,\nthe file contents are set to their actual byte size but with random byte\ncontents (or zero filled if you specify `-z`, or to zero length if you\nspecify `-s`).\n\nThis utility requires almost nothing to download from your B2 archive\nand runs extremely quickly. You can then run `b2restore` against this\ndummy archive to simulate what files are changed between versions, etc.\nIt is also good to get a feel for how `b2restore` works, what it does,\nand whether it suits your needs without requiring you to first perform\nan onerous huge download of your entire B2 archive.\n\nHere is an example usage:\n\n```\nrclone lsl --b2-versions B2:mybucket | b2restore-create-dummy-files b2files\nb2restore b2files outdir\ndu -shl outdir # (see how much storage tree of latest versions uses)\nb2restore -t 2018-05-10T12:00.00 b2files outdir\ndu -shl outdir # (see how much storage tree of yesterdays versions uses)\n```\n\n### b2restore-create-dummy-files command line options\n\n```\nUsage: b2restore-create-dummy-files [-options] outdir\nReads B2 file list (from lsl output) from standard input to create\ndummy tree of files.\nOptions:\n-z (zero fill files, not with random content which is default)\n-s (set files to zero length, not their actual size)\n-p (only process files under given path)\n```\n\n## License\n\nCopyright (C) 2018 Mark Blakeney. This program is distributed under the\nterms of the GNU General Public License.\nThis program is free software: you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the\nFree Software Foundation, either version 3 of the License, or any later\nversion.\nThis program is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General\nPublic License at <http://www.gnu.org/licenses/> for more details.\n\n<!-- vim: se ai syn=markdown: -->\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "Program to recreate Backblaze B2 file archive at specified date+time",
    "version": "1.15",
    "project_urls": {
        "Homepage": "https://github.com/bulletmark/b2restore"
    },
    "split_keywords": [
        "backblaze",
        "b2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97246df907091334616692d191e9cb732cae3ccea4e479ca403c94a1305e1788",
                "md5": "990986eb379ba9f7472b49e2d2321eb2",
                "sha256": "4c8c03da3018ebb17d77401754a358c0e63b59020fb4d15939fd7a421e9053e4"
            },
            "downloads": -1,
            "filename": "b2restore-1.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "990986eb379ba9f7472b49e2d2321eb2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9651,
            "upload_time": "2023-12-29T22:57:51",
            "upload_time_iso_8601": "2023-12-29T22:57:51.641525Z",
            "url": "https://files.pythonhosted.org/packages/97/24/6df907091334616692d191e9cb732cae3ccea4e479ca403c94a1305e1788/b2restore-1.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3408f4b8c59b55b248e421cf412c543fc6379eddf0ca7ca5847066c331fb2fc8",
                "md5": "4819ac1196e90706cf233deb0baee673",
                "sha256": "12a4999e65d7d870eae8f2c2ba591e9315a73b4595313b504ee939020a0ac524"
            },
            "downloads": -1,
            "filename": "b2restore-1.15.tar.gz",
            "has_sig": false,
            "md5_digest": "4819ac1196e90706cf233deb0baee673",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 9083,
            "upload_time": "2023-12-29T22:57:53",
            "upload_time_iso_8601": "2023-12-29T22:57:53.719156Z",
            "url": "https://files.pythonhosted.org/packages/34/08/f4b8c59b55b248e421cf412c543fc6379eddf0ca7ca5847066c331fb2fc8/b2restore-1.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-29 22:57:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bulletmark",
    "github_project": "b2restore",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "b2restore"
}
        
Elapsed time: 0.16904s