mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-04 02:28:34 +00:00
Repository: cleanup on ENOSPC
This commit is contained in:
parent
6977fcf9e2
commit
7ed425dae0
3 changed files with 15 additions and 4 deletions
|
@ -84,6 +84,12 @@ class Repository:
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
if exc_type is not None:
|
if exc_type is not None:
|
||||||
|
no_space_left_on_device = exc_type is OSError and exc_val.errno == errno.ENOSPC
|
||||||
|
# The ENOSPC could have originated somewhere else besides the Repository. The cleanup is always safe, unless
|
||||||
|
# EIO or FS corruption ensues, which is why we specifically check for ENOSPC.
|
||||||
|
if self._active_txn and no_space_left_on_device:
|
||||||
|
logger.warning('No space left on device, cleaning up partial transaction to free space.')
|
||||||
|
self.io.cleanup(self.io.get_segments_transaction_id())
|
||||||
self.rollback()
|
self.rollback()
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
@ -543,7 +549,7 @@ class LoggedIO:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_segments_transaction_id(self):
|
def get_segments_transaction_id(self):
|
||||||
"""Verify that the transaction id is consistent with the index transaction id
|
"""Return last committed segment
|
||||||
"""
|
"""
|
||||||
for segment, filename in self.segment_iterator(reverse=True):
|
for segment, filename in self.segment_iterator(reverse=True):
|
||||||
if self.is_committed_segment(segment):
|
if self.is_committed_segment(segment):
|
||||||
|
|
|
@ -280,6 +280,7 @@ emptied to 25%, its size is shrinked. So operations on it have a variable
|
||||||
complexity between constant and linear with low factor, and memory overhead
|
complexity between constant and linear with low factor, and memory overhead
|
||||||
varies between 33% and 300%.
|
varies between 33% and 300%.
|
||||||
|
|
||||||
|
.. _cache-memory-usage:
|
||||||
|
|
||||||
Indexes / Caches memory usage
|
Indexes / Caches memory usage
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
|
@ -11,11 +11,15 @@ The next section continues by showing how backups can be automated.
|
||||||
Important note about free space
|
Important note about free space
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
Before you start creating backups, please make sure that there is **always**
|
Before you start creating backups, please make sure that there is *always*
|
||||||
a good amount of free space on the filesystem that has your backup repository
|
a good amount of free space on the filesystem that has your backup repository
|
||||||
(and also on ~/.cache). It is hard to tell how much, maybe 1-5%.
|
(and also on ~/.cache). A few GB should suffice for most hard-drive sized
|
||||||
|
repositories. See also :ref:`cache-memory-usage`.
|
||||||
|
|
||||||
If you run out of disk space, it can be hard or impossible to free space,
|
If |project_name| runs out of disk space, it tries to free as much space as it
|
||||||
|
can while aborting the current operation safely, which allows to free more space
|
||||||
|
by deleting/pruning archives. This mechanism is not bullet-proof though.
|
||||||
|
If you *really* run out of disk space, it can be hard or impossible to free space,
|
||||||
because |project_name| needs free space to operate - even to delete backup
|
because |project_name| needs free space to operate - even to delete backup
|
||||||
archives. There is a ``--save-space`` option for some commands, but even with
|
archives. There is a ``--save-space`` option for some commands, but even with
|
||||||
that |project_name| will need free space to operate.
|
that |project_name| will need free space to operate.
|
||||||
|
|
Loading…
Add table
Reference in a new issue