Commit graph

572 commits

Author SHA1 Message Date
TW
f834e335f9 Merge pull request #437 from anarcat/no-progress
fix --no-progress
2015-11-23 18:48:45 +01:00
anarcat
2ac515a5f7 fix typos 2015-11-23 12:41:20 -05:00
Antoine Beaupré
0196d80b28 fix progress tests on travis
we now check if we really have a terminal before doing the fancy auto-detection testing
2015-11-22 21:24:37 -05:00
TW
04f081fea7 Merge pull request #442 from ThomasWaldmann/fix-compiler-warnings
get rid of C compiler warnings, fixes #391
2015-11-22 14:15:24 +01:00
TW
faacd18244 Merge pull request #443 from ThomasWaldmann/tb-add-sysinfo
include system info below traceback, fixes #324
2015-11-22 14:09:07 +01:00
Thomas Waldmann
adb35ab07f include system info below traceback, fixes #324 2015-11-21 22:51:59 +01:00
Thomas Waldmann
7247043db0 get rid of C compiler warnings, fixes #391 2015-11-21 22:08:30 +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
1093894be8 UpgradableLock: release exclusive lock in case of exceptions
also: add some comments about how to use the locks in the safest way
2015-11-21 16:53:33 +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
Thomas Waldmann
b3b4db427c rename print_info to print_verbose
better name as it is only outputting if verbose flag is set.
2015-11-21 02:26:50 +01:00
Thomas Waldmann
6abf7621c1 remove rarely used print_status method 2015-11-21 02:22:26 +01:00
Thomas Waldmann
25140e8c82 add --log-level to set the level of the builtin logging configuration, fixes #426 2015-11-21 02:09:16 +01:00
Thomas Waldmann
c4dae52ca4 configure logging via env var, use LazyLogger
logging.raiseExceptions not needed any more for py >= 3.2
2015-11-21 01:14:07 +01:00
Antoine Beaupré
a6f8436ceb move toggle action to beginning of class so it can be reused 2015-11-20 15:03:46 -05:00
Antoine Beaupré
a40729f4f3 --progress option was backwards
adds unit tests and ensures we detect --progress correctly in all cases
2015-11-20 15:03:39 -05:00
TW
a7eb83efa5 Merge pull request #419 from anarcat/no-progress
add a --no-progress flag to forcibly disable progress info
2015-11-20 20:08:39 +01:00
Thomas Waldmann
b1ba7a84f0 --keep-tag-files: fix file status, fix multiple tag files in one directory, fixes #432 2015-11-19 20:03:50 +01:00
Thomas Waldmann
2e64c29e01 use ISO-8601 date and time format, fixes #375 2015-11-16 23:51:21 +01:00
Antoine Beaupré
9b1ca5c1eb force --no to be at the start of option 2015-11-16 15:26:50 -05:00
Antoine Beaupré
5be060d1f1 add a --no-progress flag to forcibly disable progress info
--progress isn't a "toggle" anymore, in that it will never disable progress information: always enable it.

example:

$ borg create ~/test/borg2::test$(date +%s) . ; echo ^shows progress
reading files cache
processing files
^shows progress
$ borg create ~/test/borg2::test$(date +%s) . < /dev/null; echo ^no progress
reading files cache
processing files
^no progress
$ borg create --progress ~/test/borg2::test$(date +%s) . < /dev/null; echo ^progress forced
reading files cache
processing files
^progress forced
$ borg create --no-progress ~/test/borg2::test$(date +%s) . ; echo ^no progress
reading files cache
processing files
^no progress

we introduce a ToggleAction that can be used for other options, but
right now is just slapped in there near the code, which isn't that
elegant. inspired by:

http://stackoverflow.com/questions/11507756/python-argparse-toggle-flags

note that this is supported out of the box by click:
http://click.pocoo.org/5/options/#boolean-flags

fixes #398
2015-11-16 11:27:27 -05:00
Thomas Waldmann
234a88bec6 avoid hidden import, make it easy for pyinstaller
this fixes #218 in an easier way so one doesn't have to type
--hidden-import=logging.config all the time when using pyinstaller.
2015-11-15 15:52:02 +01:00
Thomas Waldmann
d6b8de943b add docs for item flags / status output, fixes #402 2015-11-15 14:32:19 +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
7d178e09b0 Implement --keep-tag-files to preserve directory roots/tag-files
We also add --keep-tag-files to keep in the archive the root directory and the
tag/exclusion file in the archive.

This is taken from a attic PR (and adapted for borg):
    commit f61e22cacc90e76e6c8f4b23677eee62c09e97ac
    Author: Yuri D'Elia <yuri.delia@eurac.edu>
    Date:   Mon Dec 15 12:27:43 2014 +0100
