Commit graph

71 commits

Author SHA1 Message Date
Thomas Waldmann
cabcbc5887 fix determination of newest mtime, fixes #1860
bug:
if no files were added/modified, _newest_mtime stayed at its initial 0 value.
when saving the files cache, this killed all age 0 entries.

Now using None as initial value, so we can spot that circumstance.

The 2 ** 63 - 1 value is just so it is MAX_INT on a 64bit platform, for better performance.
It can be easily increased when y2262 is coming.
2016-11-20 00:08:33 +01:00
Thomas Waldmann
baa77c0e04 avoid previous_location mismatch, fixes #1741
due to the changed canonicalization for relative pathes in PR #1711 (implement /./ relpath hack),
there would be a changed repo location warning and the user would be asked if this is ok.
this would break automation and require manual intervention, which is unwanted.

thus, we automatically fix the previous_location config entry, if it only changed in the
expected way, but still means the same location.
2016-10-24 19:29:35 +02:00
enkore
2e5b2b150b Merge pull request #1709 from ThomasWaldmann/fix-1700
better messages for cache newer than repo, fixes #1700
2016-10-10 11:15:40 +02:00
Thomas Waldmann
4fc5a35572 better messages for cache newer than repo, fixes #1700 2016-10-10 06:10:39 +02:00
Thomas Waldmann
f50068944d update changed repo location immediately after acceptance
fixes #1524

before, if a longer backup got interrupted before commit(),
it asked same question again.
2016-10-10 05:18:43 +02: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
7b9d0c9739 yes(): abort on wrong answers, saying so
except for the passphrase display as we can only display it as long as we have it in memory,
here: retry, telling the user if he entered something invalid and needs to enter again.
2016-09-22 02:43:57 +02:00
Marian Beermann
ef13d392c7 Cache: release lock if cache is invalid 2016-08-18 12:26:14 +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
b96bc155ac fix unintended file cache eviction, fixes #1430
thanks much to e477 for diagnosing this and finding the right fix.
2016-08-05 13:59:21 +02:00
Thomas Waldmann
5f7b466969 implement BORG_FILES_CACHE_TTL, update FAQ
raise default ttl to 20 (previously: 10).
2016-07-31 01:33:46 +02:00
Marian Beermann
29ebdbadae
refcounting: use uint32_t, protect against overflows, fix merging for BE 2016-04-14 23:38:56 +02:00
Marian Beermann
d12c1deece
borg delete: fix --cache-only for broken caches
This also makes --cache-only idempotent: it won't fail if the cache
is already deleted.

Fixes #874
2016-04-11 12:50:42 +02:00
Marian Beermann
29bc396559
borg create: add --ignore-inode option
This is mainly meant for use with network file systems like sshfs and
possibly CIFS, which don't convey proper inode numbers.
2016-04-06 23:23:14 +02:00
Thomas Waldmann
3e120378e0 fix capitalization, add ellipses, change log level to debug for 2 messages, fixes #798 2016-03-26 14:31:54 +01:00
Thomas Waldmann
4843719f72 Cache: fix exception handling in __init__, release lock, fixes #610 2016-02-04 23:19:35 +01:00
Thomas Waldmann
4b339f5d69 cosmetic source cleanup (flake8) 2016-01-30 21:32:45 +01:00
Thomas Waldmann
b2dedee3c8 refactor yes(), cleanup env var semantics, fixes #355
refactorings:

- introduced concept of default answer:

if the answer string is in the defaultish sequence, the return value of yes() will be the default.
e.g. if just pressing <enter> when asked on the console or if an empty string or "default" is
in the environment variable for overriding.

if an environment var has an invalid value and no retries are enabled: return default
if retries are enabled, next retry won't use the env var again, but either ask via input().

- simplify:

only one default - this should be a SAFE default as it is used in some special conditions
like EOF or invalid input with retries disallowed.

no isatty() magic, the "yes" shell command exists, so we could receive input even if it is not from a tty.

- clean:

separate retry flag from retry_msg
2016-01-24 16:04:00 +01:00
Thomas Waldmann
fc52101d46 suppress unneeded exception context (PEP 409) 2016-01-24 15:36:04 +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
TW
1878e223d6 Merge pull request #566 from ThomasWaldmann/cache-ctxmgr
implement and use context manager for Cache, partial fix for #285
2016-01-18 01:00:17 +01:00
Thomas Waldmann
22f218baef implement and use context manager for Cache, partial fix for #285
also: make check in Lock.close more precise, check for "is not None".

note: a lot of blocks were just indented to be under the "with" statement,
in one case a block had to be moved into a function.
2016-01-17 01:15:42 +01:00
Thomas Waldmann
4d73f3cdb9 implement and use context manager for RepositoryCache, fixes #548 2016-01-17 00:30:00 +01:00
Thomas Waldmann
720fc49498 hashindex_add C implementation
this was also the loop contents of hashindex_merge, but we also need it callable from Cython/Python code.

