Commit graph

230 commits

Author SHA1 Message Date
Thomas Waldmann
6df21df3f4 Merge branch 'master' into multithreading
Note: although I hopefully fixed all the conflicts,
some tests are quite broken.

Conflicts:
	borg/_chunker.c
	borg/archive.py
	borg/archiver.py
	borg/cache.py
	borg/helpers.py
	borg/testsuite/archiver.py
2016-02-04 20:34:18 +01:00
Thomas Waldmann
4b339f5d69 cosmetic source cleanup (flake8) 2016-01-30 21:32:45 +01:00
TW
9797ab0130 Merge pull request #612 from ThomasWaldmann/fix-544
borg serve: overwrite client's --restrict-to-path with forced command's …
2016-01-30 20:04:09 +01:00
Thomas Waldmann
b8d954e60a use XDG_CONFIG_HOME for borg keys instead of ~/.borg, fixes #515 2016-01-28 22:26:58 +01:00
Thomas Waldmann
7ea2404048 borg serve: overwrite client's --restrict-to-path with forced command's option value, fixes #544
we also make sure the client is not cheating, like giving another subcommand or his own --restrict-to-path.
2016-01-28 21:59:24 +01:00
Thomas Waldmann
3476fffe7d remove deprecated "--compression <number>"
use --compression zlib,<number> instead
in case of 0, you could also use --compression none
2016-01-24 16:04:00 +01:00
Thomas Waldmann
ad31fcd7c0 remove deprecated "--hourly/daily/weekly/monthly/yearly"
use --keep-hourly/daily/weekly/monthly/yearly instead

note: kept the code and test, we might have deprecated option in future, too
2016-01-24 16:04:00 +01:00
Thomas Waldmann
e1515ee251 remove deprecated "borg verify"
use borg extract --dry-run ...
2016-01-24 16:04:00 +01:00
Thomas Waldmann
2f9b643edb migrate-to-repokey command, dispatch passphrase type to repokey handler
every chunk has the encryption key type as first byte and we do not want to rewrite the whole repo
to change the passphrase type to repokey type. thus we simply dispatch this type to repokey
handler.
if there is a repokey that contains the same secrets as they were derived from the passphrase, it will just work.
if there is none yet, one needs to run migrate-to-repokey command to create it.
2016-01-24 16:04:00 +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
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
5607e5aefe use os.urandom instead of own cython openssl RAND_bytes wrapper, fixes #493 2016-01-24 15:40:04 +01:00
Thomas Waldmann
3ade3d8a41 use hashlib.pbkdf2_hmac from py stdlib instead of own openssl wrapper
this is available in python 3.4+.

note:
before removing the pbkdf tests, i ran them with the pbkdf from stdlib to make sure it gives same result.
long term testing of this now belongs into stdlib tests, not into borg.
2016-01-24 15:40:04 +01:00
Thomas Waldmann
7c8bfe6681 __file__ is now always an absolute path (3.4) 2016-01-24 15:36:04 +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
fe8762ad28 os.utime on py 3.4+ always supports fd and follow_symlinks 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
19998888ba remove support for missing PermissionError on py 3.2 2016-01-24 14:57:48 +01:00
Thomas Waldmann
dabac6a4ed use mock from stdlib, fixes #145 2016-01-24 14:57:48 +01:00
Michael Hanselmann
c7fb598ab9 Add shell-style pattern syntax
The fnmatch module in Python's standard library implements a pattern
format for paths which is similar to shell patterns. However, “*”
matches any character including path separators. This newly introduced
pattern syntax with the selector “sh” no longer matches the path
separator with “*”. Instead “**/” can be used to match zero or more
directory levels.
2016-01-21 16:07:24 +01:00
Michael Hanselmann
ceae4a9fa8 Support patterns on extraction, fixes #361
This change implements the functionality requested in issue #361:
extracting files with a given extension. It does so by permitting
patterns to be used instead plain prefix paths. The pattern styles
supported are the same as for exclusions.
2016-01-18 21:26:08 +01:00
Michael Hanselmann
848375e2fe Add and document path prefix as pattern style
The “extract” command supports extracting all files underneath a given
set of prefix paths. The forthcoming support for extracting files using
a pattern (i.e. only files ending in “.zip”) requires the introduction
of path prefixes as a third pattern style, making it also available for
exclusions.
2016-01-18 21:26:08 +01:00
Michael Hanselmann
190107ada7 Replace use of “exclude_path” in tests
The newly added pattern matcher class can replace the “exclude_path”
function. The latter is going to be removed in a later change.
2016-01-18 20:59:08 +01:00
Michael Hanselmann
9747755131 Add pattern matcher wrapper
The utility functions “adjust_patterns” and “exclude_path” produce
respectively use a standard list object containing pattern objects.
With the forthcoming introduction of patterns for filtering files
to be extracted it's better to move the logic of these classes into
a single class.