2015-11-09 04:08:49 +01:00
Thomas Waldmann
a6a8a4ebd9 Implement --exclude-if-present
Add a new --exclude-if-present command-line flag to ``borg create``.  If
specified, directories containing the specified tag file will be excluded from
the backup. The flag can be repeated to ignore more than a single tag file,
irregardless of the contents.

This is taken from a attic PR (and adapted for borg):
    commit 3462a9ca90388dc5d8b4fa4218a32769676b3623
    Author: Yuri D'Elia <yuri.delia@eurac.edu>
    Date:   Sun Dec 7 19:15:17 2014 +0100
2015-11-09 03:41:06 +01:00
Björn Ketelaars
e6911b2f25 Avoid using msgpack.packb at import time.
move item_keys = ... to __init__ (self.item_keys = ...)

Solution from/discussed with TW.
2015-11-08 15:23:09 +01:00
Thomas Waldmann
007572594f try to fix build on readthedocs 2015-11-08 02:00:51 +01:00
Thomas Waldmann
5595d56ecf deal with unicode errors for symlinks in same way as for regular files, fixes #382 2015-11-08 01:05:55 +01:00
Thomas Waldmann
ba67b96434 have a helpful warning message about how to fix wrong locale setup, fixes #382 2015-11-08 00:57:02 +01:00
Thomas Waldmann
244303ac66 add ACL keys the RobustUnpacker must know about 2015-11-07 19:55:17 +01:00
Thomas Waldmann
c9090fc3c2 helper: minor style fix 2015-11-07 15:37:05 +01:00
Thomas Waldmann
8cc726a107 make basic test more robust, try 2
check if we have all expected files in list output (but ignore extra lines,
like "can't load libfakeroot" or so).
2015-11-07 00:30:02 +01:00
Thomas Waldmann
eb3bc1023b make basic test more robust
counting lines is a bad idea. just one unrelated output line and the test fails.
thus we rather check if what we expect is in the output.
2015-11-07 00:11:36 +01:00
TW
1a20d3d5ae Merge pull request #366 from ThomasWaldmann/fix-364
Fix borg check crashing on some repos, issue #364
2015-11-06 21:05:30 +01:00
Thomas Waldmann
c01efa4666 repository: refactor some duplicate code 2015-11-06 19:37:39 +01:00
TW
864fa9ae2d Merge pull request #370 from ThomasWaldmann/debug-helpers
Debug helpers
2015-11-06 18:08:05 +01:00
Thomas Waldmann
37c8aa2d42 debug-get-obj command 2015-11-06 17:45:30 +01:00
Thomas Waldmann
a2fc479da3 debug-put-obj command 2015-11-06 17:31:05 +01:00
Thomas Waldmann
9986705760 add some tests for the debug commands 2015-11-06 16:51:39 +01:00
Thomas Waldmann
7da730a8d7 borg list --prefix=thishostname- REPO, fixes #205
lists only archives with names starting with the given prefix.
2015-11-06 15:45:49 +01:00
Thomas Waldmann
a4bb85970d do not mention the deprecated passphrase mode 2015-11-06 15:01:37 +01:00
Thomas Waldmann
4c6be00d65 remove some superfluous / duplicate log messages 2015-11-06 14:58:12 +01:00
Thomas Waldmann
39b5734b31 debugging helper: borg debug-delete-obj 2015-11-04 01:05:21 +01:00
Thomas Waldmann
47813f6f6a archiver checker: better error logging, give chunk_id and sequence numbers
can be used together with borg debug-dump-archive-items.
2015-11-04 00:20:12 +01:00
Thomas Waldmann
d2b7dbc0a8 debugging helper: borg debug-dump-archive-items 2015-11-03 23:42:58 +01:00
Thomas Waldmann
12b5d07e55 fix RobustUnpacker, it missed some metadata keys. add check for unknown metadata keys.
not just the new atime and ctime keys were missing, but also bsdflags.
2015-11-03 20:21:52 +01:00
Thomas Waldmann
fa35525b58 create from stdin: also save atime, ctime
cosmetic, just for completeness.
2015-11-03 19:52:49 +01:00
Thomas Waldmann
f28d5d1f96 disk full test: some improvements
- can create 0-byte files now
- frees space early (avoids running out of disk space at repo init time)
- creates multiple reserve files, so we do not only reserve some space,
  but also some inodes
 - only print output if there is an error RC
 - if make_files makes us run out of space, that is not interesting, just start
   a new iteration from scratch
2015-11-03 19:39:05 +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
22262e3fb7 add a test to find disk-full issues, #327 2015-11-03 00:41:20 +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
e6231896cd emit a deprecation warning for --compression N
deprecating it in the source is not enough, we also need to tell the users to fix their scripts.
2015-11-02 00:14:01 +01:00
Thomas Waldmann
35280e9a65 label platform code, exclude freebsd and unknown platform from coverage measurement
this coverage configuration is mostly for travis and there we only can test linux and darwin.
2015-11-01 23:06:52 +01:00
Thomas Waldmann
0a6e6cfe2e refactor confirmation code, reduce code duplication, add tests 2015-11-01 19:18:29 +01:00
Thomas Waldmann
36900051c5 move test utilities to testsuite package, add FakeInputs utility 2015-11-01 19:13:45 +01:00
Thomas Waldmann
4a1c995244 add --show-rc option enable "terminating with X status, rc N" output, fixes #351
this is needed for tools like borgweb (or in general: when the rc value / exit status should
be logged for later review or directly seen on screen).

