Commit Graph

69 Commits

Author SHA1 Message Date
Marian Beermann 64a3fa8e73 check: bail out early if repository is *completely* empty 2016-11-13 11:40:19 +01:00
Thomas Waldmann 67aafec195 backport bin_to_hex and use it
simplifies code and also porting and merging between 1.0 and 1.1/master.
2016-10-06 05:15:01 +02:00
Thomas Waldmann 60c5482e6b fix closed FD issue, fixes #1551 2016-09-26 04:34:25 +02:00
Marian Beermann adaeb32cd4 Repository: fix repo not closed cleanly on InvalidRepository exception 2016-08-18 00:54:10 +02:00
Marian Beermann 95cf337fa5 Fix untracked segments made by moved DELETEs
Fixes #1442

(note that the segments _still_ get generated, see the comment, they
 should be collected now on the next compaction run)
2016-08-13 01:46:37 +02:00
Thomas Waldmann 7b5772df2d add transaction_id assertion
an acd_cli (amazon cloud drive fuse filesystem) user had "borg init" crash in the line below.

by adding the assertion we tell that we do not expect the transaction_id to be None there,
so it is easier to differentiate from a random coding error.
2016-08-10 13:56:06 +02:00
Thomas Waldmann 20392f8dd9 repo: split size check into too small and too big
also add a hint if somebody needs to restore an archive that has too big objects.
2016-08-09 18:05:22 +02:00
Thomas Waldmann a360307938 repo: do not put objects that we won't get, fixes #1451
we will not get() objects that have a segment entry larger than MAX_OBJECT_SIZE.
thus we should never produce such entries.

also: introduce repository.MAX_DATA_SIZE that gives the max payload size.
2016-08-09 18:05:22 +02:00
Thomas Waldmann 33e3348208 locking: better differentiate new vs. old clients, lock upgrade for replay
old clients use self.exclusive = None and do a read->write lock upgrade when needed.
new clients use self.exclusive = True/False and never upgrade.

replay fakes an old client by setting self.exclusive = None to get a lock upgrade if needed.
2016-08-05 19:11:16 +02:00
Thomas Waldmann d3d51e12ea rename UpgradableLock to Lock
lock upgrading is troublesome / may deadlock, do not advertise it.
2016-08-05 19:06:09 +02:00
Thomas Waldmann 2a355e547e make sure we have a excl. lock when starting a transaction
if we don't, we try to upgrade the lock.
this is to support old clients talking to a new server and also
to avoid bad consequences from coding mistakes for new clients.
2016-08-05 18:55:32 +02:00
Lee Bousfield 88a4989c57 Add --append-only to borg init 2016-07-27 08:52:42 -04:00
Marian Beermann 7ed425dae0
Repository: cleanup on ENOSPC 2016-07-05 20:33:07 +02:00
Marian Beermann f3aaffdb39 Repository: fix hints file unknown version error handling bug 2016-07-04 00:55:12 +02:00
Marian Beermann e7740458cd
Repository: Read v2 hints files
Fixes #1235
2016-07-04 00:44:29 +02:00
Thomas Waldmann 99566a31c0 sync the containing directory also 2016-07-01 02:11:49 +02:00
Thomas Waldmann fde5a60549 make sure data hits disk before commit tag, fixes #1236 2016-07-01 01:11:12 +02:00
Lee Bousfield c515d6018d
Add --append-only to borg serve
Fixes #1168
2016-06-30 17:58:36 -04:00
Oleg Drokin f99792d31d Ignore empty index file.
Empty index file is most likely a result from an unclean
shutdown in the middle of write, e.g. on ext4 with delayed
allocation enabled (default).
Ignoring such a file would get it recreated by other parts of code,
where as not ignoring it leads to an exception about
not being able to read enough bytes from the index.

this commit fixes #1195

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
2016-06-24 11:18:54 -04:00
Marian Beermann 714e93bf64
Repository: fix commit tags being seen in data 2016-05-19 01:12:06 +02:00
TW fc10ac0ef9 Merge pull request #830 from enkore/feature/1.0ctxmng
Make Repository a context manager, use decorators for wrapping withs
2016-04-03 17:36:38 +02:00
Marian Beermann 83586ae09c Make Repository a context manager, use decorators for wrapping withs
(Remote)Repository.close() is not a public API anymore, but a private
API. It shall not be used from within other classes than Repository
or it's tests. The proper way is to use a context manager now. However,
for RPC/Remote compatibility with Borg 1.0 it is kept and unchanged.

