Commit Graph

97 Commits

Author SHA1 Message Date
Paulo Saraiva 6de6cc6c75 Show progress for restic stats (#5705)
Co-authored-by: Paulo Saraiva <paulo.saraiva@cern.ch>
2026-05-15 20:31:20 +02:00
Michael Eischer 4c94678d7d fix linter and compilation issues 2026-05-10 17:53:29 +02:00
Michael Eischer 6566f786e9 stats: also print snapshot size statistics in debug mode (#5712) 2026-02-18 21:21:40 +01:00
Michael Eischer 46ebee948f stats: use AssociatedBlobSet 2025-11-26 20:59:39 +01:00
Michael Eischer a816b827cf extract GlobalOptions into internal/global package
Rough steps:
```
mv cmd/restic/global* cmd/restic/secondary_repo* internal/global/
sed -i "s/package main/package global/" internal/global/*.go
Rename "GlobalOptions" to "Options" in internal/global/
Replace everywhere " GlobalOptions" -> " global.Options"
Replace everywhere "\*GlobalOptions" -> " *global.Options"
Make SecondaryRepoOptions public
Make create public
Make version public
```
2025-10-12 17:56:28 +02:00
Michael Eischer 2c677d8db4 global: make private fields public 2025-10-12 17:56:28 +02:00
Srigovind Nayak 22f254c9ca feat: allow override env RESTIC_HOST with flag to filter all snapshots (#5541) 2025-10-05 13:22:50 +02:00
Michael Eischer 56ac8360c7 data: split node and snapshot code from restic package 2025-10-03 19:10:39 +02:00
Michael Eischer 52eb66929f repository: deduplicate index progress bar initializaton 2025-10-03 18:55:46 +02:00
Michael Eischer 76b2cdd4fb replace globalOptions.stdout with termstatus.OutputWriter 2025-10-03 18:55:46 +02:00
Michael Eischer e753941ad3 move NewProgressPrinter to ui package 2025-10-03 18:55:46 +02:00
Michael Eischer 3410808dcf deduplicate termstatus setup 2025-10-03 18:55:46 +02:00
Michael Eischer 6bd85d2412 reduce usages of globalOptions variable 2025-10-03 18:22:42 +02:00
Michael Eischer 6b5c8ce14e change run* functions to accept ui.Terminal instead of *termstatus.Terminal 2025-09-15 22:37:25 +02:00
Michael Eischer c14cf48776 further reduce Warnf usages 2025-09-15 22:35:16 +02:00
Michael Eischer 109a211fbe convert repository locking to use termstatus 2025-09-15 22:34:59 +02:00
Michael Eischer 8510f09225 stats: convert to termstatus 2025-09-15 22:17:26 +02:00
Martin Smith 092899df8b Remove unnecessary type conversions. 2025-03-22 18:20:30 +00:00
Michael Eischer 412d6d9ec5 Create root command via function 2025-02-07 21:29:33 +01:00
Michael Eischer aacd6a47e3 refactor to use constructor functions to create cobra commands
This allows getting rid of the global options variables
2025-02-07 18:56:45 +01:00
Michael Eischer dc9b6378f3 move cli flags into AddFlags on option structs 2025-02-06 22:10:41 +01:00
Michael Eischer ca1e5e10b6 add proper constants for node type 2024-08-31 18:20:01 +02:00
Michael Eischer 5988d825b7 group commands and make features/options visible 2024-08-23 23:48:45 +02:00
Michael Terry 56f28c9bd5 main: return an exit code (12) for "bad password" errors 2024-08-15 16:55:45 -04:00
Michael Eischer 0b19f6cf5a Switch back to sha256 from the std library
The std library now also supports the sha assembly instructions on
ARM64. Thus, sha256-simd no longer provides a performance benefit.
2024-08-10 19:16:10 +02:00
Michael Eischer 7448a15f72 stats: add --mode completions 2024-07-28 12:21:42 +02:00
Michael Eischer 94fdca08c4 return exit code 10 if repository does not exist 2024-07-10 21:46:26 +02:00
Michael Eischer d76a78aa99 return exit code 11 if the repository could not be locked 2024-07-10 21:37:32 +02:00
Michael Eischer 3b7228c8c1 explicitly document exit code 1 on error 2024-07-10 21:35:46 +02:00
Michael Eischer 864995271e repository: unwrap BlobHandle parameters of LookupBlob
The method now uses the same parameters as LookupBlobSize.
2024-05-24 21:33:17 +02:00
Michael Eischer 1266a4932f repository: fix parameter order of LookupBlobSize
All methods should use blobType followed by ID.
2024-05-24 21:33:17 +02:00
Michael Eischer 4df887406f repository: inline MasterIndex interface into Repository interface 2024-05-24 21:33:17 +02:00
Michael Eischer 940a3159b5 let index.Each() and pack.Size() return error on canceled context
This forces a caller to actually check that the function did complete.
2024-04-22 22:39:32 +02:00
Michael Eischer 31624aeffd Improve command shutdown on context cancellation 2024-04-22 22:31:38 +02:00
will-ca 6aced61c72 Tiny docs wording clarification. 2024-04-18 07:29:55 +00:00
Michael Eischer 118a69a84b lock: replace lockRepo(Exclusive) with openWith(Read/Write/Exclusive)Lock
The new functions much better convey the intent behind the lock
request. This allows cleanly integrating noLock (for read) and dryRun
(write/exclusive) handling.

There are only minor changes to existing behavior with two exceptions:
- `tag` no longer accepts the `--no-lock` flag. As it replaces files in
  the repository, this always requires an exclusive lock.
- `debug examine` now returns an error if both `--extract-pack` and
  `--no-lock` are given.
2024-03-28 22:46:33 +01:00
Michael Eischer cf81f8ced6 stats: only check for hardlinks for files with more than one link 2024-03-28 21:29:27 +01:00
Alexander Neumann c0514dd8ba Fix linter errors (except for tests) 2024-02-10 22:58:10 +01:00
Michael Eischer e44e4b00a6 Merge pull request #4550 from ndecker/ls-ncdu
Ls ncdu
2024-01-27 12:27:35 +00:00
Michael Eischer 9ecbda059c walker: add callback to inform about leaving a directory 2024-01-27 13:17:32 +01:00
Michael Eischer bfb56b78e1 replace some usages of restic.Repository with more specific interface
This should eventually make it easier to test the code.
2024-01-27 13:02:02 +01:00
Michael Eischer 0b39940fdb walker: Remove ignoreTrees functionality
It was only used in two places:
- stats: apparently as a minor performance optimization, which is
  unlikely to be important
- find: filtered directories would be ignored. However, this
  optimization missed that it is possible that two directories have the
  exact same content. Such directories would be incorrectly ignored too.
  Example:
```
mkdir test test/a test/b
restic backup test
restic find latest test/b
-> incorrectly does not return anything
```

Thus, remove the functionality as it's apparently too complex to use
correctly.
2024-01-19 21:16:06 +01:00
Michael Eischer 731b3a4357 stats: fix hardlink tracking in a snapshot
inodes are only unique within a device. Use the HardlinkIndex from the
restorer instead of the custom (broken) hashmap to correctly account for
both inode and deviceID.
2023-10-27 23:40:42 +02:00
Michael Eischer c7b770eb1f convert MemorizeList to be repository based
Ideally, code that uses a repository shouldn't directly interact with
the underlying backend. Thus, move MemorizeList one layer up.
2023-10-25 23:01:35 +02:00
Michael Eischer b0da0f152f deduplicate index progress bar setup 2023-10-01 19:53:26 +02:00
Michael Eischer 75f6bd89ed hide index loading progress for JSON output 2023-10-01 19:53:26 +02:00
arjunajesh ed65a7dbca implement progress bar for index loading 2023-10-01 19:52:59 +02:00
Michael Eischer 325fa916b5 stats: Add debug mode to collect repository statistics 2023-07-08 23:04:47 +02:00
Michael Eischer a466e945d9 stats: pass StatsOptions via parameter 2023-05-18 21:17:53 +02:00
jo ea59896bd6 Add a global option --retry-lock
Fixes restic#719

If the option is passed, restic will wait the specified duration of time
and retry locking the repo every 10 seconds (or more often if the total
timeout is relatively small).

- Play nice with json output
- Reduce wait time in lock tests
- Rework timeout last attempt
- Reduce test wait time to 0.1s
- Use exponential back off for the retry lock
- Don't pass gopts to lockRepo functions
- Use global variable for retry sleep setup
- Exit retry lock on cancel
- Better wording for flag help
- Reorder debug statement
- Refactor tests
- Lower max sleep time to 1m
- Test that we cancel/timeout in time
- Use non blocking sleep function
- Refactor into minDuration func

Co-authored-by: Julian Brost <julian@0x4a42.net>
2023-04-07 16:24:14 +02:00