Commit Graph

44 Commits

Author SHA1 Message Date
Jarek Kowalski
30ca3e2e6c Upgraded linter to 1.40.1 (#1072)
* tools: upgraded linter to 1.40.1

* lint: fixed nolintlint vionlations

* lint: disabled tagliatele linter

* lint: fixed remaining warnings
2021-05-15 12:12:34 -07:00
Jarek Kowalski
74833cefcb cli: added standard --json flags to several commands (#910)
* cli: added standard --json flags to several commands

Fixes #272

* Update flag description

Co-authored-by: Julio López <julio+gh@kasten.io>
2021-03-25 17:55:18 -07:00
Pavan Navarathna
3e76169921 Support for stdin streams (#862)
* Add StreamingFile interface
* unit test for virtualfs
* CLI: Snapshot create support for stdin sources
* Uploader support for fs.StreamingFile
* End to end test for stdin source snapshot
* upload test to improve coverage
2021-03-04 15:34:05 -08:00
Jarek Kowalski
ac9f85967a Added first-class support for fs.ErrorEntry for directory entries that could not be read or are unknown/unsupported (#852)
* policy: added errorHandling.ignoreUnknownTypes flag (defaults to true)

* cli: get/set ignore-unknown-types policy flag

* htmlui: added UI for setting ignore-unknown-types

* htmlui: fixed typo

* fs: return fs.ErrorEntry when a directory entry is not recognized (localfs and repofs)

* upload: explicitly handle unknown entry types by treating them as ignored errors
2021-03-01 06:16:26 -08:00
Jarek Kowalski
23273af1cd snapshot: reworked error handling and added fail-fast option (#840)
Fixes #690

This is a breaking change for folks who are expecting snapshots to fail
quickly without writing a snapshot manifest in case of an error.

Before this change, any source read failure would cause the entire
snapshot to fail (and not write a snapshot manifest as a result),
unless `ignoreFileErrors` or `ignoreDirectoryErrors` was set.

The new behavior is to continue snapshotting remaining files and
directories (this can be disabled by passing `--fail-fast` flag or
setting `KOPIA_SNAPSHOT_FAIL_FAST=1` environment variable) and defer
returning an error until the very end.

After snapshotting we will always attempt to write the snapshot manifest
(except when the root of the snapshot itself cannot be opened). In case
of a fail-fast error, the manifest will be marked as 'partial' and
the directory tree will contain only partial set of files.

In case of any errors, the manifest (and each directory object) will
list the number if failures and no more than 10 examples of failed
files/directories along with their respective errors.

Once the snapshot is complete we will return non-zero exit code to the
operating system if there were any fatal errors during snapshotting.

With this change we are repurposing `ignoreFileErrors` and
`ignoreDirectoryErrors` to designate some errors as non-fatal.
Non-fatal errors are reported as warnings in the logs and will not
cause a non-zero exit code to be returned.
2021-02-17 10:29:01 -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
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
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
Jarek Kowalski
4d7f0cb6cd Fixed symlink restore behavior on macOS (#673)
* restore: use symlink-specific APIs instead of chmod, chown and chtimes

* upload: fix updating directory modtime for symlinks

* cli: plumbed through flags to restore to control new behaviors

* localfs: use Lstat() instead of Stat() in Child() method

* testing: added restore tests for new flags
2020-10-10 11:03:35 -07:00
Jarek Kowalski
ff6a414ec5 cli: When listing directory that had errors, print error summary at the end. (#643)
Can be disabled with `--no-error-summary`.
Quick demo: https://asciinema.org/a/2rma0sx2mD6HoIPy6VL0QEFeP

Also refactored fs.Directory to provide Summary optionally.
2020-09-25 09:06:41 -07:00
Jarek Kowalski
f0b97b960b Fixed checkpointing to not restart the entire upload process (#594)
* object: added Checkpoint() method to object writer

* upload: refactored code structure to allow better checkpointing

* upload: removed Checkpoint() method from UploadProgress

* Update fs/entry.go

Co-authored-by: Julio López <julio+gh@kasten.io>
2020-09-12 22:36:22 -07:00
Jarek Kowalski
9a6dea898b Linter upgrade to v1.30.0 (#526)
* fixed godot linter errors
* reformatted source with gofumpt
* disabled some linters
* fixed nolintlint warnings
* fixed gci warnings
* lint: fixed 'nestif' warnings
* lint: fixed 'exhaustive' warnings
* lint: fixed 'gocritic' warnings
* lint: fixed 'noctx' warnings
* lint: fixed 'wsl' warnings
* lint: fixed 'goerr113' warnings
* lint: fixed 'gosec' warnings
* lint: upgraded linter to 1.30.0
* lint: more 'exhaustive' warnings

Co-authored-by: Nick <nick@kasten.io>
2020-08-12 19:28:53 -07:00
Jarek Kowalski
9b68a631e6 Highlight snapshot errors in the UI and CLI (#376)
* upload: exposed numFailed and failedEntries on directory summary

* cli: better present snapshot errors

* htmlui: display snapshot errors
2020-03-22 14:18:47 -07:00
Jarek Kowalski
de71f0f057 fs: added functions Update() and Remove() on fs.Entries which return a copy of entries with specified entry updated or removed 2020-01-05 09:13:41 -08:00
Jarek Kowalski
503fa74be5 fs: added Directory.Child() method to look up children by name without necessarily loading all of them 2019-12-30 19:21:17 -08:00
Jarek Kowalski
242d012a54 removed fs.EntryMetadata and replaced fs.Entry with os.FileInfo + small additions 2018-11-03 11:28:06 -07:00
Jarek Kowalski
5d73d18347 removed Parent from fs.Entry 2018-08-19 11:32:17 -10:00
Jarek Kowalski
e36d02c59b emit per-dir incomplete reason
store entire rootEntry on snapshot nmanifest
format 'snapshot list' consistently for both root and nested items
2018-05-19 22:00:14 -07:00
Jarek Kowalski
d8201229d8 plumbed through ctx in storage.Storage APIs and all uses 2018-04-03 17:39:54 -07:00
Jarek Kowalski
e01fcff9a4 fixed sorting of synthetic fs.Entries 2017-08-27 14:49:15 -07:00
Jarek Kowalski
2b887b0b2e changed fs.Reader to be a Seeker too 2017-08-27 08:58:59 -07:00
Jarek Kowalski
50370ae96a cleaned up fs/ contents - extracted fs/localfs/ and fs/loggingfs/ moved repofs/ to fs/repofs/ 2016-08-27 11:26:16 -07:00
Jarek Kowalski
940e63832d Moved ObjectID and BundledChildren out of EntryMetadata and into repofs.dirEntry.
Fixed metadata hashing of bundles.
2016-08-27 10:45:45 -07:00
Jarek Kowalski
cded7ba49b renamed fs.EntryMetadataReadCloser as fs.Reader 2016-08-26 21:31:51 -07:00
Jarek Kowalski
38fc47e2f1 Continuing the API cleanup, Created internal/dirstream, internal/mockfs, repo/repofs and upload packages. 2016-08-26 21:26:35 -07:00
Jarek Kowalski
f70c69c9d9 several bugfixes, added tests for ObjectID UIString round-tripping 2016-08-22 21:03:06 -07:00
Jarek Kowalski
16b6b2d8bd godoc updates, API cleanup 2016-08-21 12:26:49 -07:00
Jarek Kowalski
d0fbbbb12e bundle tweaks 2016-08-21 11:20:14 -07:00
Jarek Kowalski
28baa0bf19 entry JSON format tweaks 2016-08-21 10:38:39 -07:00
Jarek Kowalski
0c6ba27eaa doc and API cleanup 2016-08-21 09:28:52 -07:00
Jarek Kowalski
91d4346f67 replaced generated protobuf code with hand-written, switched back to JSON serialization, but preserving protobuf code structure.
The generated code leaked unclean concepts to public API.
2016-08-21 00:21:40 -07:00
Jarek Kowalski
e528b32748 Major refactoring of data formats to use protobuf instead of JSON. This is a breaking change to data formats, but hoping to stabilize soon.
This change removes lots of pointless string and custom format parsing code and instead relies on protobuf to do the thing. JSON is still an option thanks to proto3-generated output.

- Refactored ObjectID to use protobuf
- Indirect blocks to use protobuf (in the form of seek table)
- Added generic proto stream reader and writer
- ObjectIDFormat became proto enum

Also:

- fixed major issue where indirect object ID entries were not encrypted, since they were storing block IDs and not object IDs.
- dropped support for majority of formats, only supporting HMAC-{SHA256,SHA512,SHA512_384} hashes with AES256.
This produces object IDs of 32 or 64 characters long.
- changed how pretty-printing works for 'kopia show'
2016-08-20 16:59:10 -07:00
Jarek Kowalski
e3dc066c58 Moved EntryMetadataReadCloser to entry.go 2016-08-03 20:55:28 -07:00
Jarek Kowalski
342eab2db8 Major refactoring of 'fs' package.
fs.Entry - represents filesystem entry
fs.Directory - is a directory entry
fs.Symlink - is a symlink entry
fs.File - is an entry representing a file

This simplifies a bunch of code. Still work in progress.
2016-07-24 10:40:44 -07:00
Jarek Kowalski
8e96665ffe renamed cas to repo, general cleanup 2016-05-10 06:50:08 -07:00
Jarek Kowalski
90691c9e24 cleanup 2016-04-14 22:39:20 -07:00
Jarek Kowalski
aa3a8ae45d upload, hashcache and testing 2016-04-14 22:30:48 -07:00
Jarek Kowalski
1fc51b49b4 separated hash cache 2016-04-14 20:48:01 -07:00
Jarek Kowalski
72f28ed2b2 hash cache w.i.p. 2016-04-11 20:17:12 -07:00
Jarek Kowalski
8e62820f74 changed Entry to be a struct 2016-04-09 22:36:26 -07:00
Jarek Kowalski
e8afaaa02f refactored Entry to use FileInfo 2016-04-05 19:42:21 -07:00
Jarek Kowalski
db57e19451 doc fix 2016-04-03 11:32:14 -07:00
Jarek Kowalski
417a34e584 renames 2016-04-01 19:26:06 -07:00
Jarek Kowalski
778359e8c4 renamed dir to fs 2016-04-01 19:11:39 -07:00