this is off by default, so the output is less verbose (and also does not fail tests which
counts lines).
2015-11-01 00:53:55 +01:00
Thomas Waldmann
4bf8c8a6f8 separate parse_args() from run()
parse_args concentrates on only processing arguments, including pre and post processing.
this needs to be called before run(), which is now receiving the return value of parse_args.

this was done so we can have the parsed args outside of the run function, e.g. in main().
2015-11-01 00:40:32 +01:00
Thomas Waldmann
7ea701f6f7 fix test failure for borg.exe
fatal error is rc 2 now (EXIT_ERROR)
2015-11-01 00:01:23 +01:00
TW
f651b014e6 Merge pull request #350 from ThomasWaldmann/fix-307
prettier connection closed message, fixes #307
2015-10-31 23:19:26 +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
TW
39e4f344bd Merge pull request #348 from ThomasWaldmann/warn-slow-msgpack
emit a warning if we have a slow msgpack installed
2015-10-31 22:43:36 +01:00
Thomas Waldmann
1740384763 prettier connection closed message, fixes #307 2015-10-31 22:41:08 +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
Thomas Waldmann
3490469734 emit a warning if we have a slow msgpack installed
the reason for a slow msgpack can be:
- pip install: missing compiler (gcc)
- pip install: missing compiler parts (e.g. gcc-c++)
- pip install: cached wheel package that was built while the compiler wasn't present
- distribution package: badly built msgpack package
2015-10-31 20:37:21 +01:00
Thomas Waldmann
ad4594a39c Fix some breakage from the merge 2015-10-31 19:39:20 +01:00
Thomas Waldmann
f4b0f57618 Merge branch 'master' into multithreading
Some tests are failing, some block, one new test needed skipping.
2015-10-31 19:36:33 +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
5992d4be58 Merge branch 'review-logging-levels' 2015-10-28 02:02:33 +01:00
Thomas Waldmann
dd577bf4ac fuse mount: fix unlocking of repository at umount time, fixes #331
there were 2 issues:
lock used another pid and tid than release because daemonize() made it different processes/threads.
solved by just determining PID only once and not using TID any more.

the other issue was that the repo needed and explicit closing.
2015-10-27 22:37:36 +01:00
Thomas Waldmann
92d31be087 atime unit test: test adapts to O_NOATIME support on platform 2015-10-26 23:16:41 +01:00
Thomas Waldmann
3e73998710 atime unit test: do not compare input file's current atime
and explain why (missing O_NOATIME open mode modified the atime at backup time).
2015-10-26 23:08:37 +01:00
Thomas Waldmann
765999195d atime unit test: hardcode "round" timestamps
just to avoid rounding / precision issues with floating point computations on py < 3.3
I used 2 hardcoded "full second" values on the input file and check if they get restored
correctly.
2015-10-26 22:34:08 +01:00
Thomas Waldmann
c492011a92 backup atime and ctime additionally to mtime, fixes #317
restore: mtime and atime
FUSE: support ctime and atime additionally to mtime
2015-10-26 02:07:55 +01:00
Thomas Waldmann
0942bc010e fix reading files without touching their atime 2015-10-26 01:43:58 +01:00
Thomas Waldmann
f7d724ce33 tests: only use mtime once in directory comparison tuples 2015-10-26 01:37:28 +01:00
Thomas Waldmann
f285e90912 archiver: add E status as error indication
E means that an error occured when processing this (single) item
2015-10-25 02:53:36 +02:00
Thomas Waldmann
7b73abdcda archiver: rename print_x methods so they correspond to log levels
also:

remove some "Warning: " msg prefixes - if we emit at WARNING level,
it is obviously a warning.

remove some "borg: " msg prefixes.
2015-10-25 02:35:42 +02:00
Thomas Waldmann
d8d3c8521b fix logging levels
All normal informational output is now logged at INFO level.
To actually see normal output, the logger is configured to level INFO also.

Log levels:
WARNING is for warnings, ERROR is for (fatal) errors, DEBUG is for debugging.

logging levels must only be used according to this semantics and must not be
(ab)used to let something show up (although the logger would usually hide it)
or hide something (although the logger would usually show it).

Controlling the amount of output shown on INFO level:
--verbose, --progress, --stats are currently used for this.
more such flags might be added later as needed.

if they are set, more output is logged (at INFO level).

