From f2b222b2c2fb7d5647d4cf9a7e8aac80dbe39e6b Mon Sep 17 00:00:00 2001 From: enkore Date: Wed, 15 Mar 2017 17:08:07 +0100 Subject: [PATCH 1/3] Archive: allocate zeros when needed (#2308) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes huge memory usage of mount (8 MiB × number of archives) (cherry picked from commit 883a7eefb2d0301cd0e178ccd2da8480b2e1ac95) --- borg/archive.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/borg/archive.py b/borg/archive.py index 178ad94b8..0c57680f4 100644 --- a/borg/archive.py +++ b/borg/archive.py @@ -204,6 +204,7 @@ class Archive: if start is None: start = datetime.utcnow() start_monotonic = time.monotonic() + self.chunker_params = chunker_params self.start = start self.start_monotonic = start_monotonic if end is None: @@ -227,7 +228,7 @@ class Archive: raise self.DoesNotExist(name) info = self.manifest.archives[name] self.load(info[b'id']) - self.zeros = b'\0' * (1 << chunker_params[1]) + self.zeros = None def _load_meta(self, id): data = self.key.decrypt(id, self.repository.get(id)) @@ -405,6 +406,8 @@ Number of files: {0.stats.nfiles}'''.format( with backup_io(): os.link(source, path) else: + if sparse and self.zeros is None: + self.zeros = b'\0' * (1 << self.chunker_params[1]) with backup_io(): fd = open(path, 'wb') with fd: From 8b2c9fd7db1ac63b6738c17af4c1079edcc7ae41 Mon Sep 17 00:00:00 2001 From: Fredrik Mikker Date: Fri, 24 Mar 2017 00:49:08 +0100 Subject: [PATCH 2/3] Added FAQ section about backing up root partition Using borgbackup to backup the root partition works fine, just remember to exclude non-essential directories. Signed-off-by: Fredrik Mikker (cherry picked from commit d01a8f54b6bbc524021e5a370b97ea870af5d46d) Plus typo-fix by @enkore. (cherry picked from commit dfdf590445beb5ff66a19d599ee51b25472c3724) --- docs/faq.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/faq.rst b/docs/faq.rst index 6c69d60b5..fbf213768 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -321,6 +321,13 @@ for a potential solution. Please note that this workaround only helps you for backup, not for restore. +Can I backup my root partition (/) with Borg? +--------------------------------------------- + +Backing up your entire root partition works just fine, but remember to +exclude directories that make no sense to backup, such as /dev, /proc, +/sys, /tmp and /run. + If it crashes with a UnicodeError, what can I do? ------------------------------------------------- From b1466f530b99de1b2b8e219495efc832d6a9fe2d Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Sat, 25 Mar 2017 15:41:11 +0100 Subject: [PATCH 3/3] docs: kill api page (cherry picked from commit 475d53d9ef8e3dc6c91b3aada499c4196b366f20) --- docs/api.rst | 86 -------------------------------------------- docs/development.rst | 13 ++++--- setup.py | 35 ------------------ 3 files changed, 6 insertions(+), 128 deletions(-) delete mode 100644 docs/api.rst diff --git a/docs/api.rst b/docs/api.rst deleted file mode 100644 index f05cdbc29..000000000 --- a/docs/api.rst +++ /dev/null @@ -1,86 +0,0 @@ - -.. IMPORTANT: this file is auto-generated by "setup.py build_api", do not edit! - - -API Documentation -================= - -.. automodule:: borg.archive - :members: - :undoc-members: - -.. automodule:: borg.archiver - :members: - :undoc-members: - -.. automodule:: borg.cache - :members: - :undoc-members: - -.. automodule:: borg.chunker - :members: - :undoc-members: - -.. automodule:: borg.compress - :members: get_compressor, Compressor, CompressorBase - :undoc-members: - -.. automodule:: borg.crypto - :members: - :undoc-members: - -.. automodule:: borg.fuse - :members: - :undoc-members: - -.. automodule:: borg.hashindex - :members: - :undoc-members: - -.. automodule:: borg.helpers - :members: - :undoc-members: - -.. automodule:: borg.key - :members: - :undoc-members: - -.. automodule:: borg.keymanager - :members: - :undoc-members: - -.. automodule:: borg.locking - :members: - :undoc-members: - -.. automodule:: borg.logger - :members: - :undoc-members: - -.. automodule:: borg.lrucache - :members: - :undoc-members: - -.. automodule:: borg.platform - :members: - :undoc-members: - -.. automodule:: borg.platform_linux - :members: - :undoc-members: - -.. automodule:: borg.remote - :members: - :undoc-members: - -.. automodule:: borg.repository - :members: - :undoc-members: - -.. automodule:: borg.shellpattern - :members: - :undoc-members: - -.. automodule:: borg.xattr - :members: - :undoc-members: diff --git a/docs/development.rst b/docs/development.rst index afc1e21a9..7dc2941ac 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -183,20 +183,19 @@ Important notes: Regenerate usage files ---------------------- -Usage and API documentation is currently committed directly to git, +Usage documentation is currently committed directly to git, although those files are generated automatically from the source tree. -When a new module is added, the ``docs/api.rst`` file needs to be -regenerated:: - - ./setup.py build_api - When a command is added, a commandline flag changed, added or removed, the usage docs need to be rebuilt as well:: ./setup.py build_usage +However, we prefer to do this as part of our :ref:`releasing` +preparations, so it is generally not necessary to update these when +submitting patches that change something about the command line. + Building the docs with Sphinx ----------------------------- @@ -270,7 +269,7 @@ Checklist: - update ``CHANGES.rst``, based on ``git log $PREVIOUS_RELEASE..`` - check version number of upcoming release in ``CHANGES.rst`` - verify that ``MANIFEST.in`` and ``setup.py`` are complete -- ``python setup.py build_api ; python setup.py build_usage`` and commit +- ``python setup.py build_usage`` and commit - tag the release:: git tag -s -m "tagged/signed release X.Y.Z" X.Y.Z diff --git a/setup.py b/setup.py index e3b8beb9e..8f65963d5 100644 --- a/setup.py +++ b/setup.py @@ -213,43 +213,8 @@ class build_usage(Command): return is_subcommand -class build_api(Command): - description = "generate a basic api.rst file based on the modules available" - - user_options = [ - ('output=', 'O', 'output directory'), - ] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - print("auto-generating API documentation") - with open("docs/api.rst", "w") as doc: - doc.write(""" -.. IMPORTANT: this file is auto-generated by "setup.py build_api", do not edit! - - -API Documentation -================= -""") - for mod in sorted(glob('borg/*.py') + glob('borg/*.pyx')): - print("examining module %s" % mod) - mod = mod.replace('.pyx', '').replace('.py', '').replace('/', '.') - if "._" not in mod: - doc.write(""" -.. automodule:: %s - :members: - :undoc-members: -""" % mod) - - cmdclass = { 'build_ext': build_ext, - 'build_api': build_api, 'build_usage': build_usage, 'sdist': Sdist }