Commit Graph

772 Commits

Author SHA1 Message Date
J
c735e6089d rename AZURE_CLIENT_CERTIFICATE environment variable 2025-07-16 20:44:24 -07:00
J
e75e84be7e refactor(providers): rename Options.ClientCertificate for clarity 2025-07-16 20:38:17 -07:00
Julio Lopez
b6ad91dcd3 refactor(general): rename variable to humanReadable for consistency (#4709) 2025-07-01 20:42:10 -07:00
Kian Kasad
f40fe88254 feat(cli): human-readable sizes for kopia ls (#4696) 2025-07-01 18:46:26 -07:00
Nick
ed304e6c12 feat(snapshots): Add periodic JSON progress output to snapshot verify (#4645)
- Add read stats to snapshot verifier output
- Add periodic JSON progress output.
- Refactor the use of directory summary.
- Use stats mutex for all stats.
- Add processedBytes to the snapshot verify output
- Output more frequently, when bytes processed changes
2025-06-24 15:15:59 -07:00
Nick
b2b051417f Add JSON output flag for snapshot verify (#4644) 2025-06-24 13:20:09 -07:00
Nathan Baulch
19d92613a6 chore(general): typos (#4659) 2025-06-10 17:24:14 -07:00
Kian Kasad
e5e64e936e fix(cli): fix path printed by "kopia snapshot fix" commands (#4638)
The `dirRelativePath` variable is actually the path to the file being
checked, but was treated as if it was the path to the parent directory,
causing the filename to be duplicated in log messages.
2025-06-04 22:15:53 -07:00
Julio Lopez
d91a5a8f94 chore(general): enable forcetypeassert linter (#4624)
- enable `forcetypeassert` linter in non-test files
- add `//nolint` annotations
- add `testutil.EnsureType` helper for type assertions
- enable `forcetypeassert` linter in test files
2025-05-31 23:17:38 -07:00
Julio Lopez
ab1f62e3ad refactor(general): misc cleanups (#4615)
- nit: rename var to packCountByPrefix
- leverage impossible package
- use maps.Clone
- unexport indirectObjectID
- unexport compressed
- rename function to flushBufferLocked
- add checklocks annotations to functions that must be called under w.mu
2025-05-29 08:26:55 -07:00
Julio Lopez
3d4c5f8f9e refactor(general): s/interface{}/any/ (#4614) 2025-05-29 06:07:49 +00:00
Jarek Kowalski
1ee24977ce fix(notifications): fixed notification severities on snapshot creation (#4604) 2025-05-25 16:25:35 -07:00
Donatas Abraitis
67d8399127 fix(cli): Fix crash when doing kopia policy show <path> (#4560)
```
~# ./kopia policy show /home/donatas/tests
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x18b7b84]

goroutine 1 [running]:
github.com/kopia/kopia/cli.appendOSSnapshotPolicyRows({0xc005759008, 0x26, 0x55}, 0xc005754600?, 0xc005764008)
	/home/donatas/projects/kopia/cli/command_policy_show.go:490 +0x44
github.com/kopia/kopia/cli.printPolicy(0xc0000f5d48, 0xc005754600, 0xc005764008)
	/home/donatas/projects/kopia/cli/command_policy_show.go:135 +0x5e5
github.com/kopia/kopia/cli.(*commandPolicyShow).run(0xc0000f5d10, {0x2311ef8, 0xc0002e5320}, {0x7fb83829f3d0, 0xc0052eeb00})
	/home/donatas/projects/kopia/cli/command_policy_show.go:46 +0x18d
github.com/kopia/kopia/cli.(*App).repositoryReaderAction.func1({0x2311ef8?, 0xc0002e5320?}, {0x7fb83829f3d0?, 0xc0052eeb00?})
	/home/donatas/projects/kopia/cli/app.go:477 +0x2b
github.com/kopia/kopia/cli.(*App).repositoryReaderAction.(*App).maybeRepositoryAction.func2({0x2311ef8, 0xc0002e5320})
	/home/donatas/projects/kopia/cli/app.go:571 +0xbd
github.com/kopia/kopia/cli.(*App).repositoryReaderAction.(*App).maybeRepositoryAction.(*App).baseActionWithContext.func3.1.1()
	/home/donatas/projects/kopia/cli/app.go:554 +0x6e
github.com/kopia/kopia/cli.(*profileFlags).withProfiling(0x0?, 0xc0004a09c0?)
	/home/donatas/projects/kopia/cli/profile.go:45 +0x2b9
github.com/kopia/kopia/cli.(*App).repositoryReaderAction.(*App).maybeRepositoryAction.(*App).baseActionWithContext.func3.1({0x2311ef8?, 0xc0002e5320?})
	/home/donatas/projects/kopia/cli/app.go:549 +0x50
github.com/kopia/kopia/cli.(*App).runAppWithContext.func1(0xc0000f48d0?, 0xc0000f4808, 0xc0000efd30, {0x2311ef8, 0xc0002e52f0})
	/home/donatas/projects/kopia/cli/app.go:521 +0x186
github.com/kopia/kopia/cli.(*App).runAppWithContext(0xc0000f4808, 0xc0002b88f0, 0xc0000efd30)
	/home/donatas/projects/kopia/cli/app.go:522 +0x1a9
github.com/kopia/kopia/cli.(*App).repositoryReaderAction.(*App).maybeRepositoryAction.(*App).baseActionWithContext.func3(0x22e2801?)
	/home/donatas/projects/kopia/cli/app.go:548 +0x3c
github.com/alecthomas/kingpin/v2.(*actionMixin).applyActions(...)
	/home/donatas/go/pkg/mod/github.com/alecthomas/kingpin/v2@v2.4.0/actions.go:28
github.com/alecthomas/kingpin/v2.(*Application).applyActions(0xc0001b8500?, 0xc000453050)
	/home/donatas/go/pkg/mod/github.com/alecthomas/kingpin/v2@v2.4.0/app.go:568 +0xd0
github.com/alecthomas/kingpin/v2.(*Application).execute(0xc0001b8500, 0xc000453050, {0xc0004b6d80, 0x2, 0x2})
	/home/donatas/go/pkg/mod/github.com/alecthomas/kingpin/v2@v2.4.0/app.go:398 +0x65
github.com/alecthomas/kingpin/v2.(*Application).Parse(0xc0001b8500, {0xc00014e090?, 0xc0001b8500?, 0x22e8c80?})
	/home/donatas/go/pkg/mod/github.com/alecthomas/kingpin/v2@v2.4.0/app.go:230 +0x14a
main.main()
	/home/donatas/projects/kopia/main.go:77 +0x1cc
```

This is happening if we apply this before:

```
~# ./kopia policy set --inherit=false --clear-ignore /home/donatas/tests
```

Default value for `p.OSSnapshotPolicy.VolumeShadowCopy.Enable` is nil, so it's not set
which is inherited from a global one and is 0 (never).

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-05-12 23:34:28 +00:00
Julio Lopez
5c11822d16 chore(cli): rename function to setListBlobsParallelismFromFlags (#4564) 2025-05-09 23:01:18 -07:00
Rohit-BM18
12409c7279 feat(cli): --stats-only flag for the diff command (#4557)
Adds a `--stats-only` flag to the `diff` command to reduce
output verbosity.
When `kopia diff` is invoked with the `--stats-only` flag it
only outputs the aggregate statistics of changes.
2025-05-05 20:59:52 -07:00
Julio Lopez
14bcbcb07e fix(cli): add flag for rclone's startup timeout (#4543)
- add flag for rclone startup timeout
- rename const
2025-05-01 15:37:22 -07:00
Julio Lopez
1c5c4e2568 refactor(cli): cleanup cli.repositoryAccessMode (#4541)
Remove `repositoryAccessMode.mustBeConnected`
It is always true.

Rename `repositoryAccessMode.disableMaintenance`
to `allowMaintenance`.
This explicitly conveys when maintenance is allowed
to run. It is related to accessing a repository in
'read-only' mode.
2025-05-01 15:35:11 -07:00
Julio Lopez
2d9b7f1e33 feat(providers): Azure Blob client certificate authentication (#4535)
Allow the use of a client certificate when authenticating
to an Azure Blob storage provider.

Tests included.

Credit: @DeepikaDixit

Authored-by: Deepika Dixit <DeepikaDixit@users.noreply.github.com>
2025-04-29 23:47:41 -07:00
Julio Lopez
8098f49c90 chore(ci): remove exclusion for unused ctx parameters (#4530)
Remove unused-parameter exclusion for `ctx` in revive linter.

---------

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-04-26 23:11:36 -07:00
Matthieu MOREL
8a176255c0 fix(general): enable wsl for all go files (#4524)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-04-26 13:01:20 -07:00
blenderfreaky
f12fafb516 docs(cli): clarify documentation regarding per-user and per-host (#4512)
Ref: #4341

---------
Co-authored-by: Julio Lopez <1953782+julio-lopez@users.noreply.github.com>
2025-04-23 23:37:15 -07:00
Julio López
09b88d3860 chore(general): minor cleanups and other nits (#4507)
* use uint8 for clarity
* unexport writeContentAsyncAndVerify
* fix typo in test function name
* remove commented interface functions
* use atomic.Int32
* cleanups in socket server activation test
* leverage stdlib's maps and slices packages
  replace uses of `golang.org/x/exp/maps`
* nit: leverage `maps.Values`
2025-04-16 23:25:01 -07:00
Matthieu MOREL
675e958877 chore(ci): bump golangci-lint to v2.1.2 (#4500)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-04-15 22:49:13 -07:00
Jarek Kowalski
51ef01dad5 refactor(snapshots): extracted snapshot.FindPreviousManifests() (#4453) 2025-04-13 04:08:03 +00:00
Julio López
ad33441fbc chore(cli): add details to persistent password error message (#4480)
Extends error message with a generic, OS-independent hint about
what the source of the error may be and a potential solution.

Also, modifies error message to avoid duplicate messages.

- kopia/kopia#4449
2025-03-31 21:10:21 -07:00
Julio López
8f32be2a00 fix(cli): add newline after policy export output (#4476)
- #4341
- #4020
2025-03-29 22:46:28 -07:00
Jarek Kowalski
51de24dcff refactor(snapshots): refactored uploader into separate package (#4450) 2025-03-14 15:48:31 -07:00
Rohit-BM18
9b68189d29 feat(cli): compute snapshot diff stats (#4444)
Added functionality to calculate aggregate statistics when
comparing what's changed between snapshots using kopia diff

Statistics collected during snapshot diff computation includes:

- files added/removed/modified
- dirs added/removed/modified
- files/dirs with metadata changes but same underlying content (OID)

Testing approach:

Added a test for verifying stats collected when comparing two directories with the same objectID but metadata changes across snapshots (dir mode, dir mod time, dir owner, etc), expectation is all the appropriate dir stats fields are updated.
Added another test for verifying stats collected when comparing two directories with similar file contents but the metadata for the files have changed between snapshots but content remains unchanged. Expectation is all the relevant file level stats fields are updated.
Existing tests have been updated due to stats now being printed in addition to previous output.
2025-03-07 12:41:14 +00:00
Julio López
8f632e4e1f refactor(cli): diff test (#4422)
- Use a single struct and implementation for common functionality
- set type in Mode() for directories
- nit: fix typo
2025-02-21 21:57:22 -08:00
Jarek Kowalski
e6e2870319 feat(notifications): tweak snapshot report template (#4338)
* feat(notifications): tweak snapshot report template

* test fix
2025-01-09 18:45:51 -08:00
Janne Johansson
a4d725e754 Update command_benchmark_compression.go (#4339)
make sure MB-or-GB is not separated from /s in table.
2025-01-09 17:44:24 -08:00
Jarek Kowalski
ef01650665 feat(server): emit notifications as JSON to stderr when running under KopiaUI (#4322)
* feat(server): emit notifications as JSON to stderr when running under KopiaUI

* added tests
2024-12-30 15:06:11 -08:00
Jarek Kowalski
d6b9254a4c feat(notifications): emit snapshot report notifications in the UI/server (#4323)
* feat(notifications): emit snapshot report notifications in the UI/server

* added test

* fixed data race
2024-12-30 10:59:11 -08:00
Jarek Kowalski
c1757a0c67 feat(general): misc notifications improvements (#4319)
* feat(general): various notifications improvements

* added API to test notification profiles
* added --http-header to webhook notification configuration
* refactored configuration to always apply defaults before persisting options in the repository
* added 'notification profile show --profile-name=X' command

* more tests

* more test coverage

* report notification code coverage
2024-12-29 09:50:20 -08:00
Jarek Kowalski
b60cac4860 fix(cli): fixed v0.18.0 failures using v0.17.0-generated config (#4255)
This was caused by the client using key derivation algorithm
from a config file (which did not have it when it was generated
using old version of Kopia).

Fixes #4254
2024-11-17 10:15:00 -08:00
Jarek Kowalski
9cb940334d feat(cli): added --send-snapshot-report flag to 'snapshot create' (#4252) 2024-11-16 11:51:08 -08:00
Jarek Kowalski
eb1cf64c27 chore(ci): upgraded linter to 1.62.0 (#4250) 2024-11-16 07:16:50 -08:00
Jarek Kowalski
f73887f4d6 feat(cli): improved snapshot reports (#4244) 2024-11-15 22:09:07 -08:00
Jarek Kowalski
b874bb8b9b feat(cli): send general error notifications only if the standard output is not a terminal (#4245) 2024-11-15 18:00:09 -08:00
Jarek Kowalski
afb85cbb34 feat(cli): send error notifications and snapshot reports (#4233)
* feat(cli): send error notifications and snapshot reports

Notifications will be sent to all configured notification profiles
according to their severity levels.

The following events will trigger notifications:

- Snapshot is created (CLI only, severity >= report)
- Server Maintenance error occurs (CLI, server and UI, severity >= error)
- Any other CLI error occurs (CLI only, severity >= error).

A flag `--no-error-notifications` can be used to disable error notifications.

* added template tests

* improved time formatting in templates

* plumb through notifytemplate.Options

* more testing for formatting options

* fixed default date format to RFC1123
2024-11-11 17:53:50 -08:00
Eugene Sumin
f0541ab67e feat(cli): introduce adaptive estimation mechanism (#4218)
* Add rough estimation mechanism

* Extract data size estimation scan to standalone function

* Introduce estimation type flag

* Change signature of EstimatedDataSize

* Extract estimation logic and test it

* Adjust err handling in GetVolumeSizeInfo

* Make GetVolumeSizeInfo reusable

* Fix type issue for windows platform

* Use adaptive estimation with threshold
2024-11-04 17:31:09 -08:00
Julio López
9aadd9114c fix(cli): avoid memory bloat in benchmark encryption command (#4213)
Avoid memory bloat in `benchmark encryption` and `benchmark crypto` commands

Reuse the output buffer by resetting it between iterations.

Fixes #4210
2024-10-30 09:18:12 -07:00
Julio López
0e91261c3e fix(cli): allow running quick maintenance with epoch manager (#4198)
* allow running quick maintenance with epoch manager
* run full maintenance to cleanup logs
* separate logs maintenance set params test
2024-10-28 16:04:29 -07:00
blenderfreaky
a9e178edff feat(cli): add policy import/export commands to im-/export policies from/to json (#4020)
* feat(cli): add policy export command

* feat(cli): add policy import command

* chore(cli): remove unused policyTargetFlags in commandPolicyImport

* feat(cli): allow limiting which policies to import

* docs(cli): document policy import and export commands

* feat(cli): add policy import/export commands

* fix(cli): apply suggestions

* fix(general): unintentional commit

* feat(cli: add policy export tests

* feat(cli): add policy import tests

* feat(cli): add deleteOtherPolicies option for policy import

* docs(cli): stdin/stdout in policy import/export and --delete-other-policies flag

* chore(cli): fix linter issues

* fix(cli): fix newly introduced errors

* fix(cli): fix failing windows tests

* chore(cli): more test coverage for policy import/export

* fixed windows test

---------

Co-authored-by: Jarek Kowalski <jaak@jkowalski.net>
2024-10-28 01:36:12 +00:00
Julio López
c90495d809 fix(cli): hashing benchmark repeat (#4199)
Ref:
- #4181
2024-10-25 00:18:33 -07:00
Prasad Ghangal
3bf947d746 feat(repository): Metadata compression config support for directory and indirect content (#4080)
* Configure compressor for k and x prefixed content

Adds metadata compression setting to policy
Add support to configure compressor for k and x prefixed content
Set zstd-fastest as the default compressor for metadata in the policy
Adds support to set and show metadata compression to kopia policy commands
Adds metadata compression config to dir writer

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Pass concatenate options with ConcatenateOptions struct

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Move content compression handling to caller

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Move handling manifests to manifest pkg

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Correct const in server_test

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Remove unnecessary whitespace

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Disable metadata compression for < V2 format

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

---------

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>
2024-10-23 23:28:23 -07:00
Julio López
723583552a refactor(server): handle ErrServerClosed where it occurs (#4165)
Checks whether any of the `httpServer.Serve*()` calls returns
`ErrServerClosed`.

Handles `ErrServerClosed` inside the `startServerWithOptionalTLS` function
instead of propagating it up.  This means that `startServerWithOptionalTLS`
returns a nil error when the HTTP server is closed, so the caller does not need
to check for `ErrServerClosed`

No functional changes otherwise.
2024-10-15 21:40:19 -07:00
Julio López
2ca59394c1 refactor(cli): do not run auto-maintenance after a command fails (#4168) 2024-10-14 10:17:11 -07:00
Julio López
eb2ea5dddd test(server): speedup cert key generation in server tests (#4166)
Use shorter key size to speed up cert generation in TestServerStartInsecure.

Refactor: add const for default server-control username.
2024-10-10 10:22:34 -07:00
Jarek Kowalski
c0bd372d29 feat(cli): support for defining notification profiles and templates via CLI (#4034)
* feat(cli): support for defining notification profiles via CLI

Profile management:

```
$ kopia notification profile configure email \
    --profile-name=X \
    --smtp-server=smtp.gmail.com \
    --smtp-port=587 \
    --smtp-username=X \
    --smtp-password=X \
    --mail-from=X \
    --mail-to=X \
    --format=html|txt \
    [--send-test-notification]

$ kopia notification profile configure pushover --profile-name=X \
    --user-key=X \
    --app-token=X \
    --format=html|txt \
    [--send-test-notification]

$ kopia notification profile configure webhook --profile-name=X \
    --endpooint=http://some-address:port/path \
    --method=POST|PUT \
    --format=html|txt \
    [--send-test-notification]

$ kopia notification profile test --profile-name=X

$ kopia notification profile delete --profile-name=X

$ kopia notification profile list
```

Template management:

```
$ kopia notification template show X

$ kopia notification template set X \
   --from-stdin | --from-file=X | --editor

$ kopia notification template remove X

$ kopia notification template list

```

Implements #1958

* additional refactoring for testability, various naming tweaks
2024-10-06 16:28:39 +00:00