also: change strange setup_logging return value
2015-10-23 02:29:41 +02:00
TW
52fd2ad3da Merge pull request #320 from ThomasWaldmann/final-status
Final status
2015-10-22 01:04:36 +02:00
Thomas Waldmann
5bcd4835e6 add tests for return codes 2015-10-22 00:45:29 +02:00
Antoine Beaupré
bfaa046a31 add standard --version argument
this way the version can be discovered by scripts without having to
part the output of 'help'.

it is removed from the 'help' output itself because it is prettier
without the complete version number, and then the description can be
reused elsewhere as well without needing the version number
2015-10-21 09:58:28 -04:00
TW
557d8c7e03 Merge pull request #318 from anarcat/flake8
small flake8 changes
2015-10-21 02:15:22 +02:00
Antoine Beaupré
05c4255620 flake8 cleanup broke the upgrader, re-import Repository 2015-10-20 19:54:57 -04:00
Thomas Waldmann
72c984891c refactor return codes, fixes #61
0 = success (logged as INFO)
1 = warning (logged as WARNING)
2 = (fatal and abrupt) error (logged as ERROR)

please use the EXIT_(SUCCESS,WARNING,ERROR) constants from helpers module.
2015-10-21 01:11:51 +02:00
Thomas Waldmann
1439f3be60 give a final status into the log output, including exit code, fixes #58 2015-10-20 23:57:56 +02:00
Thomas Waldmann
af2366693a tests: catch stderr also, some tests expect stderr contents in "output"
weird: the remote archive fuse tests deadlock, that's why I replaced them by dummies
2015-10-20 22:46:47 +02:00
Antoine Beaupré
8651f87fa1 fix flake8 warnings in my recent PRs 2015-10-20 14:43:49 -04:00
Antoine Beaupré
aad6afb3e0 pep8 the whole darn helpers module 2015-10-20 13:39:21 -04:00
Antoine Beaupré
21fdc91995 clarify size tests 2015-10-20 13:04:01 -04:00
Antoine Beaupré
416e42335c introduce variable precision 2015-10-20 13:01:39 -04:00
Antoine Beaupré
c7c1b9222b convert to more flexible size formatters
those can now support both file sizes (in SI/decimal format, powers of 10) and memory sizes (in binary format, powers of 2)

tests still fail because the result is always displayed as floats
2015-10-20 13:01:14 -04:00
Antoine Beaupré
de390b1ca6 add file size tests, failing
the tests are failing because 1KB gets displayed as 1000 bytes, but also because higher prefixes are missing
2015-10-20 13:01:14 -04:00
TW
21f26988cc Merge pull request #303 from anarcat/verbosity
Verbosity
2015-10-19 22:25:46 +02:00
Antoine Beaupré
38bde26673 remove needless double type conversion
i got confused and thought i was setting the environment (in which case you need to cast to str anyways, so this was wrong even then)
2015-10-19 15:47:05 -04:00
Antoine Beaupré
a3084b7174 try to fix build on py32 again 2015-10-19 14:41:02 -04:00
Antoine Beaupré
12d22d5940 try to fix build on py32 2015-10-19 09:10:45 -04:00
Antoine Beaupré
f9bccd1987 revert policy decision of showing all files listing only on debug 2015-10-19 09:10:19 -04:00
Antoine Beaupré
49d7c240a0 cosmetic: don't word-wrap needlessly 2015-10-19 09:10:04 -04:00
Thomas Waldmann
7d31da7914 implement cmdline metadata value decoding
code copied & adapted from Archive.load()
2015-10-19 12:16:28 +02: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
TW
79482a1c46 Merge pull request #310 from ThomasWaldmann/non-ascii-acls
Non ascii acls
2015-10-19 11:39:15 +02:00
TW
a7db210ee9 Merge pull request #308 from ThomasWaldmann/test-binary
Test binary, fixes #215
2015-10-19 10:14:20 +02:00
Antoine Beaupré
98512736e5 stats tests: vary values to possible catch errors 2015-10-18 21:13:01 -04:00
Antoine Beaupré
f48bbc3725 move defaults up in alternate implementation, use nameduple 2015-10-18 21:07:28 -04:00
Antoine Beaupré
158e6b529a cosmetic: pep8 and io is actually just out 2015-10-18 21:06:56 -04:00
Antoine Beaupré
4c6915cce5 fix typos and remove debug code 2015-10-18 21:06:37 -04:00
Antoine Beaupré
1c0fb82b59 check for the stream --progress uses, not stdin 2015-10-18 20:54:39 -04:00
Thomas Waldmann
d602558f9d acls (darwin): use helper functions safe_encode/safe_decode
also: rewrite one bytes-based function to work more similar than all other acl-processing functions.
2015-10-19 02:32:29 +02:00
Thomas Waldmann
213075e5c1 acls (freebsd): use helper functions safe_encode/safe_decode 2015-10-19 01:43:46 +02:00
Thomas Waldmann
259f8678d6 acls (linux): helper functions safe_encode/safe_decode 2015-10-19 01:40:15 +02:00
Thomas Waldmann
5a2aa7b02b acls (linux): make tests as they should be
TODO: can this be done without creating a user/group "übel" with uid 666 gid 666?
2015-10-19 01:09:58 +02:00
Thomas Waldmann
e818026440 acls (linux): remove int() cast
it seems like the (non-numerical) name or group might get into fields[3] if the name -> uid or group -> gid mapping is unknown.
2015-10-19 00:28:53 +02:00
Thomas Waldmann
1f14d1de19 acls (linux): use surrogatescape error handling for acl_append_numeric_ids and acl_numeric_ids
surrogatescape will decode/encode invalid utf-8 sequences (if we do not get utf-8) in a round-tripping way.
2015-10-19 00:01:19 +02:00
Thomas Waldmann
63ed5d9949 acls (posix platforms): use surrogatescape error handling for posix_acl_use_stored_uid_gid
surrogatescape will decode/encode invalid utf-8 sequences (if we do not get utf-8) in a round-tripping way.
2015-10-18 23:43:24 +02:00
Thomas Waldmann
b2cffe00fe acls (linux): use surrogatescape error handling, fix test
surrogatescape will decode/encode invalid utf-8 sequences (if we do not get utf-8) in a round-tripping way.
2015-10-18 23:33:29 +02:00
Thomas Waldmann
55179fe64d acls (linux): add a test for acl_use_local_uid_gid and fix this function
this has never worked as intended as the function was not using the computed "fields[1]" value at all.
plus there were type issues after that was fixed.
2015-10-18 23:20:01 +02:00
Thomas Waldmann
45b04cd3c1 add non-ascii ACL test (linux)
still failing as the tested code does not yet work with non-ascii ACLs
2015-10-18 20:54:46 +02:00
Thomas Waldmann
723590df3d fix borg.exe presence detection for python3.2 2015-10-18 19:18:24 +02:00
Thomas Waldmann
60cdb5f716 make archiver tests run for the python source as well as for the pyinstaller binary, fixes #215
if the borg.exe binary is not available in PATH, binary tests are skipped.