Repositories are not opened by __init__ now anymore, it is done
by binding it to a context manager. (This SHOULD be compatible both ways
with remote, since opening the repo is handled by a RepositoryServer method)

Decorators @with_repository() and @with_archive simplify
context manager handling and remove unnecessary indentation.

Backported to 1.0-maint
2016-04-03 17:14:43 +02:00
Marian Beermann effa992d22 append-only mode: use single file for log, disallow check --repair, docs 2016-03-31 18:23:08 +02:00
Marian Beermann ffc8cf6c97 Append-only mode for repositories
New repository config item, repository.append_only, causes Borg to never
delete or append to existing data files. Hints and indices are handled
as before, old ones are deleted, because they can get quite large, but
are automatically reconstructed: no need to keep them.

When append_only is activated a file /path/to/repo/transactions/<NUMBER>
will be created for every commit.
Deleting all segments <NUMBER+1> and higher will rollback to that commit.

Note that this only influences Borg behaviour. Since repository config
can't be altered remotely (except for repository.key) this can't be
disabled when accessed remotely over SSH with "borg serve" as the
forced command.

This is only a feature to support the use case, and does not replace
appropriate file system permissions or monitoring.

Resolves #809
2016-03-31 17:29:17 +02:00
Thomas Waldmann 6d615ec30a change encryption to be on by default (repokey mode)
it's 2015, let's be safe-by-default and unsafe-as-option.

also: show default mode in builtin help
2016-01-24 15:44:09 +01:00
Thomas Waldmann fc52101d46 suppress unneeded exception context (PEP 409) 2016-01-24 15:36:04 +01:00
Thomas Waldmann a6f9c29dfe use new OS and IO exception hierarchy of py 3.3 2016-01-24 15:36:04 +01:00
Thomas Waldmann 4444113414 remove misc. compat code not needed for py 3.4+ 2016-01-24 15:16:05 +01:00
Thomas Waldmann 265da6286f remove conditionals/wrappers, we always have stat nanosecond support on 3.4+
also: no wrapper needed for binascii.unhexlify any more
2016-01-24 15:16:05 +01:00
Thomas Waldmann e2f5983eef finer repo check progress indicator
a step size of 5% was way too much, now doing 0.1%
2016-01-23 20:00:03 +01:00
Thomas Waldmann 0c076ad114 compact_segments: save_space -> free unused segments quickly
as soon as one target segment is full, it is a good time to commit it and remove the source segments
that are already completely unused (because they were transferred int the target segment).

so, for compact_segments(save_space=True), the additional space needed should be about 1 segment size.

note: we can't just do that at the end of one source segment as this might create very small
target segments, which is not wanted.
2015-12-08 18:36:41 +01:00
Thomas Waldmann b41f6dfbbf Merge branch 'silent' of https://github.com/ThomasWaldmann/borg into ThomasWaldmann-silent 2015-12-08 01:56:44 +01:00
Jakob Schnitzer 17952dff48 helpers: remove functions that are only used once
The read_msgpack and write_msgpack functions were only used in one place
each.  Since msgpack is read and written in lots of places, having
functions with these generic names is confusing. Also, the helpers
module is quite a mess, so reducing its size seems to be a good idea.
2015-12-07 14:29:01 +01:00
Thomas Waldmann 7a1316cb79 implement ProgressIndicators, use it for repo check and segment replay, fixes #195, fixes #188 2015-12-02 01:06:07 +01:00
Thomas Waldmann 38994c78fc implement borg break-lock REPO command, fixes #157
due to borg's architecture, breaking the repo lock needs first creating a repository object.
this would usually try to get a lock and then block if there already is one.
thus I added a flag to open without trying to create a lock.
2015-11-21 20:50:53 +01:00
Thomas Waldmann f19e95fcf7 implement --lock-wait, support timeout for UpgradableLock, fixes #210
also: simplify exceptions / exception handling
2015-11-21 15:34:51 +01:00
Antoine Beaupré f13dd6e579 completely remove have_cython() hack
this was making us require mock, which is really a test component and
shouldn't be part of the runtime dependencies. furthermore, it was
making the imports and the code more brittle: it may have been
possible that, through an environment variable, backups could be
corrupted because mock libraries would be configured instead of real
once, which is a risk we shouldn't be taking.