The wrapper allows adding any number of patterns to an internal list
together with a value to be returned if a match function finds that
one of the patterns matches. A fallback value is returned otherwise.
2016-01-18 20:59:08 +01:00
Michael Hanselmann
c1feb4b532 Simplify pattern tests
- Stop using “adjust_pattern” and “exclude_path” as they're utility
  functions not relevant to testing pattern classes
- Cover a few more cases, especially with more than one path separator
  and relative paths
- At least one dedicated test function for each pattern style as opposed
  to a single, big test mixing styles
- Use positive instead of negative matching (i.e. the expected list of
  resulting items is a list of items matching a pattern)
2016-01-18 20:47:22 +01:00
Robin Schneider
576348a9d4
Use HTTPS everywhere. Especially when the website already redirects to HTTPS. 2016-01-17 22:31:08 +01:00
Michael Hanselmann
3a39ddbd83 Rename pattern classes for consistency
The class names “IncludePattern” and “ExcludePattern” may have been
appropriate when they were the only styles. With the recent addition of
regular expression support and with at least one more style being added
in forthcoming changes these classes should be renamed to be more
descriptive. “ExcludeRegex” is also renamed to match the new names.
2016-01-15 17:16:25 +01:00
Michael Hanselmann
2c7ab8595d Refactor Unicode pattern tests
The unit tests for Unicode in path patterns contained a lot of
unnecessary duplication. One set of duplication was for Mac OS X (also
known as Darwin) as it normalizes Unicode in paths to NFD. Then each
test case was repeated for every type of pattern.

With this change the tests become parametrized using py.test. The
duplicated code has been removed.
2016-01-15 17:16:25 +01:00
Thomas Waldmann
96f88a29d2 add --list option for borg create
like --stats enables statistics output, --list enables the file/dirs list output.
2016-01-14 18:57:05 +01:00
Michael Hanselmann
2369b8a0f2 Strip whitespace when loading exclusions from file
Patterns to exclude files can be loaded from a text file using the
“--exclude-from” option. Whitespace at the beginning or end of lines was
not stripped. Indented comments would be interpreted as a pattern and
a misplaced space at the end of a line--some text editors don't strip
them--could cause an exclusion pattern to not match as desired. With the
recent addition of regular expression support for exclusions the spaces
can be matched if necessary (“^\s” or “\s$”), though it's highly
unlikely that there are many paths deliberately starting or ending with
whitespace.
2016-01-13 17:39:22 +01:00
Michael Hanselmann
2bafece093 Implement exclusions using regular expressions
The existing option to exclude files and directories, “--exclude”, is
implemented using fnmatch[1]. fnmatch matches the slash (“/”) with “*”
and thus makes it impossible to write patterns where a directory with
a given name should be excluded at a specific depth in the directory
hierarchy, but not anywhere else. Consider this structure:

  home/
  home/aaa
  home/aaa/.thumbnails
  home/user
  home/user/img
  home/user/img/.thumbnails