source tests are run without forking (for better speed, esp. on travis).
binary tests need forking the binary, of course.

for source tests, some tests check for an exception to happen.
for a forked binary, we of course can only check the exit code, which is non-zero in that case.
2015-10-18 18:48:36 +02:00
Thomas Waldmann
03975016c5 upgrader: fix / reformat comments 2015-10-18 16:43:59 +02:00
TW
3c52f41132 Merge pull request #299 from anarcat/no-inplace
do not upgrade repositories in place by default
2015-10-18 16:36:07 +02:00
TW
10567fb327 Merge pull request #306 from anarcat/upgrader-index-fixes
fix cascading failure with the index conversion code
2015-10-18 14:54:49 +02:00
Antoine Beaupré
319fcbacc5 fix phrasings in "in place" refactoring 2015-10-17 22:04:00 -04:00
Antoine Beaupré
8c48015e70 try to work around Windows idiocy of open files
apparently, we may be able to rewrite an open file if we rename it first.

i have no way to test this, unfortunately
2015-10-17 21:59:51 -04:00
Antoine Beaupré
e59f1d50d9 fix tests: umask is not defined in the repo yet 2015-10-17 21:56:25 -04:00
Antoine Beaupré
ce72051284 rename cache variable to index for clarity 2015-10-17 21:50:16 -04:00
Antoine Beaupré
07e7f2dcad fixup warning message 2015-10-17 21:50:14 -04:00
Antoine Beaupré
fb68c6ff70 always convert the chunks cache we find
it seems it is possible that the chunks files are copied but *not*
converted. this may have happened here because the conversion was
interrupted, although the specific scenario is still unclear (but it
did happen during manual tests here). therefore reproducing this
problem seems to be difficult, hence the lack of tests for this
specific issue.

since we consider the header replacement code to be safe, that we
always convert shouldn't pose any additional threat to the existing
borg chunk cache.
2015-10-17 21:44:50 -04:00
Antoine Beaupré
c4599d8ea4 fix cascading failure with the index conversion code
this resolves bug #something where the index file could not be
converted, completely breaking conversion.

it seems that, during some refactoring, the index conversion code was
completely dropped. this was missed by the unit tests because the repo
can still be opened by the constructor even though the index is
invalid, so tests need improvements there.
2015-10-17 21:44:50 -04:00
Antoine Beaupré
92ac120fb0 default progress display to true if on a tty
this makes --progress a toggle: if there's a terminal, it turns it
off, if there isn't, it forces it on.
2015-10-17 21:21:33 -04:00
Antoine Beaupré
e4f325182e Revert "no need to flush stderr in my tests"
It is actually necessary, for now.

This reverts commit 8fdd1eddf9.

Conflicts:
	borg/helpers.py
