Commit Graph

249 Commits

Author SHA1 Message Date
Thomas Waldmann 24d3400dd4 borg export-tar: fix memory leak with ssh: remote repository, fixes #5568
also: added a comment how to avoid this kind of memory leak.
2020-12-17 22:55:13 +01:00
Guinness 9052c1cc54
Add repo location to the stats in borg create 2020-12-16 13:46:29 +01:00
Lapinot 34f6cfcd81
Outsource recursive directory walking (#5492)
Split recursive directory walking/processing into walking and item processing.
2020-11-15 15:31:01 +01:00
Phil Kulin c0504c0669 create: implement --stdin-mode, --stdin-user and --stdin-group, #5333 2020-11-01 20:45:56 +03:00
Thomas Waldmann 0839ac3034 prettier error message when archive gets too big, fixes #5307 2020-09-08 21:00:27 +02:00
Thomas Waldmann d2536de4ee fix hardlinked CACHEDIR.TAG processing, fixes #4911 2020-06-14 22:00:02 +02:00
Thomas Waldmann dee402652f --read-special: .part files also should be regular files, fixes #5217 2020-06-14 15:36:22 +02:00
Peter Gerber 00b09370c0
Allow creating archives using stdout of given command (#5174)
allow creating archives using stdout of given command

In addition to allowing:

some-command --param value | borg create REPO::ARCH -

also allow:

borg create --content-from-command create REPO::ARCH -- some-command --param value

The difference is that the latter approach deals with errors properly.
In the former example, an archive is created no matter what. Even, if
`some-command` aborts and the output is truncated, Borg won't realize.
In the latter example, the status code is checked and archive creation
is aborted properly when appropriate.
2020-06-02 22:24:14 +02:00
Elmar Hoffmann dad3aa9dae rename local preload() function to not overwrite keyword argument of same name
The locally defined preload() function overwrites the preload boolean keyword
argument, always evaluating to true, so preloading is done, even when not
requested by the caller, causing a memory leak.
Also move its definition outside of the loop.

This issue was found by Antonio Larrosa in borg issue #5202.
2020-06-01 17:12:51 +02:00
Thalian 08a7661e67 [FEATURE] #4489 – Deprecate --nobsdflags option
Replaced by --noflags. In internal data structure the key 'bsdflags' is kept for backwards compatibility.
2020-03-25 06:35:15 +01:00
Thomas Waldmann 046dea8643 check: do not stumble over invalid item key, fixes #4845
The code used for error reporting crashes due to an invalid utf-8
sequence. Use errors='replace' to never crash there. Errors
are expected in input data when borg check is run.
2020-03-09 00:12:36 +01:00
TW 597b09a993 support platforms with no os.link (#4903)
support platforms with no os.link, fixes #4901

if we don't have os.link, we just extract another copy instead of making a hardlink.

for that to work, we need to have (and keep) the chunks list in hardlink_masters.
2020-03-03 23:34:54 -05:00
Thomas Waldmann a8831f4978 fix ProgressIndicator msgids, fixes #4935
add some to code, fix docs.
2020-03-03 23:57:36 +01:00
Rémi Oudin a029d686b5 Borg recreate timestamp is a no op (#4815)
recreate: support --timestamp option, fixes #4745
2019-11-16 11:03:34 +01:00
TW aa7df50a2d
Merge pull request #4635 from ThomasWaldmann/ctrlc-checkpoint
first ctrl-c: checkpoint and abort, fixes #4606
2019-09-06 21:44:07 +02:00
Thomas Waldmann cb2d31ed98 fix partial extract for hardlinked contentless file types, fixes #4725
if the file is not a regular file, but a hardlink slave with a not
extracted hardlink master, chunks will be None and we must not call
preload(chunks).

(cherry picked from commit 291d58efa1)
2019-08-27 19:20:20 +05:30
Thomas Waldmann 9732fe4965 special behaviour on first ctrl-c, fixes #4606
like:
 - try saving a checkpoint if borg create is ctrl-c-ed
2019-08-25 22:49:09 +02:00
Jürg Rast bff97a99e1 Windows specific directory handling
On windows os.open does not work for directories.
If borg tries to open an directory on windows, None is returned
as file descriptor. The archive and archiver where adjusted to
handle the case if a file descriptor is None.
2019-08-24 10:17:18 +02:00
Thomas Waldmann 71c7efd17c extract: fix KeyError for "partial" extraction, fixes #4607
note that "partial" even applied to giving an always matching condition.

"full" is only assumed if no conditions are given.
2019-06-10 20:18:44 +02:00
Thomas Waldmann f33f318d81 preload chunks for hardlink slaves w/o preloaded master, fixes #4350
also split the hardlink extraction test into 2 tests.
2019-05-06 02:06:58 +02:00
Thomas Waldmann 502ebe63be delete archive: consider part files correctly for stats, see #4507 2019-04-19 19:29:30 +02:00
Thomas Waldmann cd4f6b41ca create: only run stat_simple_attrs() once
the second call was done in stat_attrs().

this increases backup with lots of unchanged files performance by ~ 5%.
2019-04-08 21:34:09 +02:00
Thomas Waldmann b3751b107d determine whether a file has changed while being backed up, fixes #1750 2019-03-11 22:55:27 +01:00
Thomas Waldmann 6809f6f7fa calc_stats: use archive stats metadata, if available
by default, we still have to compute unique_csize the slow way,
but the code offers want_unique=False param to not compute it.
2019-02-23 15:05:07 +01:00
Thomas Waldmann e569595974 include size/csize/nfiles[_parts] stats into archive, fixes #3241 2019-02-23 15:05:07 +01:00
Thomas Waldmann 23eeded7c5 fix --read-special behaviour: follow symlinks pointing to special files
also: added a test for this.
2019-02-20 10:13:09 +01:00
Thomas Waldmann ec17f0a607 check for stat race conditions, see #908
we must avoid a handler processing a fs item of wrong file type,
so check if it has changed.
2019-02-20 09:16:57 +01:00
Thomas Waldmann 39922e88e5 micro-opt: get xattrs directly before acls
on linux, acls are based on xattrs, so do these closeby:

1. listxattr -> keys (without acl related keys)
2. for all keys: getxattr
3. acl-related getxattr by acl library
2019-02-17 02:46:03 +01:00
Thomas Waldmann 85b711fc88 opening device files is troublesome, don't do it
for fd-based operations, we would have to open the file, but for
char / block devices this has unwanted effects, even if we do not
read from the device.

thus, we use path (or dir_fd + name) based ops here.
2019-02-14 09:20:04 +01:00
Thomas Waldmann 833c49f834 use *at style functions (e.g. openat, statat) to avoid races
races via changing path components can be avoided by opening the
parent directory and using parent_fd + file_name combination with
*at style functions to access the directories' contents.
2019-02-14 09:20:04 +01:00
Thomas Waldmann ad5b9a1dfd _process / process_*: change to kwargs only
we'll add/remove some args soon, so many pos args would be just bad.
2019-02-14 09:20:03 +01:00
Thomas Waldmann 8220c6eac8 move/refactor Archive._open_rb function to helpers.os_open
also:
- add and use OsOpen context manager
- add O_NONBLOCK, O_NOFOLLOW, O_NOCTTY (inspired by gnu tar)
2019-02-14 09:20:03 +01:00
Thomas Waldmann 677102f292 process_file: avoid race condition: stat data vs. content
always open the file and then do all operations with the fd:
- fstat
- read
- get xattrs, acls, bsdflags
2019-02-14 09:20:03 +01:00
Thomas Waldmann ac0803fe0b chunker algorithms: use constants to avoid typos 2019-02-13 04:36:09 +01:00
Thomas Waldmann c4ffbd2a17 prepare to support multiple chunkers 2019-02-13 04:24:14 +01:00
TW b204201fb5
Merge pull request #4302 from ThomasWaldmann/repair-output
add archive name to check --repair output, fixes #3447
2019-02-04 03:29:58 +01:00
TW c3f40de606
cache_sync: compute size/count stats, borg info: consider part files (#4286)
cache_sync: compute size/count stats, borg info: consider part files

fixes #3522
2019-02-04 03:26:45 +01:00
Thomas Waldmann 18b62f63a6 add archive name to check --repair output, fixes #3447
so it does not look like duplicated and also informs the user about
affected archives.
2019-02-01 23:30:45 +01:00
Emmo Emminghaus 733a2bfa30 Introduce borg.platformflags.is_<os> 2018-11-10 23:34:43 +01:00
Emmo Emminghaus 558ca61d20 remove posix issues and fixup for unsupported methodes 2018-11-10 21:48:46 +01:00
Emmo Emminghaus b997d5ba5b move code from borg.helpers.usergroup to borg.platform.posix 2018-11-10 21:43:45 +01:00
Thomas Waldmann 10cdadb2f8 flake8: fix F841 2018-10-29 12:36:03 +01:00
Thomas Waldmann 3c173cc03b wrap msgpack, fixes #3632, fixes #2738
wrap msgpack to avoid future upstream api changes making troubles
or that we would have to globally spoil our code with extra params.

make sure the packing is always with use_bin_type=False,
thus generating "old" msgpack format (as borg always did) from
bytes objects.

make sure the unpacking is always with raw=True,
thus generating bytes objects.

note:

safe unicode encoding/decoding for some kinds of data types is done in Item
class (see item.pyx), so it is enough if we care for bytes objects on the
msgpack level.

also wrap exception handling, so borg code can catch msgpack specific
exceptions even if the upstream msgpack code raises way too generic
exceptions typed Exception, TypeError or ValueError.
We use own Exception classes for this, upstream classes are deprecated
2018-08-06 17:32:55 +02:00
Thomas Waldmann d2e2f1b89d call socket.gethostname only once 2018-08-04 17:40:40 +02:00
Thomas Waldmann de4afa097c separate borg compact command, fixes #2195 2018-07-14 14:29:28 +02:00
Thomas Waldmann 13e6970437 create: do not give chunker a py file object, it is not needed
the os level file handle is enough, the chunker will prefer it if
valid and won't use the file obj, so we can give None there.

this saves these unneeded syscalls:

fstat(5, {st_mode=S_IFREG|0664, st_size=227063, ...}) = 0
ioctl(5, TCGETS, 0x7ffd635635f0)  = -1 ENOTTY (Inappropriate ioctl for device)
lseek(5, 0, SEEK_CUR)             = 0
2018-07-07 18:06:57 +02:00
Thomas Waldmann 018b62c845 bsdflags: use fd instead of path
this optimization is only needed for linux, the bsd-like platforms
do not need an open file to run a ioctl against, but have bsdflags
in the stat result already.

on linux, this optimization saves 1 file open/close per input file.
2018-07-07 17:30:17 +02:00
Thomas Waldmann 7e47e68e29 acls: use fd instead of path 2018-07-07 17:02:37 +02:00
Thomas Waldmann 113b0eabec xattr: use fd for get_all
when processing regular files, use a fd to query xattrs.

when the file was modified and we chunked it, we have it open anyways.

if not, we open the file once and then query xattrs, in the hope that
this is more efficient than the path based calls.

guess it is less prone to race conditions in any case.
2018-07-07 15:47:56 +02:00
Thomas Waldmann 394d59e6d8 xattr: implement set_all to complement get_all
also: follow_symlinks param defaults to False (we do never use True)

fix tests, xattrs are set via FD now.
2018-07-07 15:47:56 +02:00