fnmatch incorrectly excludes “home/user/img/.thumbnails” with a pattern
of “home/*/.thumbnails” when the intention is to exclude “.thumbnails”
in all home directories while retaining directories with the same name
in all other locations.

With this change regular expressions are introduced as an additional
pattern syntax. The syntax is selected using a prefix on “--exclude”'s
value. “re:” is for regular expression and “fm:”, the default, selects
fnmatch. Selecting the syntax is necessary when regular expressions are
desired or when the desired fnmatch pattern starts with two alphanumeric
characters followed by a colon (i.e. “aa:something/*”). The exclusion
described above can be implemented as follows:

  --exclude 're:^home/[^/]+/\.thumbnails$'

The “--exclude-from” option permits loading exclusions from a text file
where the same prefixes can now be used, e.g. “re:\.tmp$”.

The documentation has been extended and now not only describes the two
pattern styles, but also the file format supported by “--exclude-from”.

This change has been discussed in issue #43 and in change request #497.

[1] https://docs.python.org/3/library/fnmatch.html

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
2016-01-13 17:39:19 +01:00
Michael Hanselmann
5d40eba175 Convert pattern test to py.test
The test for exclusion patterns was written using the standard unittest
module. The py.test module provides facilities to parametrize the test.
2016-01-13 12:39:37 +01:00
Michael Hanselmann
02e04653b6 Factorize and test loading of excludes from file
The parsing code for exclude files (given via `--exclude-from`) was not
tested. Its core is factorized into a separate function to facilitate an
easier test. The observable behaviour is unchanged.
2016-01-11 12:24:26 +01:00
Thomas Waldmann
57b913bc88 fix badly named environment variable, fixes #503
added: BORG_DELETE_I_KNOW_WHAT_I_AM_DOING for the check in "borg delete"
2015-12-20 02:03:33 +01:00
Thomas Waldmann
95f6cd4a4e Merge branch 'master' of github.com:borgbackup/borg 2015-12-13 14:26:49 +01:00
Thomas Waldmann
aa97724c0c add --prefix to check to check only some specific archives, fixes #206 2015-12-13 00:39:52 +01:00
Thomas Waldmann
229512b6f5 determine log level from the logger, so it works with logging.conf also 2015-12-12 22:15:08 +01:00
Thomas Waldmann
eab60cce99 pass through some global options from client to server
new: logging level options
refactored:
- umask option and remote_path
- cleanly separated ssh command from borg command
2015-12-12 22:15:08 +01:00
Thomas Waldmann
9c271afefa unify repo/archive parameter name to "location" 2015-12-12 22:15:08 +01:00
Thomas Waldmann
34b35761dd remove --progress magic, fixes #476
For 0.29 we worked towards a "silent by default" behaviour, so interactive usage will include -v more frequently in future.

But I noticed that this conflicts with the progress display. This would be no problem if users willingly decide which one
of --verbose or --progress they want to see, but before this fix, the progress display was activated magically when
a tty was detected. So, to counteract this magic, users would need to use --no-progress.

That's backwards imho, so I removed the magic again and users have to give --progress when they want
to see a progress indicator. Or (alternatively) they give --verbose when they want to see the long file list.
2015-12-10 10:28:43 +01:00
Thomas Waldmann
499b6f7313 add a test that invokes borg prune --save-space 2015-12-08 18:36:41 +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
Thomas Waldmann
cb821b119b remove --log-level, add --debug and --info option, update docs
removed --log-level due to overlap with how --verbose works now.

for consistency, added --info as alias to --verbose (as the effect is
setting INFO log level).

also added --debug which sets DEBUG log level.
note: there are no messages emitted at DEBUG level yet.

WARNING is the default (because we want mostly silent behaviour,
except if something serious happens), so we don't need --warning
as an option.
2015-12-08 01:37:34 +01:00
Thomas Waldmann
68225af449 archive checker: remove report_progress, fix log levels 2015-12-08 00:59:41 +01:00
TW
f5634092a2 Merge pull request #455 from ThomasWaldmann/add-progress-indication
Add progress indication, fixes #394
2015-12-03 15:04:44 +01:00
Thomas Waldmann
df24ce5acd progress indicators: add tests 2015-12-03 14:45:16 +01:00
TW
9005586ca4 Merge pull request #452 from ThomasWaldmann/hashtable
misc. hash table tuning
2015-12-02 16:45:39 +01:00
Thomas Waldmann
21bd01ef16 add a --filter option replacing --changed/--unchanged
the problem here was that we do not just have changed and unchanged items,
but also a lot of items besides regular files which we just back up "as is" without
determining whether they are changed or not. thus, we can't support changed/unchanged
in a way users would expect them to work.

the A/M/U status only applies to the data content of regular files (compared to the index).
for all items, we ALWAYS save the metadata, there is no changed / not changed detection there.

thus, I replaced this with a --filter option where you can just specify which
status chars you want to see listed in the output.

E.g. --filter AM will only show regular files with A(dded) or M(odified) state, but nothing else.
Not giving --filter defaults to showing all items no matter what status they have.

Output is emitted via logger at info level, so it won't show up except if the logger is at that level.
2015-12-02 03:29:20 +01:00