2015-10-17 21:21:33 -04:00
Antoine Beaupré
ce1aaa9dfa Revert "fix conflict between --stats and --progress"
the columns handling fixed that isssue more elegantly

This reverts commit 7f77778419.

Conflicts:
	borg/helpers.py
2015-10-17 21:21:33 -04:00
Antoine Beaupré
0d8525ad8f add missing lines 2015-10-17 21:21:33 -04: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é
28d0a9ce84 human-readable representation of stats 2015-10-17 21:21:32 -04:00
Antoine Beaupré
66bfc6fce8 get rid of print_() function
this function was over-coupling the cache system and the statistics
module. they are now almost decoupled insofar as the cache system has
its own rendering system now that is called separately.

furthermore, we have a much more flexible formatting system that is
used coherently between --progress and --stats

the degenerate case here is if we want to change the label in the
statistics summary: in this case we need to override the default
__str__() representation to insert our own label.
2015-10-17 21:21:32 -04:00
Antoine Beaupré
118ee8679f remove custom microformat from stats
i saw the errors in my ways: __format__ is only to customize the
"format mini-language", what comes after ":" in a new string
format. unfortunately, we cannot easily refer to individual fields in
there, short of re-implementing a new formatting language, which seems
silly.

instead, we use properties to extract human-readable versions of the
statistics. more intuitive and certainly a more common pattern than
the exotic __format__().

also add unit tests to prove this all works
2015-10-17 21:21:32 -04:00
Antoine Beaupré
6b547e6554 no need to flush stderr in my tests 2015-10-17 21:21:32 -04:00
Antoine Beaupré
75c993b875 simplify progress display
we stop enforcing a minimum width for fields, it changes only on
logarithmic boundaries, so not a big problem. string conversion is
implicit

this gives us a little more width for the path
2015-10-17 21:21:32 -04:00
Antoine Beaupré
ecae163072 use all available columns for path in progress
we use the new get_terminal_size() function, with a fallback for
Python 3.2. we default to 80 columns.

then we generate the stats bit and fill the rest with the path, as
previously, but with a possibly larger field.

note that this works with resizes in my test (uxterm)
2015-10-17 21:21:32 -04:00
Antoine Beaupré
7f28244cfe fix conflict between --stats and --progress
the --stats output would be slightly garbled by --progress, because of
the \r that is output at the last line...

example:

    initializing cache
    reading files cache
    processing files
    ------------------------------------------------------------------------------ s/twotone
    Archive name: 2015-10-15-test
2015-10-17 21:21:32 -04:00
Antoine Beaupré
e8cf28f9a0 only show all files found in debug
a single -v flag shouldn't flood the console with all the files in the
path specified, it makes -v basically useless

this way, -v can also be used with --progress to have nicer output:

initializing cache
reading files cache
processing files
  5.20 GB O   2.66 GB C  25.13 MB D 27576 N baz/...
2015-10-17 21:21:31 -04:00
Antoine Beaupré
d8f8076984 factor out status output so it is consistent
as it was, surrogates were not always removed, for example

we may also want to output at different levels or control if we want
to print unchanged files and so on
2015-10-17 21:21:31 -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é
3827c2b107 also show the number of files processed in --progress 2015-10-17 21:21:31 -04:00
Antoine Beaupré
3eebea8745 explain what the --progress flag does exactly
an alternative to this would be to use more than a letter in the
output, for example:

 orig: 16.82 GB comp: 9.44 GB dedup: 25.86 MB home/
2015-10-17 21:21:31 -04:00
Thomas Waldmann
fc78b44923 use --one-file-system (as "du" tool does) instead of --do-not-cross-mountpoints
the old name still works, but emits a deprecation warning suggesting the new name.

this is a followup to 4fd06e2634, which added "-x" (as seen in "du").
2015-10-17 20:55:07 +02:00
TW
2dda41dc2a Merge pull request #294 from anarcat/x-option
add -x flag, common to GNU utilities
2015-10-17 20:06:02 +02:00
Antoine Beaupré
eacb0b9e83 Merge branch 'logging-refactor' into upstream 2015-10-17 12:29:52 -04:00
Antoine Beaupré
4fd06e2634 add -x flag, common to GNU utilities
it should also probably be --one-file-system for coherence with du(1)
2015-10-17 12:23:45 -04:00
Antoine Beaupré
34d0e0641c make sure hardlink copy doesn't break perms 2015-10-17 00:41:20 -04:00
Antoine Beaupré
4be9c29d0d os.link signature is the same as shutil.copy, use it directly 2015-10-17 00:38:14 -04:00
Antoine Beaupré
aaf72e3861 do not skip all attic tests, some work without now 2015-10-17 00:38:14 -04:00
Antoine Beaupré
6d457aed57 do not upgrade repositories in place by default
instead, we perform the equivalent of `cp -al` on the repository to
keep a backup, and then rewrite the files, breaking the hardlinks as
necessary.