this saves some cycles, esp. if the key is already present in the index.
2015-12-07 19:13:58 +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
4c6be00d65 remove some superfluous / duplicate log messages 2015-11-06 14:58:12 +01:00
Thomas Waldmann
6d5cc06cf6 remove unused imports, add missing imports 2015-11-02 20:36:13 +01:00
Thomas Waldmann
36cc377329 use default_notty=False for confirmations, fixes #345
this is so that e.g. cron jobs do not hang indefinitely if yes() is called,
but it will just default to "no" if not tty is connected.

if you need to enforce a "yes" answer (which is not recommended for
the security critical questions), you can use the environment:

BORG_CHECK_I_KNOW_WHAT_I_AM_DOING=Y
2015-11-02 01:59:22 +01:00
Thomas Waldmann
0a6e6cfe2e refactor confirmation code, reduce code duplication, add tests 2015-11-01 19:18:29 +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
Antoine Beaupré
d666c86bfc adjust display of --stats
it was broken by recent commits.

also remove the __format__() anti-pattern from cache as well.
2015-10-17 21:21:33 -04:00
Antoine Beaupré
b120e5f119 output more progress information
without this, there would be a solid 20 seconds here without any sort
of output on the console, regardless of the verbosity level. this
makes nice incremental messages telling the user that borg is not
stalled (or waiting for a lock, for that matter)

the "processing files" message is a little clunky, as we somewhat
abuse the cache to figure out if we are just starting... but it helps
if there are problems reading the actual files: it tells us the
initialization is basically complete and we're going ahead with the
reading of all the files.
2015-10-17 21:21:31 -04: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é
1c61f87da3 remove debugging code and fix all have_cython calls 2015-10-08 17:20:52 -04:00
Antoine Beaupré
a869ab0702 try to fix RTD build *again* *again* 2015-10-08 17:03:35 -04:00
Antoine Beaupré
3f68399463 style: wrap multiline strings elegantly 2015-10-08 16:52:49 -04:00
Antoine Beaupré
2d4b735fed remove unintended changes 2015-10-08 16:38:53 -04:00
Antoine Beaupré
42cc17caed use new logger object initialisation code 2015-10-06 12:57:27 -04:00
Antoine Beaupré
24413136ee Merge remote-tracking branch 'origin/master' into logging-refactor
Conflicts:
	borg/archiver.py
2015-10-03 14:23:53 -04:00
TW
adac324b6c Merge pull request #240 from ThomasWaldmann/cache-config-check
fix multiple issues with the cache config version check, fixes #234
2015-10-03 19:19:22 +02:00
Antoine Beaupré
e5a0936a05 add formatters for Cache and Statistics objects
this greatly simplifies the display of those objects, as the
__format__() parameter allows for arbitrary display of the internal
fields of both objects

this will allow us to display those summaries without having to pass a
label to the string representation. we can also print the objects
directly without formatting at all.
2015-10-02 15:55:14 -04:00
Thomas Waldmann
893242ead4 fix multiple issues with the cache config version check, fixes #234
- issue #234: handle exception when config file is empty is really not a borg cache config
- there was a unused %s in the Exception string
- error msg was wrong when version check failed - this IS a borg cache, but not of expected version
2015-10-02 18:11:10 +02:00
Antoine Beaupré
ca6c52610f restore some print statements
the heuristics i used are the following:

 1. if we are prompting the use, use print on stderr (input() may
    produce some stuff on stdout, but it's outside the scope of this
    patch). we do not want those prompts to end up on the standard
    output in case we are piping stuff around

 2. if the command is primarily producing output for the user on the
    console (`list`, `info`, `help`), we simply print on the default
    file descriptor.

 3. everywhere else, we use the logging module with varying levels of
    verbosity, as appropriate.
2015-10-02 11:13:01 -04:00
Antoine Beaupré
c9b11316ab use a module-specific logger instead of global one
that way we have one logger per module, and we can pick and choose
which module we want verbose, for example
2015-10-02 11:05:44 -04:00
Thomas Waldmann
8978515991 temporary hack to avoid using lots of disk space for chunks.archive.d 2015-10-02 16:56:31 +02:00
Antoine Beaupré
09ffbb1d9d convert most print() calls to logging
the logging level varies: most is logging.info(), in some place
logging.warning() or logging.error() are used when the condition is
clearly an error or warning. in other cases, we keep using print, but
force writing to sys.stderr, unless we interact with the user.

there were 77 calls to print before this commit, now there are 7, most
of which in the archiver module, which interacts directly with the
user. in one case there, we still use print() only because logging is
not setup properly yet during argument parsing.

it could be argued that commands like info or list should use print
directly, but we have converted them anyways, without ill effects on
the unit tests

unit tests still use print() in some places

this switches all informational output to stderr, which should help
with, if not fix jborg/attic#312 directly
2015-10-01 13:41:45 -04:00