Commit Graph

1507 Commits

Author SHA1 Message Date
Jarek Kowalski
f517703079 Preliminary support for sessions (#752)
* content: fixed time-based auto-flush behavior to behave like Flush()

Previously it would sometimes be possible for a content whose write
started before time-based flush to finish writing afterwards (and it
would be included in the new index).

Refactored the code so that time-based flush happens before WriteContent
write and behaves exactly the same was as real Flush() so all writes
started before it will be awaited during the flush.

Also previous regression test was incorrect since it was mocking the
wrong blob method.

* content: refactored index blob manager crypto to separate file

This will be reused for encrypting session info.

* content: added support for session markers

Session marker (`s` blob) is written BEFORE the first data blob
(`p` or `q`) that belongs to new index segment (`n` is written).

Session marker is removed AFTER the index blob (`n`) has been written.

All pack and index blobs belonging to a session will have the session
ID as its suffix, so that if a reader can see `s<sessionID>` blob, they
will ignore any `p` and `q` blobs with the same suffix.

* maintenance: ignore blobs belonging to active sessions when running blob garbage collection

* cli: added 'sessions list' for listing active sessions

*  content: added retrying writing previously failed blobs before writing new one
2021-01-14 00:25:51 -08:00
Jarek Kowalski
ed9db56b87 Cleaned up and refactored object manager (#782)
* object: refactored Open() and VerifyObject() to be stateless

(no code movement yet to facilitate review)

* mechanical: moved function more appropriate files

* object: remove object manager tracing which was unused
2021-01-13 00:40:23 -08:00
Jarek Kowalski
34bf496570 Manifest manager refactoring (#776)
* manifest: refactored management of committed manifests into separate component

This is very similar to content.CommittedReadManager and allows
multiple writes to coexist and share the underlying committed manifest
manager.

Changed compaction to only include previously-committed manifests and
not any pending ones.

Added locking assertions for extra safety.
2021-01-09 07:39:25 -08:00
Jarek Kowalski
dcf2daa050 fixed goreleaser typo 2021-01-08 19:26:24 -08:00
Peter Palotas
ae37719e51 Improved .kopiaignore pattern matching (#773)
* Improved .kopiaignore pattern matching

.kopiaignore pattern matching now (hopefully) conforms to the .gitignore specification (https://git-scm.com/docs/gitignore)

Replaced old package "ignore" with a newly written "wcmatch" that manages the globbing. This should support all the patterns that .gitignore supports.  

Some changes in ignorefs that dealt with how the patterns were matched.

This fixes #571

* Fixed invalid matching of non-rooted patterns that contained a slash.

If a pattern contains a slash in the middle of the pattern this should only match relative to the .gitignore file, i.e. the same as if it started with a '/' according to the .gitignore spec.

Example:
foo/bar should match "/foo/bar", but not "/other/foo/bar".  
whereas 
"bar" matches both "/bar" and "/foo/bar"

* Uncommented previously failing tests.

* Fixed problem with matching "nested" .kopiaignore files.

Ignore-patterns must be applied from the root .kopiaignore down the hierarchy, so that an ignore file in a subdirectory can negate a pattern from a parent directory.

* Uncommented tests that should now work.
2021-01-08 08:13:18 -08:00
Peter Palotas
cd8f3e81b8 Created end-to-end tests verifying .kopiaignore behavior. (#774)
* Created end-to-end tests verifying .kopiaignore behavior.

This is related to #571 and #773, but provided as a separate PR to include tests that did not work before PR #773.

* Commented failing tests.

These tests will be re-enabled when #773 is done.

* Added additional commented tests of .kopiaignore

These will be uncommented in #773.
2021-01-08 07:39:59 -08:00
Jarek Kowalski
73a34ff7ff trivial: move CachingOptions out of content.Manager, where it's not needed (#775)
* trivial: move CachingOptions out of content.Manager, where it's not needed

* trivial: removed newManagerWithOptions which was the same as NewManager

also moved one-time initialization to newReadManager()
2021-01-07 18:51:15 -08:00
Jarek Kowalski
8e17edcdf6 content: mechanical refactoring of content manager to extract CommittedReadManager (#771)
* content: introduced ContentReadManager
  This only introduces new type and reassigns methods
* content: moved all CommittedReadManager methods to one file
* content: more code movement
* content: refactored read manager setup
* content: refactored test hook that allowed cleaner passing of custom own writes cache
2021-01-07 00:39:20 -08:00
Jarek Kowalski
d3a6421213 cli: make sure we don't run maintenance as part of read-only actions (#769)
* cli: make sure we don't run maintenance as part of read-only actions

* cli: classified some actions that use *repo.DirectRepository as read-only too
2021-01-05 21:55:02 -08:00
Jarek Kowalski
f1b471d7e6 Fixes for test flakes (#770)
* testing: prevented spurious test flakes caused by kopia subprocesses messing with stderr

This was not causing actual failures, but misreporting error messages.

* testing: ensure random names are always unique by adding a counter
2021-01-05 21:37:23 -08:00
dependabot[bot]
d09bdb21e0 build(deps): bump axios from 0.19.2 to 0.21.1 in /htmlui (#768)
Bumps [axios](https://github.com/axios/axios) from 0.19.2 to 0.21.1.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v0.21.1/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v0.19.2...v0.21.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-05 17:54:11 -08:00
Jarek Kowalski
a8a772c293 performance: improve performance of fragmented index lookups (#765)
* performance: improve performance of fragmented index lookups

In a typical repository there will be many small indexes and few large
ones. If the number gets above ~100 or so, things get very slow.

It helps to pre-merge very small indexes in memory to reduce the number
of binary searches and mmaped IO to perform. In some extreme cases
where we have many uncompacted index segments (each with just 1-2
entries), the savings are as quite dramatic.

In one case with >100 index segments the time to run
`kopia snapshot verify` went from 10m to 0.5m after this change.

In another well-maintained repository with 1.2M contents and
about 25 segments, the time to run `kopia snapshot verify` went from
48s to 35s.

Co-authored-by: Julio López <julio+gh@kasten.io>
2021-01-05 08:10:24 -08:00
Janne Johansson
f3737fef6e crypto -vs- compress (#766)
Probably a cut-n-paste error.
2021-01-05 07:03:57 -08:00
Jarek Kowalski
f751e4f5c7 cli: only run update check if the binary was built from GitHub and use the original repository name (#756) 2021-01-04 21:33:43 -08:00
Jarek Kowalski
5e8e175cfa repo: refactored read/write methods of repo.Repository (#749)
Reader methods go to repo.Reader and write methods go to repo.Writer
Switched usage to new interfaces based on linter errors.
2021-01-04 21:33:12 -08:00
CrendKing
d947f795f4 Add doc for mounting (#757)
Add link to docs for mount command on Windows
2021-01-03 10:36:55 -08:00
smiley
98b18a9c18 Fix typos in _index.md (#760) 2021-01-03 09:06:16 -08:00
CrendKing
588ff1c849 Fix hang at unmount when Ctrl-C is pressed (#754) 2020-12-31 13:55:05 -08:00
CrendKing
60aec0ee9f Fix bug that empty log directories are created on any command with --help argument (#753) 2020-12-30 17:00:38 -08:00
Jarek Kowalski
207009939f cli: only fetch the persisted password from keychain if one was not provided on the command line (#744)
This also fixed a test bug where the test was incorrectly passing
password via environment variable and it was (incorrectly) expected
to be ignored.

Password is determined in the following order:

- flag/environment variable (highest priority)
- persistent storage
- asking user (lowest priority)
2020-12-24 22:39:02 -08:00
Jarek Kowalski
d52af7cebb fixed cases where nil was passed to errors.Wrap() causing nil to be returned (#747) 2020-12-24 20:35:29 -08:00
Jarek Kowalski
f39de7fa57 ci: disable coverage upload temporarily 2020-12-24 12:14:33 -08:00
Jarek Kowalski
fd0e8ed2c9 ci: fix coveralls publishing 2020-12-24 11:24:31 -08:00
Jarek Kowalski
2079770654 ci: don't allocate tty when running docker, since it's not supported on GH 2020-12-24 10:03:42 -08:00
Jarek Kowalski
97d630cc65 CI tweaks (#742)
* ci: run full release only on amd64

* ci: logging for apt-publish.sh

* ci: stop building website in Makefile as it's already handled by Netlify
2020-12-24 09:00:30 -08:00
Jarek Kowalski
2541f0013c ci: GitHub actions support (#739)
This mimics Travis behavior and also allows making full local release
from a GH owner other than 'kopia' as long as required secrets are
provided.

Supports:

- basic testing on PRs
- publishing kopia RPM, DEB and TAR.GZ release to <owner>/kopia
  (on tags)
- publishing KopiaUI release to <owner>/kopia (on tags)
  or <owner>/kopia-ui-release (on master)
- publishing RPM and APT packages from official kopia/kopia and
  master branch only

Verified on jkowalski/kopia clone:

Tags:
https://github.com/jkowalski/kopia/actions/runs/439735808
https://github.com/jkowalski/kopia/releases/tag/v0.8.0-testing4

Post-submit:
https://github.com/jkowalski/kopia/actions/runs/439720039
https://github.com/jkowalski/kopia-ui-release/releases/tag/v20201222.0.225118

* ci: remove .travis.yml
* testing: skip tests if environment values are empty
* ci: run heavyweight tests on amd64 only
* ci: remove .appveyor.yml
* makefile: removed appveyor travis emulation
2020-12-24 01:11:57 -08:00
Jarek Kowalski
e03971fc59 Upgraded linter to v1.33.0 (#734)
* linter: upgraded to 1.33, disabled some linters

* lint: fixed 'errorlint' errors

This ensures that all error comparisons use errors.Is() or errors.As().
We will be wrapping more errors going forward so it's important that
error checks are not strict everywhere.

Verified that there are no exceptions for errorlint linter which
guarantees that.

* lint: fixed or suppressed wrapcheck errors

* lint: nolintlint and misc cleanups

Co-authored-by: Julio López <julio+gh@kasten.io>
2020-12-21 22:39:22 -08:00
Jarek Kowalski
246dcf80ba testing: added 'snapshot verify' test 2020-12-21 20:02:53 -08:00
Jarek Kowalski
d7ca543356 cli: improvements to 'snapshot verify'
* When running against direct repository, it will verify that all
  backing blobs exist based on results of listing.
* Deprecated annoying --all-sources flag which is now default if no
  sources are provided.
2020-12-21 20:02:53 -08:00
Jarek Kowalski
eecd9d13c9 actions: Added --enable-actions flag (#737)
This can be specified at `repo create` or `repo connect` to enable
actions. By default actions are disabled to avoid security risks
associated with executing code.

Alternatively during `snapshot create` one can specify
`--force-enable-actions` or `--force-disable-actions`
2020-12-21 18:05:25 -08:00
Jarek Kowalski
213a557435 ci: run make on GitHub actions (#736) 2020-12-21 17:15:46 -08:00
Jarek Kowalski
4f7d211f72 Added support for actions that run before&after snapshot roots and before/after specific folders (#722)
* policy: add actions
* fs: added LocalFilesystemPath() which can optionally return local filesystem
  path (if entry is local)
* cli: added support for setting policy actions
* upload: support for executing actions before/after folder (non-inheritable)
  and before/after snapshots (inheritable)
* testing: end-to-end test for actions
* additional tests for actions with embedded scripts
2020-12-21 15:53:21 -08:00
Jarek Kowalski
72a33729e2 ci: moved building and testing htmlui and app to separate GH action (#733) 2020-12-21 15:08:08 -08:00
Jarek Kowalski
f279a5be69 'kopia policy set' code cleanup (#730)
* cli: split command_policy_set.go by individual areas

* cli: refactored 'policy set' implementation to reuse helpers

* use defined const instead of literal

Co-authored-by: Julio López <julio+gh@kasten.io>
2020-12-18 10:55:43 -08:00
Jarek Kowalski
450a282c2d Makefile: removed stale comment 2020-12-18 10:11:33 -08:00
Jarek Kowalski
7873fe8681 Makefile: various tricks to make PR builds faster (#727)
Avoid running goreleaser on PRs, and only build the kopia binary for the platform being tested.
2020-12-17 23:13:08 -08:00
Julio López
3795ffc6f9 robustness: minor cleanups (#726)
Remove unnecessary intermediate variables.
Send SIGTERM instead of SIGKILL to terminate child kopia server process.
Set Pdeathsig on Linux for child kopia server process.
Trivial: reduce scope of hostFioDataPathStr variable.
Trivial: rename local variable.
Trivial: Use log.Fatalln instead of log + exit(1).
Improve error message in robustness test to tell apart failure cause.
2020-12-16 12:49:54 -08:00
Julio López
4eb8f71567 Helper script to run robustness job (#721) 2020-12-15 20:32:19 -08:00
Julio López
35346863d2 robustness: add support for kopia server storage repo (#720)
Adds single client to server robustness tests.

Co-authored-by: Rahul M Chheda <rchheda@infracloud.io>
2020-12-15 17:56:30 -08:00
Julio López
7f9271f55a build(deps): bump ini from 1.3.5 to 1.3.8 in /htmlui (#719)
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.8)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-15 12:20:14 -08:00
Julio López
d2ab3ed0a4 build(deps): bump ini from 1.3.5 to 1.3.8 in /app (#718)
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.8)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-15 10:27:50 -08:00
Jarek Kowalski
ad4b222939 cli: added support for copying (or moving) snapshot history (#703)
Both source and destination can be specified using user@host,
@host or user@host:/path where destination values override the
corresponding parts of the source, so both targeted
and mass copying is supported.

Supported combinations are:

Source:             Destination         Behavior
---------------------------------------------------
@host1              @host2              copy snapshots from all users of host1
user1@host1         @host2              copy all snapshots to user1@host2
user1@host1         user2@host2         copy all snapshots to user2@host2
user1@host1:/path1  @host2              copy to user1@host2:/path1
user1@host1:/path1  user2@host2         copy to user2@host2:/path1
user1@host1:/path1  user2@host2:/path2  copy snapshots from single path

When --move is specified, the matching source snapshots are also deleted.

* cli: upgraded kingpin to latest version (not tagged)

This allows using `EnableFileExpansion` to disable treating
arguments prefixed with "@" as file includes.
2020-12-04 16:34:55 -08:00
Jarek Kowalski
e8714cb2a1 s3: upgraded to minio v7 (#707) 2020-12-02 19:46:05 -08:00
Nick
71dcbcf2e3 Robustness engine actions with stats and log (#685)
* Robustness engine actions with stats and logging

- Add actions to robustness engine
- Actions wrap other functional behavior and serve as a common interface for collecting stats
- Add stats for the engine, both per run and cumulative over time
- Add a log for actions that the engine has executed
- Add recovery logic to re-sync snapshot metadata after a possible failed engine run (e.g. if metadata wasn't properly persisted).

Current built-in actions:
- snapshot root directory
- restore random snapshot ID into a target restore path
- delete a random snapshot ID
- run GC
- write random files to the local data directory
- delete a random subdirectory under the local data directory
- delete files in a directory
- restore a snapshot ID into the local data directory

Actions are executed according to a set of options, which dictate the relative probabilities of picking a given action, along with ranges for action-specific parameters that can be randomized.
2020-11-17 01:07:04 -08:00
darkdragon-001
ade7975212 Improve ignore logic. (#496)
* Improve ignore logic.

- Add test cases for absolute patterns
- Support globs for absolute patterns

* Test exclude-include (not supported yet).
2020-11-08 17:26:48 -08:00
collectorgeneral
6cf6e4dc5d Update _index.md (#697)
Was reading the docs to do some tests and found a couple of missing words and punctuation. Submitting this PR to propose fixes to the one I found.
2020-11-08 09:36:03 -08:00
Jarek Kowalski
c61616d700 go.mod: ran go mod tidy (#696) 2020-11-01 11:06:16 -08:00
Piotr Tabor
bf729095dc Fuse: Passthrough options to allow other-users access and mounting in empty directory. (#691) 2020-10-31 21:57:27 -07:00
Julio López
dddee8a5ec Trivial: Rename local_fs_output_unix.go => local_fs_output_darwin.go (#684) 2020-10-15 13:34:51 -07:00
Erkki Seppälä
6a93e4d5b9 Added support for scanning only one filesystem via files policy (#676)
The new files policy oneFileSystem ignores files that are mounted to
other filesystems similarly to tar's --one-file-system switch. For
example, if this is enabled, backing up / should now automatically
ignore /dev, /proc, etc, so the directory entries themselves don't
appear in the backup. The value of the policy is 'false' by default.

This is implemented by adding a non-windows-field Device (of type
DeviceInfo, reflecting the implementation of Owner) to the Entry
interface. DeviceInfo holds the dev and rdev acquired with stat (same
way as with Owner), but in addition to that it also holds the same
values for the parent directory. It would seem that doing this in some
other way, ie. in ReadDir, would require modifying the ReadDir
interface which seems a too large modification for a feature this
small.

This change introduces a duplication of 'stat' call to the files, as
the Owner feature already does a separate call. I doubt the
performance implications are noticeable, though with some refactoring
both Owner and Device fields could be filled in in one go.

Filling in the field has been placed in fs/localfs/localfs.go where
entryFromChildFileInfo has acquired a third parameter giving the the
parent entry. From that information the Device of the parent is
retrieved, to be passed off to platformSpecificDeviceInfo which does
the rest of the paperwork. Other fs implementations just put in the
default values.

The Dev and Rdev fields returned by the 'stat' call have different
sizes on different platforms, but for convenience they are internally
handled the same. The conversion is done with local_fs_32bit.go and
local_fs_64bit.go which are conditionally compiled on different
platforms.

Finally the actual check of the condition is in ignorefs.go function
shouldIncludeByDevice which is analoguous to the other similarly named
functions.

Co-authored-by: Erkki Seppälä <flux@inside.org>
2020-10-14 22:45:32 -07:00