it has to be confirmed that the rest of Borg will also break hardlinks
when operating on files in the repository. if Borg operates in place
on any files of the repository, it could jeoperdize the backup, so
this needs to be verified. I believe that most files are written to a
temporary file and moved into place, however, so the backup should be
safe.

the rationale behind the backup copy is that we want to be extra
careful with user's data by default. the old behavior is retained
through the `--inplace`/`-i` commandline flag. plus, this way we don't
need to tell users to go through extra steps (`cp -a`, in particular)
before running the command.

also, it can take a long time to do the copy of the attic repository
we wish to work on. since `cp -a` doesn't provide progress
information, the new default behavior provides a nicer user experience
of giving an overall impression of the upgrade progress, while
retaining compatibility with Attic by default (in a separate
repository, of course).

this makes the upgrade command much less scary to use and hopefully
will convert drones to the borg collective.

the only place where the default inplace behavior is retained is in
the header_replace() function, to avoid breaking the cache conversion
code and to keep API stability and semantic coherence ("replace" by
defaults means in place).
2015-10-17 00:38:07 -04:00
Thomas Waldmann
9b10e8a3f3 if borg.exe is not present, do not try to test it 2015-10-16 00:52:23 +02:00
Thomas Waldmann
1a248116db move cmd fixture to archiver test module 2015-10-16 00:18:46 +02:00
Thomas Waldmann
4b7c02775e benchmarks: test with both the binary and the python code
we use forking mode always and either execute python with the archiver module or the "borg.exe" binary.
the cmd fixture alternates between 'python' and 'binary' mode and calls exec_cmd accordingly.
2015-10-16 00:12:02 +02:00
Thomas Waldmann
7efab2f254 benchmark tests: improve comments 2015-10-14 01:00:25 +02:00
Thomas Waldmann
a5a6ba0d77 integrate pytest-benchmark, test create, extract, list, delete, info, check, help, fixes #146
Instead of "realistic data", I chose the test data to be either all-zero (all-ascii-zero to be precise)
or all-random and benchmark them separately.
So we can better determine the cause (deduplication or storage) in case we see some performance regression.

"help" is benchmarked to see the minimum runtime when it basically does nothing.

also:
- refactor archiver execution core functionality into exec_cmd() so it can be used more flexibly
- tox: usually we want to skip benchmarks, only run them if requested manually
- install pytest-benchmark - run tox with "-r" to have it installed into your .tox envs
2015-10-11 16:07:11 +02:00
Antoine Beaupré
dbc183f87f drop support for Python 2 2015-10-09 14:13:58 -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é
fd41408de2 move progress information out of tests and back in converter
this was a remnant of when i was writing the converter/upgrader code,
and was destined to be a general progress message in the migration
process. i removed a more technical, internal debugging message in
exchange
2015-10-09 12:34:05 -04:00
Antoine Beaupré
efa88ef6c6 fix tests: they expect check to spew output
our default verbosity shows only warnings, we'd have to tweak tests to be verbose for this to work

This reverts commit 27be46a5ba.
2015-10-09 12:28:29 -04:00
Thomas Waldmann
60d3b24df4 tagged/signed 0.27.0
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABCgAGBQJWFPIaAAoJECQ6z6lR944Bl6UQAJsRgzQqQBEFk1tmQiDjox36
 QEJA4SyaK6dPCKqxjXNVQ8T/hdDWm2mNGoxBq3A/gcLoU4NRg73DnxroPTg0YRtR
 /mX8ojyjA0Yz9mAAFCGm8LMgTXLRBxqjpow6U/89kA/iOJbfIr4sO0a6cCI/hr9c
 7lL7ZGXO5hgVP7OugJMvLpSG/mW8xRckIW6xx3wjSvcORYPerPAoDpotDGIdMzNy
 UvqZI+TIMIeW1U85PSKa0uODrxdtnVKHBxCJRznqAYb7mOButeYY3u7Ya48oMjdB
 ZucipdWQh++lTod7zhRmczkridVrH229mKMsoA2t9fxmkiJsqkTKzpB+70l8ws+H
 76YQsPc81VJyNg6Cj9rRqrbfSjQ8Wms9+SnKzD9f0MkyyHgwUwkOZhZph5DXH6xn
 xbHbwhBhYbtFyxTXhb9UJMjY2gUREWZ48BDbf81jHUIVfCo9IuXyeWnoEoRmYBJ5
 GGB0ul2V1LG6+divoS9K3HEzf+MPW3nQCi3U4J71wvYDfDR2JggFVayXt/aL/D3E
 ED2FJZMQEQXA5vPKmosBcDr7u1vv7SZ3pjzzbyDLMHHzOG36ScxKkAIzULjpWWhP
 y9fnOv+V2g7Hoq0y3XxBLel3P0Uvx1AADqgKUTeLK0GiSLndqEehHrU1TiYYq077
 NurFcaa97j08b1l8Dif2
 =q6Ou
 -----END PGP SIGNATURE-----