finally, this was used only to build docs, which we will build and
commit to git by hand with a fully working borg when relevant.

see #384.
2015-11-13 10:40:53 -05:00
Thomas Waldmann c01efa4666 repository: refactor some duplicate code 2015-11-06 19:37:39 +01:00
Thomas Waldmann f804c6fb1c repository check code: added some comments 2015-11-03 15:41:02 +01:00
Thomas Waldmann 98f3b8d937 fix "check" for repos that have incomplete chunks, fixes #364
added try/finally (the code in between was just indented, no
other code changes) to make sure it sets self.index back to None,
even if the code crashes e.g. due to an IntegrityError caused
by an incomplete segment caused by a disk full condition.

also, in prepare_txn, create an empty in-memory index if transaction_id
is None, which is required by the Repository.check code to work correctly.
If the index is not empty there, it will miscalculate segment usage
(self.segments).
2015-11-03 15:30:33 +01:00
Thomas Waldmann 6d5cc06cf6 remove unused imports, add missing imports 2015-11-02 20:36:13 +01:00
TW 5f86959762 Merge pull request #349 from ThomasWaldmann/pretty-errors
prettier error messages, fixes #57
2015-10-31 22:44:04 +01:00
Thomas Waldmann 762fdaadd8 prettier error messages, fixes #57
subclasses of "Error": do not show traceback
(this is used when a failure is expected and has rather trivial reasons and usually
does not need debugging)

subclasses of "ErrorWithTraceback": show a traceback
(this is for severe and rather unexpected stuff, like consistency / corruption issues
or stuff that might need debugging)

I reviewed all the Error subclasses whether they fit into the one or other class.

Also: fixed docstring typo, docstring formatting
2015-10-31 22:23:32 +01:00
Radek Podgorny 5cc25d986a move away from RawConfigParser to ConfigParser
this is a recommended thing since direct use of RawConfigParser
is not deprecated according to python docs.
2015-10-29 02:37:43 +01:00
Thomas Waldmann af2f1f7861 remove a fixed FIXME
see a few lines below, where it renames the original file to *.beforerecover before creating the repaired copy using the old name.
2015-10-19 11:57:12 +02:00
Antoine Beaupré bdbdbdde90 Merge remote-tracking branch 'origin/master' into logging-refactor
Conflicts:
	borg/archive.py
	borg/archiver.py
	borg/cache.py
	borg/key.py
2015-10-09 12:58:27 -04:00
Antoine Beaupré 423ff45d81 rename cython detection function
"have" has clearer semantics than "detect"
2015-10-08 15:34:44 -04:00
Antoine Beaupré f98998f042 fix logical inversion in the semantics of detect_cython() 2015-10-08 15:26:40 -04:00
Antoine Beaupré 6f9e04bc21 generalise the cython check hack
instead of applying this only to usage generation, use it as a generic
mechanism to disable loading of Cython code.

it may be incomplete: there may be other places where Cython code is
loaded that is not checked, but that is sufficient to build the usage
docs. the environment variable used is documented as such in the
docs/usage.rst.

we also move the check to a helper function and document it
better. this has the unfortunate side effect of moving includes
around, but I can't think of a better way.
2015-10-08 08:56:02 -04:00
Antoine Beaupré 9cbc868764 make tests and build work again in usage using environment
this is such a crude hack it is totally embarrassing....

the proper solution would probably be to move the `build_parser()`
function out of `Archiver` completely, but this is such an undertaking
that i doubt it is worth doing since we're looking at switching to
click anyways.

the main problem in moving build_parser() out is that it references
`self` all the time, so it *needs* an archiver context that it can
reuse. we could make the function static and pass self in there by
hand, but it seems like almost a worse hack... and besides, we would
need to load the archiver in order to do that, which would break usage
all over again...
2015-10-07 22:26:59 -04:00