831 Commits
Author SHA1 Message Date
Vetea edcd1171a4 fix(cli): mark snapshot verify --parallel as deprecated and no-op (#5552)
`--parallel` has had no effect on `snapshot verify` since #1921, which
merged the tree-walk and file-verification parallelism into the single
`VerifierOptions.Parallelism` field and wired it to `--file-parallelism`.
`verifyCommandParallel` has had no reader since then: the flag parses,
advertises a default of 8, and is silently discarded.

The Consistency documentation page still recommends `--parallel=10` in
four places, so users following it believe they are tuning something.

Follow the existing convention in this file for `--all-sources`: hide the
flag, label it as having no effect, and log a deprecation message when it
is passed. Dropping `Default("8")` lets the zero value distinguish an
explicit `--parallel` from an absent one, and stops the help text from
advertising a default that does nothing. The flag still parses, so
existing scripts and cron jobs keep working.

Restoring a separate tree-walk parallelism knob would be the alternative
fix, but that changes the public `snapshotfs.VerifierOptions` surface.
2026-09-10 14:07:07 -07:00
John Costa b16302dca9 fix(cli): reject negative values for --parallel flags (#5484)
The --parallel flag was declared with kingpin .IntVar on 12 commands,
which accepted negative values and led to a panic at runtime (e.g.
`snapshot migrate --parallel=-1`).

Declare the --parallel family as uint so kingpin rejects negative input
at parse time.
The uint->int conversion the callee APIs need is done through a small
helper .

Add CLI test that asserts the rejection message (a bare failure check passed
even without the fix since the commands also fail with no repository connected).
Parse via ParseFloat like kingpin's built-in int flag so the only behavior
change is rejecting negatives.
2026-09-09 20:07:17 -07:00
Aditya Raj Singh 2602713af4 fix(cli): report invalid log levels for maintenance runs (#5586)
- Fixes #4008
2026-09-09 16:30:06 -07:00
Julio López fdf0159a17 refactor(general): cleanup various nits (#5618)
- use struct field initialization idiom
- clarify error message
- directly use s.rootctx in server request processing
- refactor: use require in e2e ACL test
- inline constant definition
- modernize with `strings.Cut`
- modernize with slices.Backward
- simplify timeFormat initialization
- refactor testing: check `Scanner.Err()` in testenv
- remove spurious parenthesis
- trueStr and falseStr consts
- use inheritPolicyString
- use const in cache info
- "bytes" const in ui task counters
- use common consts in gettool
2026-09-06 15:08:49 -07:00
Julio López 9473eef9d1 build(deps-dev): upgrade golangci-lint to v2.11.4 (#5247)
Fixes for new linter warnings:
- fix: add //nolint annotations where it makes sense
- fix: remove no-longer necessary linter annotations
- fix linter: add or remove new lines
- fix linter: use Fprintf instead of WriteString
- fix: check for overflow in conversion to uint8 / byte
2026-09-03 12:12:20 -07:00
Julio López 3877e3714b refactor(cli): cleanup auto-maintenance run*Action helpers (#5482)
- remove no longer needed `repositoryAccessMode` struct
- pulls up auto-maintenance run check to the call path
  where it is actually used, after write session flushes to
  keep existing behavior
- nit: put nil check inside function
2026-07-09 09:49:35 -07:00
maximilizeandmax 6c65de1176 fix(cli): only run automatic maintenance after data-modifying operations (#5473)
* fix(cli): only run automatic maintenance after data-modifying operations

Automatic maintenance previously ran after any successful repository-writer
command, including control-only operations such as `policy set`, `acl ...` and
`user ...`. Make repositoryWriterAction skip maintenance by default and add
repositoryWriterActionWithMaintenance, used only by data-modifying commands
(snapshot create/delete/expire/migrate/fix-*/copy-move-history/pin,
manifest delete).

Fixes #3174

* fix(cli): treat snapshot pin and manifest delete as control-only

Per review, move both to repositoryWriterAction so they no longer trigger
opportunistic automatic maintenance. pin orphans no content and manifest
delete is a low-level operation not meant for direct use; any content it
orphans is reclaimed at the next scheduled maintenance.

---------

Co-authored-by: max <max@example.com>
2026-07-08 19:56:58 -07:00
Julio López 116ec249c2 chore(general): remove unused deprecated field (#5476)
- remove unused field `encryptorInfo.deprecated`
- simplify implementations and function signatures
- deprecate `--deprecated` CLI flag
2026-07-06 21:59:15 -07:00
Julio López b048b22daf refactor(general): cleanup iomem hints (#5439)
- rename package to iomem
- update comments
- unexport `directoryWithOptions`
- check for `Close()` error on test cleanup
- reword flag description
- wrap errors to facilitate troubleshooting
- update logging message
2026-06-26 22:07:01 -07:00
Julio López d886957c7d feat(snapshots): reduce kernel page-cache pressure during snapshots (#5437)
Add fadvise hints to backup read path to reduce OS cache pollution

Issue FADV_SEQUENTIAL at open and FADV_DONTNEED at close for every file read during backup. This tells the kernel to read-ahead aggressively and then reclaim pages once the file is fully consumed, reducing cache pressure from large backups without adding measurable overhead.

Uses SyscallConn().Control() instead of os.File.Fd() to avoid switching file descriptors to blocking mode, which would remove them from Go's epoll poller and stall the upload pipeline.

Incremental FADV_DONTNEED during reads was tested and removed — it adds ~15% overhead on large-file workloads by fighting the kernel's own LRU. Restore write-path cache eviction was also tested and not included.

Authored-by: Rajat Gupta rajat.gupta@veeam.com
2026-06-26 19:29:13 -07:00
Julio López 8b13419327 refactor(providers): no_extra_providers build tag (#5375) 2026-05-14 07:23:32 -07:00
c26c6a1b97 feat(cli): restrict insecure unauthenticated server to loopback binds (#5354)
* feat(cli): restrict insecure unauthenticated server to loopback binds

Reject starting the server with --insecure and --without-password when
--address would bind outside loopback (including empty host / all
interfaces). Validate the actual listener after Listen so systemd socket
activation cannot bypass the check.

Add hidden --allow-extremely-dangerous-unauthenticated-server-on-the-network
to opt into the previous behavior for isolated environments.

Extract validation into internal/insecureserverbind with table-driven tests.
Add end-to-end smoke tests for rejection and escape hatch.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Update internal/insecureserverbind/insecureserverbind.go

Co-authored-by: Julio López <1953782+julio-lopez@users.noreply.github.com>

* pr feedback

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Julio López <1953782+julio-lopez@users.noreply.github.com>
2026-05-04 19:51:20 -07:00
Julio López 6d25951811 refactor(cli): registration mechanism for storage providers (#5350) 2026-04-30 08:25:04 -07:00
Julio López eee59b0e3c chore(providers): warn messages for extra storage providers (#5324)
Add warnings for unsupported, not actively tested and not maintained providers
2026-04-19 22:30:58 -07:00
Julio López c8b8fe1c7f refactor(general): bigmapbench profiling (#5321)
- improve bigmapbench stats output
- refactor bigmapbench profiling and remove unneeded dependency
- nit: unexport const
2026-04-18 12:00:47 -07:00
Julio López d1e5c1d8a0 chore(general): clean nits (#5313)
- make benchmarking params uint
- prevent error in compression benchmarking
- lint on Windows and address linter warnings
- upgrade golang.org/x/exp
- upgrade github.com/cncf/xds/go
- upgrade github.com/dustinkirkland/golang-petname
- direct users to forum
- add warning about _recovery recipes_
2026-04-16 21:41:39 -07:00
Julio López 09542631c2 fix(cli): hash benchmarking count (#5312)
Ref:

- #4181
- #4199
2026-04-16 16:21:34 -07:00
Julio López 40e645e11c refactor(cli): leverage x/term.IsTerminal (#5308) 2026-04-13 19:17:55 -07:00
Julio López 0661f65703 chore(cli): handle potential conversion overflow when setting progress default (#5271) 2026-04-06 21:38:59 -07:00
Julio López 29d4118aac refactor(general): address potential conversion overflows (#5266)
Minor robustness improvements

- add safety check when converting file descriptor (`os.File.Fd()`) to `int`
- check that file descriptor returned by Open (on Linux) is non-negative before converting to `uintptr`. This addresses a linter warning for a most-likely-non-existent-edge-case of converting a negative file descriptor.
- check that parsed content IDs (hashes) do not exceed the maximum id hash length.
- add nolint annotation for safe conversion
2026-04-01 21:51:44 -07:00
Julio López d1bc68ef61 refactor(general): cleanup nits (#5236)
Cleanup nits:
- get error handling policy upfront and improve readability in uploader
- update error message
- update field documentation and update flag description
- remove unused function
- const `isWindows` and remove redundant condition check
- add `getEnvVarBool` helper
- refactor common helper for mockfs.AddError* functions, and
  add mockfs.AddErrorEntry<Type> wrappers for clarity.
- removed list of skipped tests from gotestsum summary
2026-03-23 11:52:29 -07:00
Preston Hunt 71e35d773f feat(snapshot): disable progress by default if no tty (#5066)
When running without a tty, disable progress by default. The progress
includes binary characters such as a spinner that do not display
properly without a tty.
2026-02-06 19:45:26 -08:00
Julio López 39fb62970f refactor(cli): refactor diagnosis flags (#5026)
Refactor `--profile-*` flags:
- Multiple profile types can be enabled at once, before only
  a single type profiling could be done during a process execution.
- The new `--profiles-store-on-exit` enables all available profile
  types, except for CPU profiling which needs to be explicitly enabled.
- Profiling parameters can now be set via new flags. This allows setting
  the profile parameters for the pprof endpoint, as well as when saving
  profiles to files on exit.
- Group profiling flags with other observability flags
- Adds a `--diagnostics-output-directory` flag that unifies and
  supersedes the `--profile-dir` and `--metrics-directory` flags

Enhancements and behavior changes:
- Profile flags now have effect for all kopia commands, including
  `server start`. Before these flags did not have any effect
  in a few commands.
- Multiple profile types can be enabled at once, before only
  a single type profiling could be done during a process execution.
- The new `--profiles-store-on-exit` enables all available profile
  types, except for CPU profiling which needs to be explicitly enabled.
- Profiling parameters can now be set via new flags. This allows setting
  the profile parameters for the pprof endpoint, as well as when saving
  profiles to files on exit.

The following flags have been removed:
- `--profile-dir`: superseded by the `--diagnostics-output-directory` flag
- `--profile-blocking`: the `--profile-store-on-exit` flag enables blocking
  profiling. Use `--profile-blocking-rate=0` to explicitly disable it.
- `--profile-memory`: the `--profile-store-on-exit` flag enables memory
  profiling. Use `--profile-memory-rate=0` to explicitly disable it.
- `--profile-mutex`: the `--profile-store-on-exit` flag enables mutex
  profiling. Use `--profile-mutex-fraction=0` to explicitly disable it.

Add CLI test for profile flags.
2025-11-26 09:40:01 -08:00
Nathan Baulch ea1bdb1541 chore(ci): enable noctx linter (#4972)
* pass context in webdav helpers
* fix typo in function name
2025-11-19 21:46:28 -08:00
Julio Lopez 7db061ee71 build(deps): Go 1.25 (#4987)
Upgrade to Go 1.25
Leverage `WaitGroup.Go` in Go 1.25
2025-11-17 16:42:12 -08:00
Julio Lopez 70f8d678d0 fix(general): handle errors closing writable descriptors (#4998) 2025-11-16 23:07:51 -08:00
Julio Lopez 070c15b888 chore(general): avoid wrapping always-nil error (#4997) 2025-11-16 22:55:35 -08:00
Julio Lopez db4b89bc3d fix(cli): potential overflow in integer conversion (#4993) 2025-11-15 22:36:45 -08:00
lyndon-li c3c971a785 feat(general): fix display errors for maintenance stats (#4984) 2025-11-13 12:27:42 -08:00
Julio Lopez bb20d9e11a chore(ci): enable wsl_v5:{assign,expr} linter settings (#4982)
Enable wsl_v5 settings:
- assign
- expr
2025-11-12 23:12:06 -08:00
Julio Lopez 80eda18f99 chore(ci): enable wsl_v5:err linter (#4928) 2025-11-12 22:15:27 -08:00
lyndon-li 157c80e5e7 feat(snapshots): Flush after restoring each file (#4825)
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
2025-11-12 20:59:56 -08:00
Nathan Baulch 657fda216a chore(ci): upgrade to golangci-lint 2.6.1 (#4973)
- upgrade to golangci-lint 2.6.1
- updates for gosec
- updates for govet
- updates for perfsprint
- updates modernize

Leaves out modernize:omitempty due to conflicts with tests
2025-11-11 21:27:10 -08:00
Julio Lopez 19af93f2b1 refactor(ci): enable wsl_v5:return linter (#4975)
Also, disable redundant nakedret linter
2025-11-11 16:53:10 -08:00
Nathan BaulchandJulio Lopez 557940c524 chore(ci): upgrade to golangci-lint v2.5.0 (#4931)
Upgrades golangci-lint to v2.5.0

Enables:
- wsl_v5

Disables:
- embeddedstructfieldcheck
- noinlineerr (not used in this codebase)
- noctx (temporarily)
- godot
- wsl (deprecated)

Co-authored-by: Julio Lopez <1953782+julio-lopez@users.noreply.github.com>
2025-11-11 12:37:07 -08:00
lyndon-li 3b7f193c29 feature(general): maintenance stats for rewrite contents phase (#4961) 2025-11-06 10:22:58 -08:00
lyndon-li 3446837bed feat(general): maintenance stats for clean up logs phase (#4959) 2025-11-05 23:23:47 -08:00
Julio Lopez c7ea2c6e09 refactor(general): consistent use "pack" where possible (#4952)
In kopia, "blob" is a generic term to refer to either
an object in an object storage provider, or a file
in a file system storage provider. There are various
types of blobs in a kopia repository.

In kopia, the term "pack" is used to refer to specific types
of blobs, namely 'p' & 'q' pack blobs, that store
"content" data, as opposed to say, "index" blobs.

This change attempts to use the term "pack" consistently
in the functions and types used for pack deletion.

Note that the corresponding task names, shown below, remain
unchanged since these names are used in the persistent
maintenance run metadata, and that is used to make decisions
about the safety of the execution of those tasks.

```
	TaskDeleteOrphanedBlobsQuick     = "quick-delete-blobs"
	TaskDeleteOrphanedBlobsFull      = "full-delete-blobs"
```
2025-11-05 22:03:21 -08:00
lyndon-li db48fad95e feat(general): maintenance stats for delete unreferenced packs phase (#4955) 2025-11-04 22:51:17 -08:00
lyndon-li 83bd4d45da feat(general): maintenance stats for drop deleted contents and compact indexes (#4948) 2025-11-04 11:40:20 -08:00
Julio Lopez 356930b1a9 refactor(general): simplify function and generics signatures (#4930) 2025-10-29 12:32:51 -07:00
Julio Lopez 995e7fd893 refactor(general): modernize (#4903)
Applies the modernize changes for the following categories:

- mapsloop
- stringsseq
- stringscutprefix
- sortslice
2025-10-23 17:11:38 -07:00
Julio Lopez b6da922e3a fix(general): address linter warnings (#4897) 2025-10-22 19:01:10 -07:00
lyndon-li 657db9706b feat(general): interfaces and structures for maintenance stats (#4890)
Maintenance is critical for healthy of the repository.

On the other hand, Maintenance is complex, because
it runs multiple sub tasks each may generate different
results according to the maintenance policy.
The results may include deleting/combining/adding
data/metadata to the repository.

It is worthy to add more observability for these
tasks for below reasons:

It is helpful for troubleshooting. Any data change
to the repository is critical, the observability info
helps to understand what happened during the
maintenance and why that happened.

It is helpful for users to understand/predict the
repo's behavior. The repo data may be stored
in a public cloud for which costs are sensitive
to scale/duration of data stored. On the other
hand, repository has its own policy to manage
the data, so the data is not deleted until it is
safe enough according to the policy.

The observability info helps users to
understand how much data is in-use,
how much data is out of use and
when it is deleted
2025-10-22 18:14:10 -07:00
yinheli 3563fdd7fd fix(cli): make --progress flag visible and use it in sync-to command (#3542) (#4877)
* fix(cli): improve progress output control in repository sync and documentation

- Update progress flag description from "progress bar" to "progress output" for clarity
- Document progress control features in Logging, Synchronization, and Command-Line reference
- Support --no-progress flag for cleaner automation and scripting usage
2025-10-14 19:28:54 -07:00
Julio Lopez 6650223291 refactor(general): cleanup observabilityFlags (#4852)
- nit: rename function to repositoryAction.
  It always calls the action with a repository
- move allocator stats functionality to observability
- rename observability functions to start/stop. They
  start and stop more than just the metrics services.
- rename field to c.enablePProfEndpoint for clarity.
- add observability run function to make it explicit
  where start and stop are called.
2025-09-28 23:59:27 -07:00
Julio Lopez a0a4a7ba18 refactor(cli): ensure auto-maintenance errors are propagated (#4851)
Ensure auto-maintenance errors are propagated.
This enables sending notifications for failed "auto-maintenances".

Preserve action callback error when closing the repository fails.
2025-09-28 23:55:15 -07:00
Jarek Kowalski 0f7253eb66 feat(general): rewrote content logs to always be JSON-based and reorganized log structure (#4822)
This is a breaking change to users who might be using Kopia as a library.

### Log Format

```json
{"t":"<timestamp-rfc-3389-microseconds>", "span:T1":"V1", "span:T2":"V2", "n":"<source>", "m":"<message>", /*parameters*/}
```

Where each record is associated with one or more spans that describe its scope:

* `"span:client": "<hash-of-username@hostname>"`
* `"span:repo": "<random>"` - random identifier of a repository connection (from `repo.Open`)
* `"span:maintenance": "<random>"` - random identifier of a maintenance session
* `"span:upload": "<hash-of-username@host:/path>"` - uniquely identifies upload session of a given directory
* `"span:checkpoint": "<random>"` - encapsulates each checkpoint operation during Upload
* `"span:server-session": "<random>"` -single client connection to the server
* `"span:flush": "<random>"` - encapsulates each Flush session
* `"span:maintenance": "<random>"` - encapsulates each maintenance operation
* `"span:loadIndex" : "<random>"` - encapsulates index loading operation
* `"span:emr" : "<random>"` - encapsulates epoch manager refresh
* `"span:writePack": "<pack-blob-ID>"` - encapsulates pack blob preparation and writing

(plus additional minor spans for various phases of the maintenance).

Notable points:

- Used internal zero allocation JSON writer for reduced memory usage.
- renamed `--disable-internal-log` to `--disable-repository-log` (controls saving blobs to repository)
- added `--disable-content-log` (controls writing of `content-log` files)
- all storage operations are also logged in a structural way and associated with the corresponding spans.
- all content IDs are logged in a truncated format (since first N bytes that are usually enough to be unique) to improve compressibility of logs (blob IDs are frequently repeated but content IDs usually appear just once).

This format should make it possible to recreate the journey of any single content throughout pack blobs, indexes and compaction events.
2025-09-27 17:11:13 -07:00
Julio Lopez 6e5c8ef4e7 chore(general): minor cleanups (#4842)
* Remove unused return value from ListIndexBlobInfos
* Unexport index.Builder.buildStable
* Remove unnecessary OneUseBuilder.BuildStable
* Remove unnecessary `BuilderCreator` interface,
  use a function type instead.
* Cleanup comment
2025-09-24 12:11:22 -07:00
Julio Lopez aaae7e8004 fix(cli): enable quick maintenance by default on repo creation (#4840)
Avoid disabling quick maintenance on repo creation when the
epoch manager is available.
2025-09-23 17:27:25 -07:00