Merge tag '0.27.0' into multithreading

tagged/signed 0.27.0
2015-10-09 17:18:34 +02:00
Antoine Beaupré
1c61f87da3 remove debugging code and fix all have_cython calls 2015-10-08 17:20:52 -04:00
Antoine Beaupré
80e53fb66d it's a function, call it as such 2015-10-08 17:16:11 -04:00
Antoine Beaupré
a1dad8c9da try to mock msgpack altogether to fix RTD again
it seems that msgpack is a hard depends in archive...
2015-10-08 17:06:48 -04:00
Antoine Beaupré
a869ab0702 try to fix RTD build *again* *again* 2015-10-08 17:03:35 -04:00
Antoine Beaupré
e8ae96b54e try to fix RTD build *again* 2015-10-08 17:01:42 -04:00
Antoine Beaupré
f2c56fb890 try to fix build on RTD *again* 2015-10-08 16:57:36 -04:00
Antoine Beaupré
3f68399463 style: wrap multiline strings elegantly 2015-10-08 16:52:49 -04:00
Antoine Beaupré
a42a5e3e2d fix all logger pep8 warnings except long lines 2015-10-08 16:50:44 -04:00
Antoine Beaupré
8075a139b3 fix typo 2015-10-08 16:44:30 -04:00
Antoine Beaupré
b1eafe7833 remove status that is best reflected in VCS 2015-10-08 16:44:30 -04:00
Antoine Beaupré
2d4b735fed remove unintended changes 2015-10-08 16:38:53 -04:00
Antoine Beaupré
27be46a5ba tweak some levels 2015-10-08 16:31:22 -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é
ff483fe485 fix logical inversion in the semantics of detect_cython() 2015-10-08 15:31:46 -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
Antoine Beaupré
13d3568548 move usage generation to setup.py
this is an unfortunate rewrite of the manpage creation code mentionned
in #208. ideally, this would be rewritten into a class that can
generate both man pages and .rst files.
2015-10-07 21:07:15 -04:00
Thomas Waldmann
a4967ec582 ssh_cmd: fix wrong caller, fixes #255 2015-10-07 03:32:55 +02:00
Thomas Waldmann
8ddc448f41 make sure to always give segment and offset in repo IntegrityError exception messages
this was only handled correctly at one place, by adding the segment number afterwards.
now the segment number is always included.
2015-10-06 20:35:22 +02:00
Antoine Beaupré
d9e05946ac document logger module 2015-10-06 13:03:49 -04:00
Antoine Beaupré
42cc17caed use new logger object initialisation code 2015-10-06 12:57:27 -04:00
Antoine Beaupré
26561a7766 factor out logger object initialisation 2015-10-06 12:57:27 -04:00
Antoine Beaupré
2d0dae4e8b move logging setup to logger module 2015-10-06 12:57:26 -04:00
anarcat
7908c29180 Merge pull request #249 from anarcat/ssh-env
complete test coverage for SSH args parsing
2015-10-05 19:53:17 -04:00
Antoine Beaupré
a7b70d87cd complete test coverage for SSH args parsing 2015-10-05 19:22:33 -04:00
TW
745f9b89f8 Merge pull request #247 from anarcat/xdg
respect XDG_CACHE_HOME
2015-10-06 01:20:48 +02:00
TW
974dd58c23 Merge pull request #248 from anarcat/ssh-env
add support for arbitrary SSH commands
2015-10-06 01:20:23 +02:00
Antoine Beaupré
8f0de2cab7 fix tests on travis, which seem to set BORG_CACHE_DIR 2015-10-05 19:05:27 -04:00
Antoine Beaupré
a0ef4e25dd add support for arbitrary SSH commands (attic#99)
while SSH options can be specified through `~/.ssh/config`, some users
may want to use a completely different SSH command for their backups,
without overriding their $PATH variable. it may also be easier to do
ad-hoc configuration and tests that way.

plus, the POLA tells us that users expects something like this to be
supported by commands that talk to ssh. it is supported by rsync, git
and so on.
2015-10-05 18:54:00 -04:00
Antoine Beaupré
43a65933f7 move ssh generation code to a stub, add unit test 2015-10-05 18:51:20 -04:00
Antoine Beaupré
de2a811606 move RemoteRepository defaults to the class
the reasoning behind this is that we may need to test a
RemoteRepository setup outside of the main archiver routines, which
the current default location makes impossible

by moving the umask and remote_path remotes into the RemoteRepository
the (reasonable) defaults are available regardless of the (currently
obscure) initialisation routine, and make unit tests easier to develop
and support
2015-10-05 18:45:57 -04:00
Antoine Beaupré
427ddd64a6 respect XDG_CACHE_HOME
fixes attic#181
2015-10-05 17:50:46 -04:00