Compare commits

...

1049 Commits

Author SHA1 Message Date
Winfried Plappert
c5e09ae9b1 docs: expand restic find - documentation (#5675) 2026-02-19 18:07:05 +00:00
Winfried Plappert
1f329cd933 docs: expand documentation about testing (#5346) 2026-02-19 18:26:15 +01:00
Johannes Truschnigg
a8f0ad5cc4 mount: check for more requisite mountpoint conditions (#5718)
* mount: check for more requisite mountpoint conditions

In order to be able to mount a repository over a mountpoint target
directory via FUSE, that target directory needs to be both writeable and
executable for the UID performing the mount.

Without this patch, `restic mount` only checks for the target pathname's
existence, which can lead to a lot of data transfer and/or computation
for large repos to be performed before eventually croaking with a fatal
"fusermount: failed to chdir to mountpoint: Permission denied" (or
similar) error.

FUSE does allow for mounting over a target path that refers to a regular
(writeable) file, but the result is not accessible via chdir(), so we
prevent that as well, and accept only directory inodes as the intended
target mountpoint path.

* Don't use snake_case identifiers

* Add changelog entry

* tweak changelog summary

---------

Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-02-19 17:11:49 +00:00
Michael Eischer
4c56384481 docs: describe assigning ambient capabilities using systemd (#5698)
---

Co-authored-by: udf2457 <udf2457@users.noreply.github.com>
2026-02-18 22:33:21 +01:00
Winfried Plappert
8b567a9270 Bugfix restic find: missing check for mtime --oldest/--newest (#5310) 2026-02-18 21:14:35 +00:00
Michael Eischer
27c560b371 Merge pull request #5650 from fabien-joubert/docs-warning-capabilities
docs: add warning for capability-based non-root backups
2026-02-18 21:44:04 +01:00
Andreas Scherbaum
66d915ef79 Add space in error message (#5704) 2026-02-18 20:27:02 +00:00
Michael Eischer
7077500a3b Have backup -vv mention compressed size of added files (#5669)
ui: mention compressed size of added files in `backup -vv`

This is already shown for modified files, but the added files message
wasn't updated when compression was implemented in restic.

Co-authored-by: Ilya Grigoriev <ilyagr@users.noreply.github.com>
2026-02-18 21:24:29 +01:00
Michael Eischer
6566f786e9 stats: also print snapshot size statistics in debug mode (#5712) 2026-02-18 21:21:40 +01:00
Michael Eischer
d1937a530b clarify pack ID in decryption error (#5710)
pack ID is included in full. In addition, the error message now says
that it is a pack file.
2026-02-18 20:43:10 +01:00
gunar
7101f11133 Fail fast for invalid RESTIC_PACK_SIZE env values (#5592)
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-02-01 15:45:31 +01:00
Michael Eischer
8bff5cead0 Merge pull request #5696 from restic/dependabot/go_modules/github.com/minio/minio-go/v7-7.0.98 2026-02-01 12:29:55 +01:00
Michael Eischer
5e43a44b15 Merge pull request #5680 from castilma/unlock-doc 2026-02-01 12:13:52 +01:00
Michael Eischer
67c13c643d Merge pull request #5691 from MichaelEischer/fix-rewriter-error 2026-02-01 12:09:52 +01:00
dependabot[bot]
b706c19614 build(deps): bump github.com/minio/minio-go/v7 from 7.0.97 to 7.0.98
Bumps [github.com/minio/minio-go/v7](https://github.com/minio/minio-go) from 7.0.97 to 7.0.98.
- [Release notes](https://github.com/minio/minio-go/releases)
- [Commits](https://github.com/minio/minio-go/compare/v7.0.97...v7.0.98)

---
updated-dependencies:
- dependency-name: github.com/minio/minio-go/v7
  dependency-version: 7.0.98
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-01 11:04:31 +00:00
Michael Eischer
da2ed89ffd Merge pull request #5697 from restic/dependabot/go_modules/github.com/klauspost/compress-1.18.3 2026-02-01 12:01:36 +01:00
Michael Eischer
cf3793bb41 Merge pull request #5695 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob-1.6.4 2026-02-01 12:00:39 +01:00
Michael Eischer
db8e379fd4 Merge pull request #5694 from restic/dependabot/go_modules/cloud.google.com/go/storage-1.59.2 2026-02-01 12:00:05 +01:00
Michael Eischer
4f73daa761 Merge pull request #5693 from restic/dependabot/go_modules/golang-x-deps-173d0ad829 2026-02-01 11:59:31 +01:00
Michael Eischer
48cfa908ed Merge pull request #5692 from restic/dependabot/github_actions/docker/login-action-3.7.0 2026-02-01 11:56:38 +01:00
Michael Eischer
d3c225627f Merge pull request #5682 from wplapper/docs_list 2026-02-01 11:55:37 +01:00
Michael Eischer
07d380d54b Merge pull request #5191 from wplapper/cmd_rewrite_include 2026-02-01 11:53:05 +01:00
Winfried Plappert
b544e71cac restic list doc - documenmtation
fixed wording for paragraph and inconsistent underlining
2026-02-01 06:12:56 +00:00
Winfried Plappert
099650f883 docs: restic list
corrected typo
2026-02-01 06:02:39 +00:00
Winfried Plappert
6154685c3a docs: add documentation for restic list
added a file doc/view_repository.rst which contains the
description of `restic list ...`
2026-02-01 06:02:39 +00:00
dependabot[bot]
66bb196591 build(deps): bump github.com/klauspost/compress from 1.18.2 to 1.18.3
Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.18.2 to 1.18.3.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Commits](https://github.com/klauspost/compress/compare/v1.18.2...v1.18.3)

---
updated-dependencies:
- dependency-name: github.com/klauspost/compress
  dependency-version: 1.18.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-01 01:43:15 +00:00
dependabot[bot]
2be17d2313 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
Bumps [github.com/Azure/azure-sdk-for-go/sdk/storage/azblob](https://github.com/Azure/azure-sdk-for-go) from 1.6.3 to 1.6.4.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/storage/azblob/v1.6.3...sdk/storage/azblob/v1.6.4)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
  dependency-version: 1.6.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-01 01:42:57 +00:00
dependabot[bot]
34ba097162 build(deps): bump cloud.google.com/go/storage from 1.58.0 to 1.59.2
Bumps [cloud.google.com/go/storage](https://github.com/googleapis/google-cloud-go) from 1.58.0 to 1.59.2.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/spanner/v1.58.0...storage/v1.59.2)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/storage
  dependency-version: 1.59.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-01 01:42:48 +00:00
dependabot[bot]
38f1fb61f3 build(deps): bump the golang-x-deps group with 5 updates
Bumps the golang-x-deps group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [golang.org/x/crypto](https://github.com/golang/crypto) | `0.46.0` | `0.47.0` |
| [golang.org/x/net](https://github.com/golang/net) | `0.48.0` | `0.49.0` |
| [golang.org/x/sys](https://github.com/golang/sys) | `0.39.0` | `0.40.0` |
| [golang.org/x/term](https://github.com/golang/term) | `0.38.0` | `0.39.0` |
| [golang.org/x/text](https://github.com/golang/text) | `0.32.0` | `0.33.0` |


Updates `golang.org/x/crypto` from 0.46.0 to 0.47.0
- [Commits](https://github.com/golang/crypto/compare/v0.46.0...v0.47.0)

Updates `golang.org/x/net` from 0.48.0 to 0.49.0
- [Commits](https://github.com/golang/net/compare/v0.48.0...v0.49.0)

Updates `golang.org/x/sys` from 0.39.0 to 0.40.0
- [Commits](https://github.com/golang/sys/compare/v0.39.0...v0.40.0)

Updates `golang.org/x/term` from 0.38.0 to 0.39.0
- [Commits](https://github.com/golang/term/compare/v0.38.0...v0.39.0)

Updates `golang.org/x/text` from 0.32.0 to 0.33.0
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.32.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.47.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/net
  dependency-version: 0.49.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/sys
  dependency-version: 0.40.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/term
  dependency-version: 0.39.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/text
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-01 01:42:37 +00:00
dependabot[bot]
827c7bcae8 build(deps): bump docker/login-action from 3.6.0 to 3.7.0
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.6.0 to 3.7.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](5e57cd1181...c94ce9fb46)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 3.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-01 01:42:36 +00:00
Winfried Plappert
bcd4168428 Enhancement: calls to SnapshotFilter.FindLatest() can be simplified (#5688) 2026-01-31 23:04:01 +01:00
Michael Eischer
901235efc9 rewrite: skip snapshot parts not matchable by include patterns 2026-01-31 22:42:02 +01:00
Michael Eischer
ef1d525f22 rewriter: return correct error if tree iteration fails 2026-01-31 22:07:07 +01:00
Michael Eischer
74d60ad223 rewriter: test KeepEmptyDirectory option 2026-01-31 22:01:23 +01:00
Michael Eischer
0d71f70a22 minor cleanups and typos 2026-01-31 22:01:23 +01:00
Winfried Plappert
ee154ce0ab restic rewrite --include
added function Count() to the *TreeWriter methods
2026-01-31 19:58:29 +00:00
Winfried Plappert
b6af01bb28 restic rewrite integration test
convert exclusive lock on repository to 'no-lock'
2026-01-31 19:43:03 +00:00
Winfried Plappert
5148608c39 restic rewrite include - based on restic 0.18.1
cmd/restic/cmd_rewrite.go:
introduction of include filters for this command:
- add include filters, add error checking code
- add new parameter 'keepEmptyDirectoryFunc' to 'walker.NewSnapshotSizeRewriter()',
  so empty directories have to be kept to keep the directory structure intact
- add parameter 'keepEmptySnapshot' to 'filterAndReplaceSnapshot()' to keep snapshots
  intact when nothing is to be included
- introduce helper function 'gatherIncludeFilters()' and 'gatherExcludeFilters()' to
  keep code flow clean

cmd/restic/cmd_rewrite_integration_test.go:
add several new tests around the 'include' functionality

internal/filter/include.go:
this is where is include filter is defined

internal/walker/rewriter.go:
- struct RewriteOpts gains field 'KeepEmtpyDirectory', which is a 'NodeKeepEmptyDirectoryFunc()'
  which defaults to nil, so that al subdirectories are kept
- function 'NewSnapshotSizeRewriter()' gains the parameter 'keepEmptyDirecoryFilter' which
  controls the management of empty subdirectories in case of include filters active

internal/data/tree.go:
gains a function Count() for checking the number if node elements in a newly built tree

internal/walker/rewriter_test.go:
function 'NewSnapshotSizeRewriter()' gets an additional parameter nil to keeps things happy

cmd/restic/cmd_repair_snapshots.go:
function 'filterAndReplaceSnapshot()' gets an additional parameter 'keepEmptySnapshot=nil'

doc/045_working_with_repos.rst:
gets to mention include filters

changelog/unreleased/issue-4278:
the usual announcement file

git rebase master -i produced this

restic rewrite include - keep linter happy

cmd/restic/cmd_rewrite_integration_test.go:
linter likes strings.Contain() better than my strings.Index() >= 0
2026-01-31 19:42:56 +00:00
Michael Eischer
083cdf0675 Merge pull request #5613 from MichaelEischer/tree-node-iterator 2026-01-31 20:10:57 +01:00
Michael Eischer
ce7c144aac data: add support for unknown keys to treeIterator
While not planned, it's also not completely impossible that a tree node
might get additional top-level fields. As the tree iterator is built
with a strict expectation of the top-level fields, this would result in
a parsing error. Future-proof the code by simply skipping unknown
fields.
2026-01-31 20:03:38 +01:00
Michael Eischer
81948937ca data: test DualTreeIterator 2026-01-31 20:03:38 +01:00
Michael Eischer
fa8889eec4 data: test LoadTree+SaveTree cycle 2026-01-31 20:03:38 +01:00
Michael Eischer
6de64911fb data: test TreeFinder 2026-01-31 20:03:38 +01:00
Michael Eischer
17688c2313 data: move TestTreeMap to data package to allow reuse 2026-01-31 20:03:38 +01:00
Michael Eischer
e1a5550a27 test: use generics in Equal function signature
This simplifies comparing a typed value against nil. Previously it was
necessary to case nil into the proper type.
2026-01-31 20:03:38 +01:00
Michael Eischer
24d56fe2a6 diff: switch to efficient DualTreeIterator
The previous implementation stored the whole tree in a map and used it
for checking overlap between trees. This is now replaced with the
DualTreeIterator, which iterates over two trees in parallel and returns
the merge stream in order. In case of overlap between both trees, it
returns both nodes at the same time. Otherwise, only a single node is
returned.
2026-01-31 20:03:38 +01:00
Michael Eischer
350f29d921 data: replace Tree with TreeNodeIterator
The TreeNodeIterator decodes nodes while iterating over a tree blob.
This should reduce peak memory usage as now only the serialized tree
blob and a single node have to alive at the same time. Using the
iterator has implications for the error handling however. Now it is
necessary that all loops that iterate through a tree check for errors
before using the node returned by the iterator.

The other change is that it is no longer possible to iterate over a tree
multiple times. Instead it must be loaded a second time. This only
affects the tree rewriting code.
2026-01-31 20:03:38 +01:00
Michael Eischer
1e183509d4 data: rework StreamTrees to use synchronous callbacks
The tree.Nodes will be replaced by an iterator to loads and serializes
tree node ondemand. Thus, the processing moves from StreamTrees into the
callback. Schedule them onto the workers used by StreamTrees for proper
load distribution.
2026-01-31 20:03:38 +01:00
Michael Eischer
25a5aa3520 dump: fix missing error handling if tree cannot be read 2026-01-31 19:18:36 +01:00
Michael Eischer
278e457e1f data: use data.TreeWriter to serialize&write data.Tree
Always serialize trees via TreeJSONBuilder. Add a wrapper called
TreeWriter which combines serialization and saving the tree blob in the
repository. In the future, TreeJSONBuilder will have to upload tree
chunks while the tree is still serialized. This will a wrapper like
TreeWriter, so add it right now already.

The archiver.treeSaver still directly uses the TreeJSONBuilder as it
requires special handling.
2026-01-31 19:18:36 +01:00
Michael Eischer
f84d398989 repository: prevent test deadlock within WithBlobUploader
Calling t.Fatal internally triggers runtime.Goexit . This kills the
current goroutine while only running deferred code. Add an extra context
that gets canceled if the go routine exits while within the user
provided callback.
2026-01-31 19:18:36 +01:00
Michael Eischer
d82ea53735 data: fix invalid trees used in test cases
data.TestCreateSnapshot which is used in particular by TestFindUsedBlobs
and TestFindUsedBlobs could generate trees with duplicate file names.
This is invalid and going forward will result in an error.
2026-01-31 19:18:36 +01:00
Michael Eischer
34fdf5ba96 Merge pull request #5636 from MichaelEischer/clarify-parameter-docs 2026-01-31 19:15:24 +01:00
Michael Eischer
70591f00ed Merge pull request #5690 from restic/backend-no-restic-imports 2026-01-31 19:13:07 +01:00
Michael Eischer
4bc6bb7e27 slightly reduce redundant wording 2026-01-31 19:07:06 +01:00
Michael Eischer
2628daba97 CI: prevent backends from importing internal/restic package 2026-01-31 12:00:04 +01:00
Martin Castillo
2269ec82e1 man: add note about append-only mode to restic-unlock.1
Since restic unlock _removes_ locks, a user might wonder
whether this works in append-only mode, which prevents deletion of
data.  This change explicitly mentions in the man page that the deletion
of locks is an allowed exception.
2026-01-27 12:07:47 +01:00
Winfried Plappert
86ccc6d445 Bugfix: restic check: add missing finalizeSnapshotFilter() (#5644)
add missing finalizeSnapshotFilter() to cmd.RunE()

---------

Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-01-26 21:08:15 +00:00
Michael Eischer
d0a5d0e2f7 Merge pull request #5657 from restic/dependabot/go_modules/github.com/spf13/cobra-1.10.2
build(deps): bump github.com/spf13/cobra from 1.10.1 to 1.10.2
2026-01-26 21:52:26 +01:00
Michael Eischer
fa13f1895f Merge pull request #5658 from restic/dependabot/go_modules/github.com/elithrar/simple-scrypt-1.4.0
build(deps): bump github.com/elithrar/simple-scrypt from 1.3.0 to 1.4.0
2026-01-26 21:48:28 +01:00
Michael Eischer
880b08f9ec Merge pull request #5627 from MichaelEischer/faster-files-writer
restore: tune fileswriter
2026-01-26 21:45:49 +01:00
dependabot[bot]
1368db5777 build(deps): bump github.com/spf13/cobra from 1.10.1 to 1.10.2
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.10.1 to 1.10.2.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.10.1...v1.10.2)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-version: 1.10.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-26 20:40:43 +00:00
Michael Eischer
f78e3f369d Merge pull request #5637 from MichaelEischer/docs-table-width
docs: fix table width
2026-01-26 21:38:34 +01:00
Michael Eischer
39271a9984 Merge pull request #5656 from restic/dependabot/go_modules/cloud.google.com/go/storage-1.58.0
build(deps): bump cloud.google.com/go/storage from 1.57.2 to 1.58.0
2026-01-26 21:37:24 +01:00
Michael Eischer
2c1e8a0412 Merge pull request #5655 from restic/dependabot/go_modules/github.com/klauspost/compress-1.18.2
build(deps): bump github.com/klauspost/compress from 1.18.1 to 1.18.2
2026-01-26 21:36:53 +01:00
Michael Eischer
155372404a Merge pull request #5654 from restic/dependabot/go_modules/golang-x-deps-f1409dc592
build(deps): bump the golang-x-deps group with 7 updates
2026-01-26 21:36:18 +01:00
Ilya Grigoriev
79c37f3d1a ui: mention compressed size of added files in backup -vv
This is already shown for modified files, but the added files message
wasn't updated when compression was implemented in restic.
2026-01-15 18:39:16 -08:00
dependabot[bot]
80531dbe53 build(deps): bump github.com/elithrar/simple-scrypt from 1.3.0 to 1.4.0
Bumps [github.com/elithrar/simple-scrypt](https://github.com/elithrar/simple-scrypt) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/elithrar/simple-scrypt/releases)
- [Commits](https://github.com/elithrar/simple-scrypt/compare/v1.3.0...v1.4.0)

---
updated-dependencies:
- dependency-name: github.com/elithrar/simple-scrypt
  dependency-version: 1.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-01 01:02:15 +00:00
dependabot[bot]
40fe9f34e7 build(deps): bump cloud.google.com/go/storage from 1.57.2 to 1.58.0
Bumps [cloud.google.com/go/storage](https://github.com/googleapis/google-cloud-go) from 1.57.2 to 1.58.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/storage/v1.57.2...spanner/v1.58.0)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/storage
  dependency-version: 1.58.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-01 01:02:06 +00:00
dependabot[bot]
4d0ec87f35 build(deps): bump github.com/klauspost/compress from 1.18.1 to 1.18.2
Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.18.1 to 1.18.2.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Commits](https://github.com/klauspost/compress/compare/v1.18.1...v1.18.2)

---
updated-dependencies:
- dependency-name: github.com/klauspost/compress
  dependency-version: 1.18.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-01 01:01:51 +00:00
dependabot[bot]
d6f376b6c8 build(deps): bump the golang-x-deps group with 7 updates
Bumps the golang-x-deps group with 7 updates:

| Package | From | To |
| --- | --- | --- |
| [golang.org/x/crypto](https://github.com/golang/crypto) | `0.45.0` | `0.46.0` |
| [golang.org/x/net](https://github.com/golang/net) | `0.47.0` | `0.48.0` |
| [golang.org/x/oauth2](https://github.com/golang/oauth2) | `0.33.0` | `0.34.0` |
| [golang.org/x/sync](https://github.com/golang/sync) | `0.18.0` | `0.19.0` |
| [golang.org/x/sys](https://github.com/golang/sys) | `0.38.0` | `0.39.0` |
| [golang.org/x/term](https://github.com/golang/term) | `0.37.0` | `0.38.0` |
| [golang.org/x/text](https://github.com/golang/text) | `0.31.0` | `0.32.0` |


Updates `golang.org/x/crypto` from 0.45.0 to 0.46.0
- [Commits](https://github.com/golang/crypto/compare/v0.45.0...v0.46.0)

Updates `golang.org/x/net` from 0.47.0 to 0.48.0
- [Commits](https://github.com/golang/net/compare/v0.47.0...v0.48.0)

Updates `golang.org/x/oauth2` from 0.33.0 to 0.34.0
- [Commits](https://github.com/golang/oauth2/compare/v0.33.0...v0.34.0)

Updates `golang.org/x/sync` from 0.18.0 to 0.19.0
- [Commits](https://github.com/golang/sync/compare/v0.18.0...v0.19.0)

Updates `golang.org/x/sys` from 0.38.0 to 0.39.0
- [Commits](https://github.com/golang/sys/compare/v0.38.0...v0.39.0)

Updates `golang.org/x/term` from 0.37.0 to 0.38.0
- [Commits](https://github.com/golang/term/compare/v0.37.0...v0.38.0)

Updates `golang.org/x/text` from 0.31.0 to 0.32.0
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.31.0...v0.32.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.46.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/net
  dependency-version: 0.48.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/oauth2
  dependency-version: 0.34.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/sync
  dependency-version: 0.19.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/sys
  dependency-version: 0.39.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/term
  dependency-version: 0.38.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/text
  dependency-version: 0.32.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-01 01:01:44 +00:00
fabien-joubert
8179c4f676 docs: add warning for capability-based non-root backups 2025-12-27 22:38:16 +01:00
Michael Eischer
9e2d60e28c Merge pull request #5632 from restic/dependabot/go_modules/github.com/minio/minio-go/v7-7.0.97
build(deps): bump github.com/minio/minio-go/v7 from 7.0.95 to 7.0.97
2025-12-03 21:34:27 +01:00
Michael Eischer
ebc51e60c9 Merge pull request #5626 from MichaelEischer/lazy-status
ui: only redraw status bar if it has not changed
2025-12-03 21:29:35 +01:00
dependabot[bot]
a9a13afcec build(deps): bump github.com/minio/minio-go/v7 from 7.0.95 to 7.0.97
Bumps [github.com/minio/minio-go/v7](https://github.com/minio/minio-go) from 7.0.95 to 7.0.97.
- [Release notes](https://github.com/minio/minio-go/releases)
- [Commits](https://github.com/minio/minio-go/compare/v7.0.95...v7.0.97)

---
updated-dependencies:
- dependency-name: github.com/minio/minio-go/v7
  dependency-version: 7.0.97
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-03 20:24:30 +00:00
Michael Eischer
d7b87cedbc Merge pull request #5630 from restic/dependabot/go_modules/github.com/ncw/swift/v2-2.0.5
build(deps): bump github.com/ncw/swift/v2 from 2.0.4 to 2.0.5
2025-12-03 21:23:18 +01:00
Michael Eischer
a8be8e36fa Merge pull request #5621 from MichaelEischer/copy-stream-snapshots
copy: iterate through snapshots
2025-12-03 21:21:05 +01:00
dependabot[bot]
74f72ec707 build(deps): bump github.com/ncw/swift/v2 from 2.0.4 to 2.0.5
Bumps [github.com/ncw/swift/v2](https://github.com/ncw/swift) from 2.0.4 to 2.0.5.
- [Release notes](https://github.com/ncw/swift/releases)
- [Changelog](https://github.com/ncw/swift/blob/master/RELEASE.md)
- [Commits](https://github.com/ncw/swift/compare/v2.0.4...v2.0.5)

---
updated-dependencies:
- dependency-name: github.com/ncw/swift/v2
  dependency-version: 2.0.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-03 20:06:29 +00:00
Michael Eischer
0b0b714b84 Merge pull request #5628 from MichaelEischer/cleanup-old-build-lines
remove old // +build comments
2025-12-03 21:06:11 +01:00
Michael Eischer
3df4582b2b Merge pull request #5635 from restic/dependabot/github_actions/golangci/golangci-lint-action-9
build(deps): bump golangci/golangci-lint-action from 8 to 9
2025-12-03 21:03:55 +01:00
Michael Eischer
a24184357e Merge pull request #5634 from restic/dependabot/github_actions/actions/checkout-6
build(deps): bump actions/checkout from 5 to 6
2025-12-03 21:00:50 +01:00
Michael Eischer
0d024ad046 Merge pull request #5631 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/azidentity-1.13.1
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity from 1.13.0 to 1.13.1
2025-12-03 20:58:55 +01:00
Michael Eischer
3efd7b5fd0 Merge pull request #5629 from restic/dependabot/go_modules/github.com/klauspost/compress-1.18.1
build(deps): bump github.com/klauspost/compress from 1.18.0 to 1.18.1
2025-12-03 20:58:48 +01:00
Michael Eischer
4fd9bfc32b docs: fix table width 2025-12-03 20:38:21 +01:00
Michael Eischer
7a3b06f78a docs: move environment variables to the scripting section 2025-12-03 18:38:36 +01:00
Michael Eischer
a58d176500 docs: clarify that parameter tuning applies to all commands 2025-12-03 18:33:00 +01:00
dependabot[bot]
0af1257184 build(deps): bump golangci/golangci-lint-action from 8 to 9
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 8 to 9.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v8...v9)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-version: '9'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-01 01:14:24 +00:00
dependabot[bot]
a3f1c65022 build(deps): bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-01 01:14:22 +00:00
dependabot[bot]
fa4ca9b5b4 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity
Bumps [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) from 1.13.0 to 1.13.1.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.13.0...sdk/azidentity/v1.13.1)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
  dependency-version: 1.13.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-01 01:04:00 +00:00
dependabot[bot]
ebdeecde42 build(deps): bump github.com/klauspost/compress from 1.18.0 to 1.18.1
Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.18.0 to 1.18.1.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Commits](https://github.com/klauspost/compress/compare/v1.18.0...v1.18.1)

---
updated-dependencies:
- dependency-name: github.com/klauspost/compress
  dependency-version: 1.18.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-01 01:03:43 +00:00
Michael Eischer
1e6ed458ff remove old // +build comments 2025-11-30 11:53:23 +01:00
Michael Eischer
760d0220f4 restorer: scale file cache with workers count 2025-11-30 11:01:01 +01:00
Michael Eischer
24fcfeafcb restore: cache file descriptors
This avoid opening and closing files after each single blob write
2025-11-30 10:56:15 +01:00
Michael Eischer
0ee9360f3e restore: reduce contention while writing files 2025-11-29 23:09:04 +01:00
Michael Eischer
ae6d6bd9a6 ui: only redraw status bar if it has not changed 2025-11-29 22:09:41 +01:00
Aneesh N
b9afdf795e Fix: Correctly restore ACL inheritance state (#5465)
* Fix: Correctly restore ACL inheritance state

When restoring a file or directory on Windows, the `IsInherited` property of its Access Control Entries (ACEs) was always being set to `False`, even if the ACEs were inherited in the original backup.

This was caused by the restore process calling the `SetNamedSecurityInfo` API without providing context about the object's inheritance policy. By default, this API applies the provided Discretionary Access Control List (DACL) as an explicit set of permissions, thereby losing the original inheritance state.

This commit fixes the issue by inspecting the `Control` flags of the saved Security Descriptor during restore. Based on whether the `SE_DACL_PROTECTED` flag is present, the code now adds the appropriate `PROTECTED_DACL_SECURITY_INFORMATION` or `UNPROTECTED_DACL_SECURITY_INFORMATION` flag to the `SetNamedSecurityInfo` API call.

By providing this crucial inheritance context, the Windows API can now correctly reconstruct the ACL, ensuring the `IsInherited` status of each ACE is preserved as it was at the time of backup.

* Fix: Correctly restore ACL inheritance flags

This commit resolves an issue where the ACL inheritance state (`IsInherited` property) was not being correctly restored for files and directories on Windows.

The root cause was that the `SECURITY_INFORMATION` flags used in the `SetNamedSecurityInfo` API call contained both the `PROTECTED_DACL_SECURITY_INFORMATION` and `UNPROTECTED_DACL_SECURITY_INFORMATION` flags simultaneously. When faced with this conflicting information, the Windows API defaulted to the more restrictive `PROTECTED` behavior, incorrectly disabling inheritance on restored items.

The fix modifies the `setNamedSecurityInfoHigh` function to first clear all existing inheritance-related flags from the `securityInfo` bitmask. It then adds the single, correct flag (`PROTECTED` or `UNPROTECTED`) based on the `SE_DACL_PROTECTED` control bit from the original, saved Security Descriptor.

This ensures that the API receives unambiguous instructions, allowing it to correctly preserve the inheritance state as it was at the time of backup. The accompanying test case for ACL inheritance now passes with this change.

* Fix inheritance flag handling in low-privilege security descriptor restore

When restoring files without admin privileges, the IsInherited property
of Access Control Entries (ACEs) was not being preserved correctly.
The low-privilege restore path (setNamedSecurityInfoLow) was using a
static PROTECTED_DACL_SECURITY_INFORMATION flag, which always marked
the restored DACL as explicitly set rather than inherited.

This commit updates setNamedSecurityInfoLow to dynamically determine
the correct inheritance flag based on the SE_DACL_PROTECTED control
flag from the original security descriptor, matching the behavior of
the high-privilege path (setNamedSecurityInfoHigh).

Changes:
- Update setNamedSecurityInfoLow to accept control flags parameter
- Add logic to set either PROTECTED_DACL_SECURITY_INFORMATION or
  UNPROTECTED_DACL_SECURITY_INFORMATION based on the original SD
- Add TestRestoreSecurityDescriptorInheritanceLowPrivilege to verify
  inheritance is correctly restored in low-privilege scenarios

This ensures that both admin and non-admin restore operations correctly
preserve the inheritance state of ACLs, maintaining the original
permissions flow on child objects.

Addresses review feedback on PR for issue #5427

* Refactor security flags into separate backup/restore variants

Split highSecurityFlags into highBackupSecurityFlags and
highRestoreSecurityFlags to avoid runtime bitwise operations.
This makes the code cleaner and more maintainable by using
appropriate flags for GET vs SET operations.

Addresses review feedback on PR for issue #5427

---------

Co-authored-by: Aneesh Nireshwalia <anireshw@akamai.com>
2025-11-28 19:22:47 +00:00
Winfried Plappert
ce57961f14 restic check with snapshot filters (#5469)
---------

Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2025-11-28 19:12:38 +00:00
Michael Eischer
e1bc2fb71a copy: iterate through snapshots 2025-11-26 22:48:54 +01:00
Michael Eischer
8fdbdc57a0 Merge pull request #5581 from restic/dependabot/go_modules/google.golang.org/api-0.254.0
build(deps): bump google.golang.org/api from 0.248.0 to 0.254.0
2025-11-26 22:24:43 +01:00
dependabot[bot]
69ac0d84ac build(deps): bump google.golang.org/api from 0.248.0 to 0.254.0
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.248.0 to 0.254.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.248.0...v0.254.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-version: 0.254.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-26 21:12:48 +00:00
Michael Eischer
0a96f0d623 Merge pull request #5578 from restic/dependabot/go_modules/cloud.google.com/go/storage-1.57.1
build(deps): bump cloud.google.com/go/storage from 1.56.1 to 1.57.1
2025-11-26 22:12:09 +01:00
Michael Eischer
0d8b715d92 Merge pull request #5547 from restic/dependabot/go_modules/golang-x-deps-3a742399ff
build(deps): bump the golang-x-deps group with 8 updates
2025-11-26 22:11:35 +01:00
dependabot[bot]
31e3717b25 build(deps): bump the golang-x-deps group with 8 updates
Bumps the golang-x-deps group with 8 updates:

| Package | From | To |
| --- | --- | --- |
| [golang.org/x/crypto](https://github.com/golang/crypto) | `0.41.0` | `0.42.0` |
| [golang.org/x/net](https://github.com/golang/net) | `0.43.0` | `0.44.0` |
| [golang.org/x/oauth2](https://github.com/golang/oauth2) | `0.30.0` | `0.31.0` |
| [golang.org/x/sync](https://github.com/golang/sync) | `0.16.0` | `0.17.0` |
| [golang.org/x/sys](https://github.com/golang/sys) | `0.35.0` | `0.36.0` |
| [golang.org/x/term](https://github.com/golang/term) | `0.34.0` | `0.35.0` |
| [golang.org/x/text](https://github.com/golang/text) | `0.28.0` | `0.29.0` |
| [golang.org/x/time](https://github.com/golang/time) | `0.12.0` | `0.13.0` |


Updates `golang.org/x/crypto` from 0.41.0 to 0.42.0
- [Commits](https://github.com/golang/crypto/compare/v0.41.0...v0.42.0)

Updates `golang.org/x/net` from 0.43.0 to 0.44.0
- [Commits](https://github.com/golang/net/compare/v0.43.0...v0.44.0)

Updates `golang.org/x/oauth2` from 0.30.0 to 0.31.0
- [Commits](https://github.com/golang/oauth2/compare/v0.30.0...v0.31.0)

Updates `golang.org/x/sync` from 0.16.0 to 0.17.0
- [Commits](https://github.com/golang/sync/compare/v0.16.0...v0.17.0)

Updates `golang.org/x/sys` from 0.35.0 to 0.36.0
- [Commits](https://github.com/golang/sys/compare/v0.35.0...v0.36.0)

Updates `golang.org/x/term` from 0.34.0 to 0.35.0
- [Commits](https://github.com/golang/term/compare/v0.34.0...v0.35.0)

Updates `golang.org/x/text` from 0.28.0 to 0.29.0
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.28.0...v0.29.0)

Updates `golang.org/x/time` from 0.12.0 to 0.13.0
- [Commits](https://github.com/golang/time/compare/v0.12.0...v0.13.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.42.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/net
  dependency-version: 0.44.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/oauth2
  dependency-version: 0.31.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/sync
  dependency-version: 0.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/sys
  dependency-version: 0.36.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/term
  dependency-version: 0.35.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/text
  dependency-version: 0.29.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
- dependency-name: golang.org/x/time
  dependency-version: 0.13.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-x-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-26 20:56:35 +00:00
dependabot[bot]
42133ccffe build(deps): bump cloud.google.com/go/storage from 1.56.1 to 1.57.1
Bumps [cloud.google.com/go/storage](https://github.com/googleapis/google-cloud-go) from 1.56.1 to 1.57.1.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/storage/v1.56.1...storage/v1.57.1)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/storage
  dependency-version: 1.57.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-26 20:56:27 +00:00
Michael Eischer
77374b5bf0 Merge pull request #5619 from restic/bump-go-version
bump minimum go version to 1.24
2025-11-26 21:55:02 +01:00
Michael Eischer
f3a89bfff6 Merge pull request #5612 from MichaelEischer/repository-async-saveblob
repository: add async blob upload method
2025-11-26 21:34:35 +01:00
Michael Eischer
7696e4b495 bump minimum go version to 1.24 2025-11-26 21:33:40 +01:00
Michael Eischer
5cc8636047 Merge pull request #5614 from MichaelEischer/fix-lookupblobsize
repository: fix LookupBlobSize to also return pending blobs
2025-11-26 21:24:32 +01:00
Michael Eischer
6769d26068 archiver: improve test reliability 2025-11-26 21:21:16 +01:00
Michael Eischer
5607fd759f repository: fix race condition for blobSaver shutdown
wg.Go() may not be called after wg.Wait(). This prevents connecting two
errgroups such that the errors are propagated between them if the child
errgroup dynamically starts goroutines. Instead use just a single errgroup,
and sequence the shutdown using a sync.WaitGroup. This is far simpler
and does not require any "clever" tricks.
2025-11-26 21:18:22 +01:00
Michael Eischer
9f87e9096a repository: add tests for SaveBlobAsync 2025-11-26 21:18:22 +01:00
Michael Eischer
d8dcd6d115 archiver: add buffer test 2025-11-26 21:18:22 +01:00
Michael Eischer
3f92987974 archiver: assert number of uploaded chunks in fileSaver test 2025-11-26 21:18:22 +01:00
Michael Eischer
7f6fdcc52c archiver: convert buffer pool to use sync.Pool 2025-11-26 21:18:22 +01:00
Michael Eischer
dd6cb0dd8e archiver: port to repository.SaveBlobAsync 2025-11-26 21:18:22 +01:00
Michael Eischer
046b0e711d repository: add SaveBlobAsync method 2025-11-26 21:18:21 +01:00
Michael Eischer
4d2da63829 Merge pull request #5610 from MichaelEischer/associated-blob-set-everywhere
check/copy/diff/stats: reduce memory usage
2025-11-26 21:09:26 +01:00
Michael Eischer
134893bd35 copy: use AssociatedBlobSet to keep track of processed trees 2025-11-26 21:00:18 +01:00
Michael Eischer
7b59dd7cf4 add changelog 2025-11-26 20:59:39 +01:00
Michael Eischer
84dda4dc74 check: use AssociatedBlobSet 2025-11-26 20:59:39 +01:00
Michael Eischer
46ebee948f stats: use AssociatedBlobSet 2025-11-26 20:59:39 +01:00
Michael Eischer
d91fe1d7e1 diff: use AssociatedBlobSet 2025-11-26 20:59:39 +01:00
Michael Eischer
ff099a216a copy: use AssociatedBlobSet 2025-11-26 20:59:38 +01:00
Michael Eischer
07d090f233 repository: expose AssociatedBlobSet via repository interface 2025-11-26 20:59:08 +01:00
Michael Eischer
0f05277b47 index: add sub and intersect method to AssociatedSet 2025-11-26 20:59:08 +01:00
Michael Eischer
7e80536a9b Merge pull request #5472 from wplapper/cmd_copy_stream
restic copy --stream: run one large copy operation crossing snapshot boundaries - issue #5453
2025-11-26 20:57:46 +01:00
Michael Eischer
f9e5660e75 output which source and target snapshot belong together 2025-11-23 22:01:53 +01:00
Michael Eischer
e79b01d82f more aggressive batching 2025-11-23 21:46:03 +01:00
Michael Eischer
857b42fca4 merge into existing copy test 2025-11-23 19:08:49 +01:00
Michael Eischer
39db78446f Simplify test 2025-11-23 19:05:55 +01:00
Michael Eischer
f1aabdd293 index: add test for pending blobs 2025-11-23 18:08:56 +01:00
Michael Eischer
50d376c543 repository: fix LookupBlobSize to also report pending blobs 2025-11-23 17:55:13 +01:00
Michael Eischer
7d08c9282a align docs 2025-11-23 17:51:07 +01:00
Michael Eischer
cf409b7c66 automatically batch snapshots in copy 2025-11-23 17:40:37 +01:00
Michael Eischer
f95dc73d38 deduplicate blob enqueuing 2025-11-23 17:13:10 +01:00
Michael Eischer
63bc1405ea unify snapshot copy codepaths 2025-11-23 17:12:54 +01:00
Michael Eischer
405813f250 repository: fix LookupBlobSize to also report pending blobs 2025-11-23 17:09:07 +01:00
Michael Eischer
05364500b6 use correct context 2025-11-23 16:25:09 +01:00
Michael Eischer
e775192fe7 don't sort snapshots, drop duplicate code and cleanup copyTreeBatched function signature 2025-11-23 16:20:40 +01:00
Michael Eischer
4395a77154 copy: remove bugous seenBlobs set 2025-11-23 16:06:45 +01:00
Michael Eischer
81d8bc4ade repository: replace CopyBlobs with Repack implementation 2025-11-23 16:06:29 +01:00
Michael Eischer
d681b8af5e Merge pull request #5611 from insertish/docs/scripting-tag-schema
docs: correct the schema provided for tag summary
2025-11-23 15:45:53 +01:00
izzy
629eaa5d21 docs: correct the schema provided for tag summary 2025-11-20 17:35:25 +00:00
Michael Eischer
6174c91042 Merge pull request #5588 from seqizz/g_timezoneshow
snapshots: Show timezone in non-compact output
2025-11-19 22:06:37 +01:00
Winfried Plappert
b24b088978 restic copy --batch: The mighty linter
I cave in - no double comment
2025-11-19 07:34:39 +00:00
Winfried Plappert
fc3de018bc restic copy --batch - fussy linter
internal/repository/repack.go: I have to please the mighty linter.
2025-11-19 07:29:09 +00:00
Winfried Plappert
b87f7586e4 restic copy --batch: a fresh start from commit 382616747
Instead of rebasing my code, I decided to start fresh, since WithBlobUploader()
has been introduced.

changelog/unreleased/issue-5453:
doc/045_working_with_repos.rst:
the usual

cmd/restic/cmd_copy.go:
gather all snaps to be collected - collectAllSnapshots()
run overall copy step - func copyTreeBatched()
helper copySaveSnapshot() to save the corresponding snapshot

internal/repository/repack.go:
introduce wrapper CopyBlobs(), which passes parameter `uploader restic.BlobSaver` from
WithBlobUploader() via copyTreeBatched() to repack().

internal/backend/local/local_windows.go:
I did not touch it, but gofmt did: whitespace
2025-11-19 07:09:24 +00:00
Gürkan
dc4e9b31f6 snapshots: Show timezone in non-compact output 2025-11-18 13:32:44 +01:00
Michael Eischer
8767549367 Merge pull request #5601 from MichaelEischer/snapshots-fix-groupby-with-latest
snapshots: correctly handle --latest in combination with --group-by
2025-11-17 22:50:50 +01:00
Michael Eischer
5afe61585b snapshots: correctly handle --latest in combination with --group-by 2025-11-17 22:26:57 +01:00
Michael Eischer
46f3ece883 Merge pull request #5597 from MichaelEischer/bump-go-for-standalone-docker
bump go version in dockerfile to go 1.25
2025-11-17 22:05:45 +01:00
Michael Eischer
96adbbaa42 Merge pull request #5599 from MichaelEischer/prune-clean-error
prune: return proper error if blob cannot be found
2025-11-17 22:05:17 +01:00
Michael Eischer
7297047b71 Merge pull request #5600 from MichaelEischer/docs-tmp-var-on-windows
only suggest TMP as tmp dir variable on windows
2025-11-17 22:04:42 +01:00
Michael Eischer
132f2f8a23 Merge pull request #5602 from MichaelEischer/fix-flaky-rclone-test
rclone: fix rare test failure if rclone cannot be started
2025-11-17 22:04:10 +01:00
Michael Eischer
a519d1e8df Merge pull request #5603 from MichaelEischer/debug-flaky-windows-test
restore: enable debug logging for flaky windows test
2025-11-17 22:03:38 +01:00
Paulo Saraiva
c1a89d5150 Allow for a personal token to be specified for self-updates (#5568)
* Allow for a personal token to be specified for self-updates

This change will allow for setting the $GITHUB_ACCESS_TOKEN environment variable with a Github personal access token, allowing e.g. for higher rate limits

* Refactor github request and add test

---------

Co-authored-by: Paulo Saraiva <pauloman@cern.ch>
2025-11-17 21:39:39 +01:00
Michael Eischer
3826167474 Merge pull request #5424 from Crazycatz00/sebackup-fixes
Windows Backup Privilege Tweaks
2025-11-16 21:35:35 +01:00
Michael Eischer
98f56d8ada restore: enable debug logging for flaky windows test 2025-11-16 20:24:19 +01:00
Michael Eischer
1caeb2aa4d rclone: fix rare test failure if rclone cannot be started 2025-11-16 20:14:21 +01:00
crazycatz00
3ab68d4d11 fs: Clarified documentation 2025-11-16 11:53:13 -05:00
Michael Eischer
ffc5e9bd5c only suggest TMP as tmp dir variable on windows
TMP takes precedence over TEMP.
2025-11-16 17:31:36 +01:00
Michael Eischer
0ff3e20c4b prune: return proper error if blob cannot be found 2025-11-16 17:04:03 +01:00
Michael Eischer
3b854d9c04 Merge pull request #5449 from provokateurin/restore-ownership-by-name
feat(internal/fs/node): Restore ownership by name
2025-11-16 16:50:36 +01:00
ferringb
87f26accb7 feat: add integrated nice and ionice options for docker (#5448)
The intended usage here is to basically kick restic as a background
"do it, but don't bother my normal load" process.

This allows passing the following environment variables in to
influence scheduling:

- NICE: usual CPU nice.  Defaults to 0.  This requires CAP_SYS_NICE
  to set a negative nice (IE, prioritize).
- IONICE_CLASS: usual ionice class.  Note that setting realtime
  requires CAP_SYS_ADMIN.  Also note the actual ionice default
  is "none".
- IONICE_PRIORITY: set the priority within the given class.  Ignored
  if no class is specified due to class default of "no scheduler".

---------

Signed-off-by: Brian Harring <ferringb@gmail.com>
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2025-11-16 16:42:33 +01:00
provokateurin
8fae46011a feat(internal/fs/node): Restore ownership by name 2025-11-16 16:40:58 +01:00
Michael Eischer
c854338ad1 Merge pull request #5596 from mikix/chmod-again
backend/local: fix "operation not supported" when unlocking
2025-11-16 14:25:04 +01:00
Michael Eischer
10a10b8d63 bump go version in dockerfile to go 1.25
Note that this go version is independent of that used for the official
release binaries.
2025-11-16 14:22:43 +01:00
Michael Terry
7f3e3b77ce backend/local: fix "operation not supported" when unlocking
If the repo is on a mounted folder that doesn't support chmod (like
SMB), it was causing an "operation not supported" error when trying to
chmod 666 a file before deleting it.

But it isn't generally needed before deleting a file (the folder
permissions matter there, not the file permissions). So, just drop it.
2025-11-16 08:09:51 -05:00
Michael Eischer
d81f95c777 Merge pull request #5464 from wplapper/cmd_copy_v2
restic copy - add more status counters - issue #5175
2025-11-16 13:55:41 +01:00
DoS007
2bd6649813 docs: add info about ssd wear in backend connections (#5496)
---------

Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2025-11-16 12:48:56 +00:00
Winfried Plappert
3b71c44755 restic copy - stattistics counters
fixed typo in changelog/unreleased/pull-5319
2025-11-16 13:47:11 +01:00
Winfried Plappert
1e3b96bf99 restic copy - statistics feature
reword the description od the PR
2025-11-16 13:47:11 +01:00
Winfried Plappert
25611f4628 restic copy - add statistics counters
cmd/restic/cmd_copy.go:
add function copyStats() and call it before the actual copying starts.

changelog/unreleased/pull-5319:
rephrased wording of the statistics counters.
2025-11-16 13:47:10 +01:00
Winfried Plappert
90ac3efa88 restic copy - add additional status counters
'copyTree()' now counts and sizes the blobs in 'copyBlobs' and prints them out
via 'Verbosef()'.
2025-11-16 13:46:27 +01:00
Michael Eischer
5b173d2206 Merge pull request #5567 from Paulomen2712/add_better_forget_example_docs
Improve example for forget --keep-daily
2025-11-16 13:45:13 +01:00
Michael Eischer
14f3bc8232 Merge pull request #5560 from MichaelEischer/index-iterators
index: port to  modern Go iterators
2025-11-16 13:24:48 +01:00
Michael Eischer
4ef7b4676b Merge pull request #5559 from MichaelEischer/cleanup-repack
repository: remove unused return value from Repack
2025-11-16 13:01:00 +01:00
Michael Eischer
b587c126e0 Fix linter warning 2025-11-16 12:56:37 +01:00
Michael Eischer
9944ef7a7c index: convert AssociatedSet to go iterators 2025-11-16 12:56:37 +01:00
Michael Eischer
38c543457e index: convert to implement modern go iterators 2025-11-16 12:56:37 +01:00
Michael Eischer
393e49fc89 repository: update comment 2025-11-16 12:51:46 +01:00
Michael Eischer
a0925fa922 repository: set progress bar maximum in Repack 2025-11-16 12:51:46 +01:00
Michael Eischer
b2afccbd96 repository: remove unused obsoletePacks return values from Repack 2025-11-16 12:51:46 +01:00
Michael Eischer
0624b656b8 Merge pull request #5558 from MichaelEischer/simplify-blob-upload
repository: enforce correct usage of SaveBlob
2025-11-16 12:51:01 +01:00
Brook
fadeb03f84 Update Nix/NixOS installation instructions (#5591)
Corrected spelling errors and updated installation instructions for Nix/NixOS.
2025-11-16 11:31:47 +00:00
Michael Eischer
fc06a79518 Merge pull request #5579 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob-1.6.3
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob from 1.6.2 to 1.6.3
2025-11-16 12:03:02 +01:00
Michael Eischer
d5977deb49 Merge pull request #5580 from restic/dependabot/go_modules/github.com/pkg/sftp-1.13.10
build(deps): bump github.com/pkg/sftp from 1.13.9 to 1.13.10
2025-11-16 12:02:30 +01:00
Michael Eischer
e3b7bbd020 Merge pull request #5552 from ferringb/dockerignore
add a dockerignore
2025-11-16 12:00:52 +01:00
Michael Eischer
157f174dd9 Merge pull request #5370 from hashier/feat/exclude-macOS-cloud-files
feat(backup): add possibility to exclude macOS cloud-only files
2025-11-16 11:57:37 +01:00
Alex Xu
bcc5417dc8 Merge pull request #5386 from Hello71/patch-2
doc: Add ambient caps example, edit file caps
2025-11-16 11:54:43 +01:00
crazycatz00
d14823eb81 fs: Attempt to enable file system privileges on initialization.
Add tests to verify privileges' effects.
2025-11-07 19:31:59 -05:00
crazycatz00
01bf8977e7 fs: Use backup privileges when reading extended attributes for files too. 2025-11-07 19:31:57 -05:00
dependabot[bot]
f5a18a7799 build(deps): bump github.com/pkg/sftp from 1.13.9 to 1.13.10
Bumps [github.com/pkg/sftp](https://github.com/pkg/sftp) from 1.13.9 to 1.13.10.
- [Release notes](https://github.com/pkg/sftp/releases)
- [Commits](https://github.com/pkg/sftp/compare/v1.13.9...v1.13.10)

---
updated-dependencies:
- dependency-name: github.com/pkg/sftp
  dependency-version: 1.13.10
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-01 01:02:06 +00:00
dependabot[bot]
f756c6a441 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
Bumps [github.com/Azure/azure-sdk-for-go/sdk/storage/azblob](https://github.com/Azure/azure-sdk-for-go) from 1.6.2 to 1.6.3.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/storage/azblob/v1.6.2...sdk/storage/azblob/v1.6.3)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
  dependency-version: 1.6.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-01 01:02:03 +00:00
Brian Harring
8cbca05853 add a dockerignore
This is strictly for tightening the container to be more hygenic.

Signed-off-by: Brian Harring <ferringb@gmail.com>
2025-10-29 16:18:40 +01:00
Paulo Manuel Ferreira Dos Santos Saraiva
b0eb3652b8 Improve example for forget --keep-daily 2025-10-22 11:31:50 +02:00
Michael Eischer
71432c7f4b Merge pull request #5555 from MichaelEischer/extract-globaloptions
Split globalOptions into separate package
2025-10-12 18:31:44 +02:00
Michael Eischer
c6e33c3954 repository: enforce that SaveBlob is called within WithBlobUploader
This is achieved by removing SaveBlob from the public API and only
returning it via a uploader object that is passed in by
WithBlobUploader.
2025-10-12 18:26:26 +02:00
Michael Eischer
1ef785daa3 Merge pull request #5544 from zmanda/fix-gh-5531-azure-backend-upgrade-service-version
azure: use PutBlob API for uploads instead of PutBlock API + PutBlock List API
2025-10-12 18:24:33 +02:00
Michael Eischer
aa0fb0210a Merge pull request #5556 from greatroar/cleanup
ui/backup: Prepend, then sort (micro-optimization)
2025-10-12 18:22:36 +02:00
Michael Eischer
b6aef592f5 global: split CreateRepository and OpenRepository into smaller functions 2025-10-12 18:20:45 +02:00
Michael Eischer
588c40aaef global: unexport ReadPassword and ReadRepo 2025-10-12 18:08:26 +02:00
Michael Eischer
aa7bd241d9 init: move more logic into global package 2025-10-12 18:08:26 +02:00
Michael Eischer
536a2f38bd Merge pull request #5554 from MichaelEischer/termstatus-flush
termstatus: flush before reading password from terminal
2025-10-12 17:59:03 +02: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
Michael Eischer
394c8de502 add package to create a prepopulated backend registry 2025-10-12 17:56:28 +02:00
Michael Eischer
a632f490fa Merge pull request #5550 from MichaelEischer/refactor-check-data-selection
check: refactor pack selection for read data
2025-10-12 17:51:00 +02:00
Michael Eischer
718b97f37f Merge pull request #5551 from restic/slower-terminal-output
Reduce terminal progress fps to 10
2025-10-12 17:47:27 +02:00
Michael Eischer
ac4642b479 repository: replace StartPackUploader+Flush with WithBlobUploader
The new method combines both step into a single wrapper function. Thus
it ensures that both are always called in pairs. As an additional
benefit this slightly reduces the boilerplate to upload blobs.
2025-10-08 22:49:45 +02:00
greatroar
20b38010e1 ui/backup: Prepend, then sort (micro-optimization) 2025-10-06 16:16:37 +02:00
Srigovind Nayak
f9ff2301e8 changelog: add a changelog entry for azure PutBlob API changes 2025-10-05 21:48:02 +05:30
Srigovind Nayak
e65ee3cba8 fix: keep the PutBlock Size to 100 MiB
No complaints in the past.
2025-10-05 21:41:26 +05:30
Srigovind Nayak
34a94afc48 azure: update upload size constants to reduce memory allocation 2025-10-05 21:41:25 +05:30
Srigovind Nayak
9bcd09bde0 azure: reduce singleBlockMaxSize to accommodate 32-bit systems 2025-10-05 21:41:25 +05:30
Srigovind Nayak
e80e832130 azure: remove saveSmall, use only PutBlob API 2025-10-05 21:41:25 +05:30
Srigovind Nayak
dd2d562b7b azure: enhanced upload with single PutBlob API and configurable upload methods 2025-10-05 21:41:25 +05:30
Michael Eischer
e320ef0a62 add changelog 2025-10-05 16:14:16 +02:00
Michael Eischer
30ed992af9 termstatus: flush output before returning OutputRaw() writer
This prevents mangling the output due to delayed messages.
2025-10-05 16:14:16 +02:00
Srigovind Nayak
481fcb9ca7 backup: return exit code 3 if not all targets are available (#5347)
to make the exit code behaviour consistent with files inaccessible during the backup phase, making this change to exit with code 3 if not all target files/folders are accessible for backup

---------

Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2025-10-05 15:38:52 +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
f17027eeaa termstatus: flush before reading password from terminal 2025-10-04 23:06:57 +02:00
Christopher Loessl
f3d95893b2 feat(backup): add possibility to exclude macOS cloud-only files 2025-10-04 19:22:51 +02:00
Michael Eischer
4759e58994 Reduce terminal progress fps to 10 2025-10-04 17:34:40 +02:00
Winfried Plappert
a2a49cf784 list integration test: error scanning 'restic list blobs' (#5311)
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2025-10-04 12:18:32 +00:00
Michael Eischer
b7bbb408ee check: refactor pack selection for read data
Drop the `packs` map from the internal state of the checker. Instead the
Packs(...) method now calls a filter callback that can select the
packs intended for checking.
2025-10-03 23:45:05 +02:00
Michael Eischer
35fca09326 Merge pull request #5489 from MichaelEischer/fix-group-repos
docs: fix permission setup for group-accessible repo
2025-10-03 23:03:50 +02:00
Michael Eischer
adbd4a1d18 Fully rework docs for group-accessible repositories
Just tell the user what to do instead of explaining too many details.
I've dropped the read-only variant as it actually has no representation
in the local and sftp backends. Instead it relied on both backends
initially creating all directories, which can't actually be guaranteed.

Based on a suggestion by @brad2014 in significant parts.
2025-10-03 21:24:57 +02:00
Michael Eischer
537d107b6c docs: use absolute permissions for group accessible repositories 2025-10-03 21:24:57 +02:00
Michael Eischer
06aa0f08cb docs: fix permission setup for group-accessible repo
The group always needs execute access for the directories. In addition,
files should be always set to read-only for everyone as restic never
modifies files.
2025-10-03 21:24:57 +02:00
Rani
3ae6a69154 Bugfix(sftp): fix loose permissions on sftp backend. (#5497) 2025-10-03 18:20:52 +00:00
Michael Eischer
264cd67c36 Merge pull request #5532 from MichaelEischer/checker-cleanup
Replace Repository.SetIndex with internal helper
2025-10-03 20:08:14 +02:00
Michael Eischer
fd241b8ec7 Merge pull request #5527 from MichaelEischer/drop-s3-static-credentials
s3: drop manual credentials loading from environment
2025-10-03 19:57:55 +02:00
Michael Eischer
76aa9e4f7c Merge pull request #5549 from restic/dependabot/go_modules/github.com/peterbourgon/unixtransport-0.0.7
build(deps): bump github.com/peterbourgon/unixtransport from 0.0.6 to 0.0.7
2025-10-03 19:56:02 +02:00
Michael Eischer
aae1acf4d7 check: fix dysfunctional test cases 2025-10-03 19:49:51 +02:00
dependabot[bot]
cc0480fc32 build(deps): bump github.com/peterbourgon/unixtransport
Bumps [github.com/peterbourgon/unixtransport](https://github.com/peterbourgon/unixtransport) from 0.0.6 to 0.0.7.
- [Release notes](https://github.com/peterbourgon/unixtransport/releases)
- [Commits](https://github.com/peterbourgon/unixtransport/compare/v0.0.6...v0.0.7)

---
updated-dependencies:
- dependency-name: github.com/peterbourgon/unixtransport
  dependency-version: 0.0.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-03 17:41:39 +00:00
Michael Eischer
838ef0a9bd Merge pull request #5546 from MichaelEischer/group-golang-dependencies
CI: group dependency updates for golang.org/x/*
2025-10-03 19:40:15 +02:00
Michael Eischer
4426dfe6a9 repository: replace SetIndex method with internal loadIndexWithCallback method 2025-10-03 19:36:57 +02:00
Michael Eischer
f0955fa931 repository: add Checker() method to repository to replace unchecked cast 2025-10-03 19:34:33 +02:00
Michael Eischer
189b295c30 repository: add dedicated test helper 2025-10-03 19:34:33 +02:00
Michael Eischer
82971ad7f0 check: split index/pack check into repository package 2025-10-03 19:34:32 +02:00
Michael Eischer
bfc2ce97fd check: don't keep extra MasterIndex reference 2025-10-03 19:32:15 +02:00
Michael Eischer
d84c3e3c60 CI: group dependency updates for golang.org/x/* 2025-10-03 19:28:30 +02:00
Michael Eischer
93720f0717 Merge pull request #5525 from MichaelEischer/split-restic-directory
Extract snapshot data types from restic package
2025-10-03 19:24:31 +02:00
Michael Eischer
70a24cca85 ignore linter warning 2025-10-03 19:10:40 +02:00
Michael Eischer
56ac8360c7 data: split node and snapshot code from restic package 2025-10-03 19:10:39 +02:00
Michael Eischer
c85b157e0e restic: move interfaces between files to prepare refactor 2025-10-03 19:06:32 +02:00
Michael Eischer
13e476e1eb Merge pull request #5518 from MichaelEischer/termstatus-everywhere
Consolidate terminal input/output functionality in termstatus.Terminal
2025-10-03 19:05:28 +02:00
Michael Eischer
3335f62a8f Fix linter warnings 2025-10-03 18:55:46 +02:00
Michael Eischer
d8da3d2f2d termstatus: increase test coverage 2025-10-03 18:55:46 +02:00
Michael Eischer
df7924f4df node: report error on xattr retrieval using standard error logging 2025-10-03 18:55:46 +02:00
Michael Eischer
f2b9ea6455 termstatus: use errWriter if terminal commands fail 2025-10-03 18:55:46 +02:00
Michael Eischer
711194276c remove unused printer from ReadPassword 2025-10-03 18:55:46 +02:00
Michael Eischer
f045297348 termstatus: fix typo in comment 2025-10-03 18:55:46 +02:00
Michael Eischer
52eb66929f repository: deduplicate index progress bar initializaton 2025-10-03 18:55:46 +02:00
Michael Eischer
b459d66288 termstatus: additional comments 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
c293736841 drop unused stderr from GlobalOptions 2025-10-03 18:55:46 +02:00
Michael Eischer
1939cff334 restore: embed progress.Printer in restore-specific printer 2025-10-03 18:55:46 +02:00
Michael Eischer
1a76f988ea backup: embed progress.Printer in backup specific printer 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
ff5a0cc851 termstatus: fully wrap reading password from terminal 2025-10-03 18:55:46 +02:00
Michael Eischer
013c565c29 standardize shorten variable name for GlobalOptions to gopts 2025-10-03 18:55:46 +02:00
Michael Eischer
96af35555a termstatus: add stdin and inject into backup command 2025-10-03 18:55:46 +02:00
Michael Eischer
ca5b0c0249 get rid of fmt.Print* usages 2025-10-03 18:55:46 +02:00
Michael Eischer
3410808dcf deduplicate termstatus setup 2025-10-03 18:55:46 +02:00
Michael Eischer
1ae2d08d1b termstatus: centralize OutputIsTerminal checks 2025-10-03 18:55:46 +02:00
Michael Eischer
c745e4221e termstatus: use errWriter instead of os.Stderr 2025-10-03 18:22:42 +02:00
Michael Eischer
b6c50662da repository: don't ignore cache clearing error 2025-10-03 18:22:42 +02:00
Michael Eischer
4dc71f24c5 backends: pass error logger to backends 2025-10-03 18:22:42 +02:00
Michael Eischer
13f743e26b profiling: inject os.Stderr instead of directly using it 2025-10-03 18:22:42 +02:00
Michael Eischer
3e1632c412 reduce os.stdout / os.stderr usage in tests 2025-10-03 18:22:42 +02:00
Michael Eischer
6bd85d2412 reduce usages of globalOptions variable 2025-10-03 18:22:42 +02:00
Michael Eischer
e4395a9d73 Merge pull request #5535 from restic/dependabot/github_actions/docker/login-action-3.6.0
build(deps): bump docker/login-action from 3.5.0 to 3.6.0
2025-10-03 18:21:27 +02:00
Michael Eischer
4d1f6b1fe2 Merge pull request #5536 from restic/dependabot/github_actions/actions/setup-go-6
build(deps): bump actions/setup-go from 5 to 6
2025-10-03 18:20:47 +02:00
Michael Eischer
331260e1d4 Merge pull request #5537 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/azidentity-1.12.0
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity from 1.11.0 to 1.12.0
2025-10-03 18:20:05 +02:00
Michael Eischer
eb13789b2b Merge pull request #5528 from MichaelEischer/cleanup-fatalf-usage
Cleanup fatalf usage
2025-10-01 20:17:30 +02:00
dependabot[bot]
0cd079147f build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity
Bumps [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) from 1.11.0 to 1.12.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/sdk-breaking-changes-guide-migration.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.11.0...sdk/azcore/v1.12.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
  dependency-version: 1.12.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-01 01:02:17 +00:00
dependabot[bot]
0b4b092941 build(deps): bump actions/setup-go from 5 to 6
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5 to 6.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-01 01:01:54 +00:00
dependabot[bot]
01d3357880 build(deps): bump docker/login-action from 3.5.0 to 3.6.0
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.5.0 to 3.6.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](184bdaa072...5e57cd1181)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 3.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-01 01:01:51 +00:00
Michael Eischer
1c7bb15327 Merge pull request #5451 from greatroar/concurrency
Concurrency simplifications
2025-09-24 22:22:40 +02:00
Michael Eischer
d491c1bdbf use errors.Fatalf instead of custom formatting 2025-09-24 22:11:54 +02:00
Michael Eischer
97933d1404 remove trailing newlines from errors.Fatalf calls 2025-09-24 22:11:34 +02:00
Michael Eischer
4edfd36c8f Merge pull request #5363 from zmanda/fix-gh-5258-backup-exits-with-wrong-code-on-ctrl-c
bugfix: fatal errors do not keep underlying error
2025-09-24 22:04:38 +02:00
Michael Eischer
a30a36ca51 s3: drop manual credentials loading from environment
credentials.EnvAWS offers a superset of the manually implemented
credentials loading. Rework the error message that is shown if no
credentials were found but either access or secret key are set.
2025-09-24 21:02:02 +02:00
Michael Eischer
d52f92e8cc Merge pull request #5523 from tobiaskarch/patch-1
Add OpenContainers labels to Dockerfile.release
2025-09-24 20:37:55 +02:00
Michael Eischer
a4e565d921 Merge pull request #5524 from dmotte/pr-fix-backupend
internal/archiver: fixed BackupEnd when SkipIfUnchanged is true
2025-09-24 20:32:44 +02:00
Michael Eischer
ec796e6edd Merge pull request #5526 from lyallcooper/patch-1
Fix typo in rewrite command note
2025-09-24 20:31:50 +02:00
Lyall Cooper
e30acefbff Fix typo in rewrite command note 2025-09-24 14:40:35 +09:00
Michael Eischer
3e6b5c34c9 Merge pull request #5512 from ProactiveServices/patch-1
doc: mention value for pack size setting
2025-09-23 19:35:38 +02:00
dmotte
9017fefddd internal/archiver: fixed BackupEnd when SkipIfUnchanged is true 2025-09-23 03:07:30 +02:00
Michael Eischer
93d1e3b211 Merge pull request #5519 from MichaelEischer/go-1.25
CI: add go 1.25
2025-09-22 22:44:21 +02:00
Tobias Karch
8f858829ed Add OpenContainers labels to Dockerfile.release 2025-09-22 17:37:17 +00:00
Adam Piggott
db3b3e31e6 Line breaks 2025-09-22 14:24:02 +01:00
Michael Eischer
3f7121e180 backup: adapt test to changed error message 2025-09-21 22:59:59 +02:00
Michael Eischer
d5dd8ce6a7 CI: add go 1.25 2025-09-21 22:38:34 +02:00
Michael Eischer
08443fe593 Merge pull request #5405 from restic/dependabot/github_actions/golangci/golangci-lint-action-8
build(deps): bump golangci/golangci-lint-action from 6 to 8
2025-09-21 22:37:26 +02:00
Michael Eischer
daeb55a4fb Merge pull request #5511 from greatroar/atomic
ui/progress: Restore atomics in Counter
2025-09-21 22:29:40 +02:00
Michael Eischer
6ebc23543d CI: use strict matching for generated source files in golangci-lint 2025-09-21 22:25:57 +02:00
Michael Eischer
7257cd2e5f extra linters 2025-09-21 22:24:35 +02:00
Michael Eischer
88bdf20bd8 Reduce linter ignores 2025-09-21 22:24:27 +02:00
Michael Eischer
8518c1f7d9 CI: convert golangci-lint configuration to v2 2025-09-21 22:24:15 +02:00
Michael Eischer
60d80a6127 Fix linter warnings 2025-09-21 22:24:15 +02:00
Michael Eischer
575eac8d80 CI: bump golangci version to v2 2025-09-21 22:20:37 +02:00
dependabot[bot]
5c667f0501 build(deps): bump golangci/golangci-lint-action from 6 to 8
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6 to 8.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v6...v8)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-21 22:20:37 +02:00
Michael Eischer
f091e6aed0 Merge branch 'patch-release' 2025-09-21 21:20:56 +02:00
Alexander Neumann
39a737fe14 Set development version for 0.18.1 2025-09-21 20:05:01 +02:00
Alexander Neumann
7d0aa7f2e3 Add version for 0.18.1 2025-09-21 20:04:58 +02:00
Alexander Neumann
18f18b7f99 Generate CHANGELOG.md for 0.18.1 2025-09-21 20:03:56 +02:00
Alexander Neumann
426b71e3e5 Prepare changelog for 0.18.1 2025-09-21 20:03:56 +02:00
Michael Eischer
4871390a81 Merge pull request #5514 from MichaelEischer/term-ui-helper
ui: collect Quote and Truncate helpers
2025-09-21 17:03:56 +02:00
Michael Eischer
65b21e3348 ui: collect Quote and Truncate helpers
Collect ui formatting helpers in the ui package
2025-09-21 16:44:23 +02:00
Michael Eischer
4a7b122fb6 Merge pull request #5510 from MichaelEischer/termstatus-everywhere-print-functions
Replace Printf/Verbosef/Warnf with termstatus
2025-09-21 16:42:29 +02:00
Michael Eischer
86ddee8518 ui: document Message / Printer / Terminal interfaces 2025-09-21 16:32:00 +02:00
Michael Eischer
2fe271980f backup: only pass error log function to helpers 2025-09-21 16:02:59 +02:00
Michael Eischer
4f1390436d init: remove duplication from error message 2025-09-21 15:58:29 +02:00
Michael Eischer
2d7611373e ignore JSON flag for fully unsupported commands
Considering the flag would result in a mostly empty terminal output,
which is probably worse than text output instead of JSON.
2025-09-21 15:38:29 +02:00
Michael Eischer
f71278138f drop warnf 2025-09-18 22:58:23 +02:00
Michael Eischer
7d5ebdd0b3 version: convert to termstatus 2025-09-18 22:58:23 +02:00
Michael Eischer
d6c75ba2dc prune: drop unused parameter 2025-09-17 21:18:15 +02:00
Michael Eischer
2a9105c050 forget/snapshots: properly change error returned by PrintSnapshots 2025-09-17 21:16:39 +02:00
Michael Eischer
b7bb697cf7 Merge pull request #5513 from restic/more-polish-changelogs
doc: Nitpicks on changelogs
2025-09-17 20:38:19 +02:00
Michael Eischer
b12a638322 Merge pull request #5509 from restic/polish-changelogs
slightly polish changelogs
2025-09-17 20:37:46 +02:00
Leo R. Lundgren
4e0135e628 doc: Nitpicks on changelogs 2025-09-17 18:26:21 +02:00
Adam Piggott
8e87a37df0 doc: mention value for pack size setting 2025-09-16 17:32:26 +01:00
greatroar
a8f506ea4d ui/progress: Simplify Updater
Removed a defer'd call that was a bit subtle.
2025-09-16 09:56:33 +02:00
greatroar
0a1ce4f207 ui/progress: Restore atomics in Counter
We switched from atomics to a mutex in #3189 because of an alignment
bug, but the new-style atomic types don't need manual alignment.
2025-09-16 09:49:48 +02:00
Michael Eischer
364271c6c3 Consistently use withTermstatus in tests 2025-09-15 22:37:55 +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
5a16b29177 remove unused global output functions 2025-09-15 22:35:48 +02:00
Michael Eischer
320fb5fb98 convert repository open/create to use termstatus 2025-09-15 22:35:32 +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
9d3efc2088 cleanup progress bar helpers 2025-09-15 22:34:44 +02:00
Michael Eischer
8b5dbc18ca cleanup progress bar creation special cases 2025-09-15 22:34:28 +02:00
Michael Eischer
b0eef4b965 Initialize progress printer as early as reasonable in run functions 2025-09-15 22:34:13 +02:00
Michael Eischer
6c0dccf4a5 self-update: convert to termstatus 2025-09-15 22:33:52 +02:00
Michael Eischer
6b23d0328b find: convert to termstatus 2025-09-15 22:33:41 +02:00
Michael Eischer
52f33d2d54 snapshots: convert to termstatus 2025-09-15 22:19:19 +02:00
Michael Eischer
d89535634d unlock: convert to termstatus 2025-09-15 22:19:19 +02:00
Michael Eischer
902cd1e9d6 backup: replace Verbosef usage 2025-09-15 22:19:19 +02:00
Michael Eischer
51299b8ea7 key: convert to termstatus 2025-09-15 22:19:19 +02:00
Michael Eischer
fd8f8d64f5 init: convert to termstatus 2025-09-15 22:19:17 +02:00
Michael Eischer
114cc33fe9 generate: convert to termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
44dbd4469e tag: replace global print functions with termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
d8f3e35730 prune: replace Print call with termstatus usage 2025-09-15 22:17:26 +02:00
Michael Eischer
333dbd18d8 list: convert to termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
0226e46681 cache: convert to termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
74fb43e0c2 dump: convert to termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
69186350fc diff: convert to termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
3e7aad8916 debug: convert to termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
c3912ae7bc cat: convert to termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
d3e26f2868 ls: convert to termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
2e91e81c83 mount: convert to termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
0dcd9bee88 rewrite: convert to termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
a304826b98 repair snapshots: convert to termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
8510f09225 stats: convert to termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
e63aee2ec6 copy: convert to use termstatus 2025-09-15 22:17:26 +02:00
Michael Eischer
94b19d64be termstatus: allow retrieving the underlying writer
This is intended for special cases where it must be guaranteed that the
output on stdout exactly matches what was written to the io.Writer.
2025-09-15 22:17:26 +02:00
Michael Eischer
03600ca509 termstatus: don't buffer stdout
There's not much use in doing so as nearly every write call was paired
with a flush call. Thus, just use an unbuffered writer.
2025-09-15 21:22:07 +02:00
Michael Eischer
ef9930cce4 fix capturing stdout with termstatus 2025-09-15 20:25:17 +02:00
Michael Eischer
91ecac8003 termstatus: fix crash when printing empty string 2025-09-15 20:25:17 +02:00
Michael Eischer
e9b6149303 list: cleanup parameter order of test helper 2025-09-15 20:25:17 +02:00
Michael Eischer
32b7168a9e centralize index progress bar for termstatus 2025-09-15 20:25:17 +02:00
Michael Eischer
6cdb9a75e6 consider JSON flag in newTerminalProgressPrinter 2025-09-15 20:25:17 +02:00
Michael Eischer
9ef8e13102 slightly polish changelogs 2025-09-15 19:52:24 +02:00
Michael Eischer
4940e330c0 Merge pull request #5508 from restic/patch-release-cherrypicks
Patch release cherrypicks
2025-09-15 19:51:51 +02:00
Michael Eischer
3a63430b07 extend changelog 2025-09-15 19:34:25 +02:00
Michael Eischer
a5e814bd8d check: fix error reporting on download retry 2025-09-15 19:34:25 +02:00
Michael Eischer
398862c5c8 docs: sync compatibility section with website
This is no change in policy, just a more precise description of the
status quo.
2025-09-15 19:33:39 +02:00
Michael Eischer
b47c67fd90 update dependencies 2025-09-15 19:33:20 +02:00
Michael Eischer
81fe559222 Merge pull request #5495 from MichaelEischer/fix-check-retries
check: fix error reporting on download retry
2025-09-15 19:31:44 +02:00
Michael Eischer
f21fd9d115 Merge pull request #5494 from MichaelEischer/fix-background-handling
Refactor terminal background handling
2025-09-13 22:48:11 +02:00
Michael Eischer
d757e39992 make linter happy 2025-09-13 22:22:53 +02:00
Srigovind Nayak
ce089f7e2d errors: standardize error wrapping for Fatal errors
* replace all occurences of  `errors.Fatal(err.Error())` with `errors.Fatalf("%s", err)` so that the error wrapping is correct across the codebase

* updated the review comments
2025-09-13 23:32:40 +05:30
Srigovind Nayak
576d35b37b changelog: add bugfix changelog for issue-5258 2025-09-13 23:32:40 +05:30
Srigovind Nayak
18b8f8870f tests: add tests for preserving underlying errors 2025-09-13 23:32:39 +05:30
Srigovind Nayak
79c41966af errors: enhance fatalError type to include underlying errors 2025-09-13 23:32:39 +05:30
Michael Eischer
c0a30e12b4 extend changelog 2025-09-08 11:54:29 +02:00
Michael Eischer
de29d74707 check: fix error reporting on download retry 2025-09-08 11:45:28 +02:00
Michael Eischer
424316e016 extend background handling changelog 2025-09-08 11:04:53 +02:00
Michael Eischer
b71b77fa77 terminal: unexport tcgetpgrp, tcsetpgrp and getpgrp 2025-09-08 11:04:38 +02:00
Michael Eischer
e7890d7b81 use standard line clearing in printProgress 2025-09-08 11:04:24 +02:00
Michael Eischer
529baf50f8 simplify message printing when restic receives signal 2025-09-08 11:04:11 +02:00
Michael Eischer
d10bd1d321 terminal: move reading password from terminal here 2025-09-08 11:03:56 +02:00
Michael Eischer
43b5166de8 terminal: cleanup determining width 2025-09-08 11:03:42 +02:00
Michael Eischer
0b0dd07f15 consolidate checks whether stdin/stdout is terminal 2025-09-08 11:03:26 +02:00
Michael Eischer
93ccc548c8 termstatus: move cursor handling to terminal package 2025-09-08 11:03:17 +02:00
Michael Eischer
0ab38faa2e termstatus: track current status also in background
Without this, restic could temporarily print an outdated status when
moving back into the foreground.
2025-09-08 10:50:53 +02:00
Michael Eischer
48cbbf9651 ui/termstatus: extract background handling code 2025-09-08 10:50:09 +02:00
Michael Eischer
6ff7cd9050 backend/util: extract background handling code 2025-09-08 10:42:35 +02:00
Michael Eischer
cc1fe6c111 Merge pull request #5493 from greatroar/ioctl
backend,termstatus: Unify foreground/background detection
2025-09-08 10:40:36 +02:00
greatroar
1ed93bd54d backend,termstatus: Unify foreground/background detection
PR #5358 reintroduced a version of the TIOCGPGRP ioctl call that works
on all Unix platforms except Linux, due to a bug/inconsistency in
x/sys/unix. This commit fixes that by introducing termstatus.Tcgetpgrp.

It also introduces termstatus.Getpgrp and termstatus.Tcsetpgrp to deal
with the different signature of unix.Getpgrp in Solaris vs. all other
Unix platforms and an int-overflowing constant on AIX, so that some
AIX/Solaris-specific code can be removed elsewhere and
foreground/background detection is done the same everywhere except on
Windows.
2025-09-08 09:33:44 +02:00
Michael Eischer
c55df65bb6 Merge pull request #5490 from MichaelEischer/sync-compatibility-section
docs: sync compatibility section with website
2025-09-07 11:35:48 +02:00
Michael Eischer
289adebbb7 Merge pull request #5492 from MichaelEischer/update-dependencies
update dependencies
2025-09-07 11:34:37 +02:00
Michael Eischer
eef047cfa4 update dependencies 2025-09-06 22:58:30 +02:00
Michael Eischer
6d7e37edce Merge pull request #5491 from MichaelEischer/patch-release-cherrypicks
Patch release cherrypicks
2025-09-06 22:32:40 +02:00
dependabot[bot]
4998fd68a7 build(deps): bump docker/login-action from 3.4.0 to 3.5.0
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.4.0 to 3.5.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](74a5d14239...184bdaa072)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 3.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-06 22:07:22 +02:00
greatroar
06cc6017b8 internal/restic: Fix panic in ParseDuration
Fixes #5485. Includes test case by @MichaelEischer.
2025-09-06 22:03:12 +02:00
gregoster
37851827c5 EOPNOTSUPP can be returned if the filesystem does not support xattrs (#5344)
---------

Co-authored-by: Greg Oster <oster@netbsd.org>
2025-09-06 22:03:12 +02:00
Michael Eischer
b75f80ae5f backup: fix test on windows 2025-09-06 22:02:50 +02:00
Michael Eischer
31f87b6188 add changelog 2025-09-06 22:02:50 +02:00
Michael Eischer
b67b88a0c0 backup: test that parent directory errors can be correctly filtered 2025-09-06 22:02:50 +02:00
Michael Eischer
d57b01d6eb backup: test that missing parent directory is correctly handled 2025-09-06 22:02:50 +02:00
Michael Eischer
fc81df3f54 backup: do not fail backup is some parent folder is inaccessible
Handle errors for parent directories of backup directories in the same
way as all other file access errors during a backup.
2025-09-06 22:02:50 +02:00
Michael Eischer
73995b818a backup: do not crash if nodeFromFileInfo fails
this could crash in two cases:
- if a directory is deleted between restic stating it and trying to list
  its directory content.
- when restic tries to list the parent directory of a backup target, but
  the parent directory has been deleted.

return an error in this case instead.
2025-09-06 22:02:50 +02:00
Michael Eischer
49abea6952 add changelog 2025-09-06 21:59:54 +02:00
Dominik Schulz
f18b8ad425 Mark HTTP Error 507 as permanent
This change classifies HTTP error 507 (Insufficient Storage) as a
permanent error that should not be retried. I keep running into
this once in a while and there is literally no point in retrying when
the server is full.

Fixes #5429

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
2025-09-06 21:59:54 +02:00
dependabot[bot]
0a6296bfde build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
Bumps [github.com/Azure/azure-sdk-for-go/sdk/storage/azblob](https://github.com/Azure/azure-sdk-for-go) from 1.6.1 to 1.6.2.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/go-mgmt-sdk-release-guideline.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.6.1...sdk/storage/azblob/v1.6.2)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
  dependency-version: 1.6.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-06 21:59:54 +02:00
dependabot[bot]
2403d1f139 build(deps): bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-06 21:59:54 +02:00
dependabot[bot]
86a453200a build(deps): bump google.golang.org/api from 0.228.0 to 0.248.0
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.228.0 to 0.248.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.228.0...v0.248.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-version: 0.248.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-06 21:59:54 +02:00
dependabot[bot]
518fbbcdc2 build(deps): bump golang.org/x/crypto from 0.39.0 to 0.41.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.39.0 to 0.41.0.
- [Commits](https://github.com/golang/crypto/compare/v0.39.0...v0.41.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.41.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-06 21:59:54 +02:00
y0n3d4
c62f523e6d Update 020_installation.rst removing command options
Removed command options: their use is a user choice
2025-09-06 21:59:11 +02:00
Michele Testa
91e9f65991 Update 020_installation.rst adding instruction for Gentoo Linux 2025-09-06 21:59:11 +02:00
rhhub
d839850ed4 docs: clarify ** must me between path separators 2025-09-06 21:59:11 +02:00
A Crutcher
ac051c3dcd doc: Correct Wasabi link 2025-09-06 21:59:11 +02:00
Michael Terry
20f472a67f backend/local: ignore chmod "not supported" errors 2025-09-06 21:59:11 +02:00
dependabot[bot]
7b986795de build(deps): bump golang.org/x/time from 0.11.0 to 0.12.0
Bumps [golang.org/x/time](https://github.com/golang/time) from 0.11.0 to 0.12.0.
- [Commits](https://github.com/golang/time/compare/v0.11.0...v0.12.0)

---
updated-dependencies:
- dependency-name: golang.org/x/time
  dependency-version: 0.12.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-06 21:59:11 +02:00
dependabot[bot]
4f03e03b2c build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity
Bumps [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) from 1.10.0 to 1.10.1.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/go-mgmt-sdk-release-guideline.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.10.0...sdk/azidentity/v1.10.1)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
  dependency-version: 1.10.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-06 21:59:11 +02:00
Michael Eischer
242b607bf6 walker: fix error handling if tree cannot be loaded
A tree that cannot be loaded is a fatal error when walking the tree.
Thus, return the error and exit the tree walk.
2025-09-06 21:59:11 +02:00
Michael Eischer
22bbbf42f5 Fix release note typos 2025-09-06 21:59:11 +02:00
dependabot[bot]
3c8fc9d9bc build(deps): bump github.com/peterbourgon/unixtransport
Bumps [github.com/peterbourgon/unixtransport](https://github.com/peterbourgon/unixtransport) from 0.0.4 to 0.0.6.
- [Release notes](https://github.com/peterbourgon/unixtransport/releases)
- [Commits](https://github.com/peterbourgon/unixtransport/compare/v0.0.4...v0.0.6)

---
updated-dependencies:
- dependency-name: github.com/peterbourgon/unixtransport
  dependency-version: 0.0.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-06 21:59:11 +02:00
dependabot[bot]
5070e62b18 build(deps): bump golang.org/x/crypto from 0.38.0 to 0.39.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.38.0 to 0.39.0.
- [Commits](https://github.com/golang/crypto/compare/v0.38.0...v0.39.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.39.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-06 21:59:11 +02:00
Patrick Wolf
d64bad1a90 Update 047_tuning_backup_parameters.rst - local backend (#5355)
users would find it helpful to know how to adjust the "local" backend and they might not get the idea that the local backend is just called local... which in turn leads them to think restic is slow as they can't adjust away  from 2 threads for restore and backup.
2025-09-06 21:54:41 +02:00
Michael Eischer
6bdca9a7d5 add changelog for --stdin-filename with/directory 2025-09-06 21:54:41 +02:00
Michael Eischer
91d582a667 backup: test subdirectories in stdin filenames work 2025-09-06 21:54:41 +02:00
Michael Eischer
ef1e137e7a fs/reader: return proper error on invalid filename 2025-09-06 21:54:41 +02:00
Michael Eischer
81ac49f59d fs/reader: test file not exist case 2025-09-06 21:54:41 +02:00
Michael Eischer
ba2b0b2cc7 fs/reader: use test helpers 2025-09-06 21:54:41 +02:00
Michael Eischer
37a4235e4d fs/reader: deduplicate test code 2025-09-06 21:54:41 +02:00
Michael Eischer
04898e41d1 fs/reader: fix open+stat handling 2025-09-06 21:54:41 +02:00
Michael Eischer
07e4a78e46 fs/reader: use modification time for file and directories
This ensures that a fixed input generates a fully deterministic output
file structure.
2025-09-06 21:54:41 +02:00
Michael Eischer
236f81758e fs: rewrite Reader to build fs tree up front
This adds proper support for filenames that include directories. For
example, `/foo/bar` would result in an error when trying to open `/foo`.

The directory tree is now build upfront. This ensures let's the
directory tree construction be handled only once. All accessors then
only have to look up the constructed directory entries.
2025-09-06 21:54:41 +02:00
Ilya Grigoriev
16850c61fa docs: when describing profiling, briefly explain .pprof files 2025-09-06 21:52:57 +02:00
Ilya Grigoriev
67a572fa0d docs: document profiling options a bit better
Previously, the docs were a bit mysterious about what "enables profiling
support" means or how one could take advantage of it.
2025-09-06 21:52:57 +02:00
Ilya Grigoriev
4686a12a2d bugfix: have --{cpu,mem,...}-profile work even if Restic exits with error code (#5373)
* bugfix: write pprof file for `--{cpu,mem,...}-profile` even on error code

Before this, if `restic backup --cpu-profile dir/ backup-dir/` couldn't
read some of the input files (e.g. they weren't readable by the user
restic was running under), the `cpu.pprof` file it outputs would be
empty.

https://github.com/spf13/cobra/issues/1893

* drop changelog as it's not relevant for end users

---------

Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2025-09-06 21:52:57 +02:00
dependabot[bot]
4dbed5f905 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
Bumps [github.com/Azure/azure-sdk-for-go/sdk/storage/azblob](https://github.com/Azure/azure-sdk-for-go) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.6.0...sdk/azcore/v1.6.1)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
  dependency-version: 1.6.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-06 21:52:57 +02:00
dependabot[bot]
d708c5ea73 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity
Bumps [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) from 1.8.2 to 1.10.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/go-mgmt-sdk-release-guideline.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azidentity/v1.8.2...sdk/azcore/v1.10.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
  dependency-version: 1.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-06 21:52:57 +02:00
Mark Lopez
ee0cb7d1aa docs: updated installation docs for Windows 2025-09-06 21:52:57 +02:00
dependabot[bot]
590dc82719 build(deps): bump golang.org/x/sys from 0.31.0 to 0.33.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.31.0 to 0.33.0.
- [Commits](https://github.com/golang/sys/compare/v0.31.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-06 21:52:57 +02:00
Samuel Chambers
72d70d94f9 updated doc/faq.rst_commitsSquashed 2025-09-06 21:52:57 +02:00
Markus Hansmair
aaa48e765a doc: typo & minor rewording in 'Removing files from snapshots' 2025-09-06 21:50:54 +02:00
Michael Eischer
f61cf4a1e5 docs: fix typos in developer information (#5329) 2025-09-06 21:50:54 +02:00
Michael Eischer
a22b9d5735 update direct dependencies (#5340) 2025-09-06 21:50:54 +02:00
dependabot[bot]
e9ae67c968 build(deps): bump docker/login-action from 3.3.0 to 3.4.0 (#5333)
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](9780b0c442...74a5d14239)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 3.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-06 21:50:54 +02:00
Mohammad Javad Naderi
1fe6fbc4b8 doc: fix typos 2025-09-06 21:50:54 +02:00
Gilbert Gilb's
3d4fb876f4 docs: fix unit for S3 restore timeout
"d" is not a valid unit.
2025-09-06 21:50:54 +02:00
Michael Eischer
5d182ed1ab forget: fix ignored RESTIC_HOST environment variable 2025-09-06 21:50:54 +02:00
Michael Eischer
7f1ac5764a Merge pull request #5358 from MichaelEischer/fix-tty-capture-in-background
Fix tty capture when started in background
2025-09-06 21:01:03 +02:00
Michael Eischer
52aa1cd17f docs: sync compatibility section with website
This is no change in policy, just a more precise description of the
status quo.
2025-09-06 20:55:48 +02:00
Michael Eischer
42f690dbab add changelog 2025-09-06 20:50:06 +02:00
Michael Eischer
914bd699be backend: always start backend process in separate process group
The process group is necessary to properly handle ctrl-c.
2025-09-06 19:51:10 +02:00
Michael Eischer
4c19d6410f backend: only move child process to foreground if already in foreground
The rclone and sftp backends require starting a child process. The are
first moved into the foreground and back into the background after the
initial startup is done.

However, this behavior is also active if restic itself is started in the
background. In this case, restic changing the foreground process may
confuse the shell and in case of bash causes it to exit. Thus, disable
modification of the controlling process group of the tty if restic is
run in the background.
2025-09-06 19:51:10 +02:00
Michael Eischer
2ad703bfd8 Merge pull request #5486 from greatroar/duration-panic
Avoid panic in duration parsing
2025-09-06 18:32:36 +02:00
greatroar
0864d04c5c internal/restic: Fix panic in ParseDuration
Fixes #5485. Includes test case by @MichaelEischer.
2025-09-06 10:30:34 +02:00
gregoster
839c38b4c4 EOPNOTSUPP can be returned if the filesystem does not support xattrs (#5344)
---------

Co-authored-by: Greg Oster <oster@netbsd.org>
2025-09-05 19:09:27 +00:00
Michael Eischer
e98c44baaf Merge pull request #5421 from MichaelEischer/fix-backup-metadata-crash
backup: fix possible crash if directory disappears before metadata collection
2025-09-05 19:53:16 +02:00
Michael Eischer
01bc60e96f backup: fix test on windows 2025-09-05 19:35:25 +02:00
Michael Eischer
484b706dd8 add changelog 2025-09-05 19:28:18 +02:00
Michael Eischer
350f6452e7 backup: test that parent directory errors can be correctly filtered 2025-09-05 19:28:18 +02:00
Michael Eischer
484cdf12e5 backup: test that missing parent directory is correctly handled 2025-09-05 19:28:18 +02:00
Michael Eischer
c8bb7bd312 backup: do not fail backup is some parent folder is inaccessible
Handle errors for parent directories of backup directories in the same
way as all other file access errors during a backup.
2025-09-05 19:28:18 +02:00
Michael Eischer
a8ce2e45cc backup: do not crash if nodeFromFileInfo fails
this could crash in two cases:
- if a directory is deleted between restic stating it and trying to list
  its directory content.
- when restic tries to list the parent directory of a backup target, but
  the parent directory has been deleted.

return an error in this case instead.
2025-09-05 19:28:18 +02:00
Michael Eischer
275507fb3e Merge pull request #5452 from dominikschulz/fix/storage
Mark HTTP Error 507 as permanent
2025-09-05 19:17:15 +02:00
Michael Eischer
391c27975a Merge pull request #5460 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob-1.6.2
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob from 1.6.1 to 1.6.2
2025-09-05 19:16:54 +02:00
Michael Eischer
7d47e60e27 Merge pull request #5481 from restic/dependabot/github_actions/actions/checkout-5
build(deps): bump actions/checkout from 4 to 5
2025-09-05 19:07:58 +02:00
Michael Eischer
5c17c277f3 add changelog 2025-09-05 19:07:09 +02:00
Dominik Schulz
48e5c0984e Mark HTTP Error 507 as permanent
This change classifies HTTP error 507 (Insufficient Storage) as a
permanent error that should not be retried. I keep running into
this once in a while and there is literally no point in retrying when
the server is full.

Fixes #5429

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
2025-09-05 19:04:16 +02:00
dependabot[bot]
2414771a59 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
Bumps [github.com/Azure/azure-sdk-for-go/sdk/storage/azblob](https://github.com/Azure/azure-sdk-for-go) from 1.6.1 to 1.6.2.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/go-mgmt-sdk-release-guideline.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.6.1...sdk/storage/azblob/v1.6.2)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
  dependency-version: 1.6.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-05 16:58:21 +00:00
Michael Eischer
0e381bdbf1 Merge pull request #5483 from restic/dependabot/go_modules/google.golang.org/api-0.248.0
build(deps): bump google.golang.org/api from 0.228.0 to 0.248.0
2025-09-05 18:47:58 +02:00
dependabot[bot]
11cd4a0a88 build(deps): bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-05 16:38:46 +00:00
dependabot[bot]
f54989f634 build(deps): bump google.golang.org/api from 0.228.0 to 0.248.0
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.228.0 to 0.248.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.228.0...v0.248.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-version: 0.248.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-05 16:36:17 +00:00
Michael Eischer
af7f10d16b Merge pull request #5482 from restic/dependabot/github_actions/docker/login-action-3.5.0
build(deps): bump docker/login-action from 3.4.0 to 3.5.0
2025-09-05 18:35:59 +02:00
Michael Eischer
6de95a3d58 Merge pull request #5484 from restic/dependabot/go_modules/golang.org/x/crypto-0.41.0
build(deps): bump golang.org/x/crypto from 0.39.0 to 0.41.0
2025-09-05 18:35:24 +02:00
dependabot[bot]
93f436e999 build(deps): bump golang.org/x/crypto from 0.39.0 to 0.41.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.39.0 to 0.41.0.
- [Commits](https://github.com/golang/crypto/compare/v0.39.0...v0.41.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.41.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-01 02:10:03 +00:00
dependabot[bot]
6edb199efd build(deps): bump docker/login-action from 3.4.0 to 3.5.0
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.4.0 to 3.5.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](74a5d14239...184bdaa072)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 3.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-01 01:57:28 +00:00
rawtaz
9b2c0a0c54 Merge pull request #5466 from y0n3d4/gentoo-install-info
Added Gentoo install info
2025-08-07 13:28:17 +02:00
y0n3d4
64273ea027 Update 020_installation.rst removing command options
Removed command options: their use is a user choice
2025-08-06 13:57:29 +02:00
Michele Testa
5a00d26431 Update 020_installation.rst adding instruction for Gentoo Linux 2025-08-05 15:16:37 +02:00
Michele Testa
3faad5751d Revert "Update 020_installation.rst adding install command for Gentoo Linux"
This reverts commit f487eb1c66.
2025-08-05 14:12:04 +02:00
y0n3d4
f487eb1c66 Update 020_installation.rst adding install command for Gentoo Linux
Added basic instructions for restic installation on Gentoo using the official package manager (Portage)
2025-08-05 14:01:10 +02:00
Michael Eischer
72636238d0 Merge pull request #5400 from rhhub/patch-2
docs: clarify ** wildcard must me between path separators
2025-08-04 20:56:07 +02:00
rawtaz
51098157e2 Merge pull request #5462 from TheAlchemistOf42/wasabi-link
Correct Wasabi link
2025-08-02 22:12:57 +02:00
A Crutcher
0b080c44d7 doc: Correct Wasabi link 2025-08-02 13:03:43 -05:00
Michael Eischer
b71fe91643 Merge pull request #5345 from mikix/chmod-enotsup
backend/local: ignore chmod "not supported" errors
2025-07-21 22:28:53 +02:00
Michael Eischer
9c3b8d171a Merge pull request #5434 from restic/dependabot/go_modules/golang.org/x/time-0.12.0
build(deps): bump golang.org/x/time from 0.11.0 to 0.12.0
2025-07-21 22:17:40 +02:00
Michael Eischer
ddb7fb837b Merge pull request #5435 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/azidentity-1.10.1
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity from 1.10.0 to 1.10.1
2025-07-21 22:14:29 +02:00
Michael Eischer
3433c5abac Merge pull request #5408 from MichaelEischer/fix-walker-crash
walker: fix error handling if tree cannot be loaded
2025-07-21 21:46:59 +02:00
dependabot[bot]
09bc58c950 build(deps): bump golang.org/x/time from 0.11.0 to 0.12.0
Bumps [golang.org/x/time](https://github.com/golang/time) from 0.11.0 to 0.12.0.
- [Commits](https://github.com/golang/time/compare/v0.11.0...v0.12.0)

---
updated-dependencies:
- dependency-name: golang.org/x/time
  dependency-version: 0.12.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-21 19:46:35 +00:00
Michael Eischer
20eb9018a0 Merge pull request #5409 from MichaelEischer/fix-release-notes-typos
Fix release note typos
2025-07-21 21:46:05 +02:00
Michael Eischer
651f553530 Merge pull request #5436 from restic/dependabot/go_modules/github.com/peterbourgon/unixtransport-0.0.6
build(deps): bump github.com/peterbourgon/unixtransport from 0.0.4 to 0.0.6
2025-07-21 21:45:06 +02:00
Michael Eischer
aad4b53ead Merge pull request #5438 from restic/dependabot/go_modules/golang.org/x/crypto-0.39.0
build(deps): bump golang.org/x/crypto from 0.38.0 to 0.39.0
2025-07-21 21:42:06 +02:00
greatroar
f7f6459eb9 internal/restic: Simplify ParallelRemove 2025-07-19 12:55:40 +02:00
greatroar
95a36b55f4 internal/dump: Clarify writeNode concurrency 2025-07-19 12:54:41 +02:00
greatroar
2c39b1f84f internal/repository/index: Simplify MasterIndex concurrency 2025-07-18 15:06:37 +02:00
dependabot[bot]
e467496ace build(deps): bump golang.org/x/crypto from 0.38.0 to 0.39.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.38.0 to 0.39.0.
- [Commits](https://github.com/golang/crypto/compare/v0.38.0...v0.39.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.39.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-01 05:46:21 +00:00
dependabot[bot]
f2de260524 build(deps): bump github.com/peterbourgon/unixtransport
Bumps [github.com/peterbourgon/unixtransport](https://github.com/peterbourgon/unixtransport) from 0.0.4 to 0.0.6.
- [Release notes](https://github.com/peterbourgon/unixtransport/releases)
- [Commits](https://github.com/peterbourgon/unixtransport/compare/v0.0.4...v0.0.6)

---
updated-dependencies:
- dependency-name: github.com/peterbourgon/unixtransport
  dependency-version: 0.0.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-01 05:07:50 +00:00
dependabot[bot]
c17d5ab2e1 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity
Bumps [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) from 1.10.0 to 1.10.1.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/go-mgmt-sdk-release-guideline.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.10.0...sdk/azidentity/v1.10.1)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
  dependency-version: 1.10.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-01 05:07:41 +00:00
Michael Terry
a8535aba58 backend/local: ignore chmod "not supported" errors 2025-06-02 17:44:30 -04:00
rhhub
521fbad701 docs: clarify ** must me between path separators 2025-06-02 13:46:06 -07:00
Michael Eischer
15b7d7c3fc Fix release note typos 2025-06-02 21:12:37 +02:00
Patrick Wolf
7d39b1bfe8 Update 047_tuning_backup_parameters.rst - local backend (#5355)
users would find it helpful to know how to adjust the "local" backend and they might not get the idea that the local backend is just called local... which in turn leads them to think restic is slow as they can't adjust away  from 2 threads for restore and backup.
2025-06-02 18:40:04 +00:00
Michael Eischer
e4a7f4aadf Merge pull request #5356 from MichaelEischer/fix-backup-stdin-filename
backup: Fix `--stdin-filename` with directory
2025-06-02 20:27:26 +02:00
Michael Eischer
10cfe96cd4 walker: fix error handling if tree cannot be loaded
A tree that cannot be loaded is a fatal error when walking the tree.
Thus, return the error and exit the tree walk.
2025-06-02 20:04:26 +02:00
Michael Eischer
2eaa79d33f Merge pull request #5374 from ilyagr/docprofile
docs: document profiling options a bit better
2025-06-02 19:57:33 +02:00
Ilya Grigoriev
99ee5696f3 bugfix: have --{cpu,mem,...}-profile work even if Restic exits with error code (#5373)
* bugfix: write pprof file for `--{cpu,mem,...}-profile` even on error code

Before this, if `restic backup --cpu-profile dir/ backup-dir/` couldn't
read some of the input files (e.g. they weren't readable by the user
restic was running under), the `cpu.pprof` file it outputs would be
empty.

https://github.com/spf13/cobra/issues/1893

* drop changelog as it's not relevant for end users

---------

Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2025-06-02 17:57:07 +00:00
Ilya Grigoriev
e8dbb69a94 docs: when describing profiling, briefly explain .pprof files 2025-06-02 19:49:19 +02:00
Ilya Grigoriev
f4e21cdb75 docs: document profiling options a bit better
Previously, the docs were a bit mysterious about what "enables profiling
support" means or how one could take advantage of it.
2025-06-02 19:49:19 +02:00
Michael Eischer
e5bdc3c74f Merge pull request #5382 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob-1.6.1
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob from 1.6.0 to 1.6.1
2025-06-02 19:40:33 +02:00
Michael Eischer
7e51c928c4 Merge pull request #5384 from zmanda/feat-gh-5377-check-add-percentage-for-read-data-subset
check: add percentage of repository checked
2025-06-02 19:37:08 +02:00
dependabot[bot]
21e87851aa build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
Bumps [github.com/Azure/azure-sdk-for-go/sdk/storage/azblob](https://github.com/Azure/azure-sdk-for-go) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.6.0...sdk/azcore/v1.6.1)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
  dependency-version: 1.6.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-02 17:32:18 +00:00
Michael Eischer
2bc1bf2702 Merge pull request #5402 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/azidentity-1.10.0
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity from 1.8.2 to 1.10.0
2025-06-02 19:19:10 +02:00
dependabot[bot]
df110060d1 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity
Bumps [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) from 1.8.2 to 1.10.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/go-mgmt-sdk-release-guideline.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azidentity/v1.8.2...sdk/azcore/v1.10.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
  dependency-version: 1.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-02 16:45:38 +00:00
Michael Eischer
337a7d1205 Merge pull request #5385 from Silvenga/windows-docs
docs: updated installation docs for Windows
2025-06-02 18:44:43 +02:00
Michael Eischer
322e271dd2 Merge pull request #5404 from restic/dependabot/go_modules/golang.org/x/sys-0.33.0
build(deps): bump golang.org/x/sys from 0.31.0 to 0.33.0
2025-06-02 18:35:34 +02:00
dependabot[bot]
1ac224458f build(deps): bump golang.org/x/sys from 0.31.0 to 0.33.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.31.0 to 0.33.0.
- [Commits](https://github.com/golang/sys/compare/v0.31.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-01 01:25:20 +00:00
rawtaz
126ad04568 Merge pull request #5389 from fronesis47/patch-3
Update passwords section of FAQ
2025-05-11 20:35:20 +02:00
Samuel Chambers
e732bdbfb8 updated doc/faq.rst_commitsSquashed 2025-05-11 14:02:07 -04:00
Mark Lopez
2db08fd749 docs: updated installation docs for Windows 2025-05-03 10:27:50 -05:00
Srigovind Nayak
debb110a7c check: add percentage of repository checked 2025-05-03 18:08:12 +05:30
rawtaz
5eb4f5af61 Merge pull request #5360 from makuhama/master
doc: typo & minor rewording in 'Removing files from snapshots'
2025-05-02 01:05:08 +02:00
Markus Hansmair
287b601f01 doc: typo & minor rewording in 'Removing files from snapshots' 2025-04-16 09:37:26 +02:00
Michael Eischer
64c82a5d9c Merge pull request #5357 from Hello71/patch-1
doc: add fastest, better compression
2025-04-14 20:02:41 +02:00
Alex Xu
12f36ebf07 doc: add fastest, better compression
Follow-up for #5321
2025-04-13 19:33:13 -04:00
Michael Eischer
45e09dca2a add changelog for --stdin-filename with/directory 2025-04-11 22:29:18 +02:00
Michael Eischer
5bb9d0d996 backup: test subdirectories in stdin filenames work 2025-04-11 22:14:32 +02:00
Michael Eischer
9f39e8a1d3 fs/reader: return proper error on invalid filename 2025-04-11 22:07:31 +02:00
Michael Eischer
ddd48f1e98 fs/reader: test file not exist case 2025-04-11 21:57:45 +02:00
Michael Eischer
6e91ea3397 fs/reader: use test helpers 2025-04-11 21:54:15 +02:00
Michael Eischer
e7c1e4f1ff fs/reader: deduplicate test code 2025-04-11 21:50:47 +02:00
Michael Eischer
70e1037a49 fs/reader: fix open+stat handling 2025-04-11 21:49:25 +02:00
Michael Eischer
19f48084ea fs/reader: use modification time for file and directories
This ensures that a fixed input generates a fully deterministic output
file structure.
2025-04-11 21:46:24 +02:00
Michael Eischer
3a995172b7 fs: rewrite Reader to build fs tree up front
This adds proper support for filenames that include directories. For
example, `/foo/bar` would result in an error when trying to open `/foo`.

The directory tree is now build upfront. This ensures let's the
directory tree construction be handled only once. All accessors then
only have to look up the constructed directory entries.
2025-04-11 21:37:40 +02:00
Michael Eischer
0dffa1208d Merge pull request #5243 from zmanda/feat-gh-4868-show-repo-id-in-df-and-mount
mount: append the repository ID to the name of the FUSE mount
2025-04-02 21:16:11 +02:00
Michael Eischer
6fbcce1d1a docs: fix typos in developer information (#5329) 2025-04-02 21:12:43 +02:00
Michael Eischer
e8d458be7e update direct dependencies (#5340) 2025-04-02 21:10:40 +02:00
dependabot[bot]
4471c7847b build(deps): bump docker/login-action from 3.3.0 to 3.4.0 (#5333)
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](9780b0c442...74a5d14239)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 3.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-02 20:54:17 +02:00
Srigovind Nayak
f13e9c10a4 Add support for additional compression levels fastest and better (#5321)
* repository: expose addtional compression levels

* adding better and fastest compression levels for zstd

* repository: add changelog entry for issue-4728

* chore: fix golint issues

* chore: sort compression modes in the help text

* updating review comments
2025-03-31 21:21:12 +02:00
Michael Eischer
f768683162 Merge pull request #5322 from zmanda/fix-gh-5233-forget-failure-exit-codes
forget: return exit code 3 on partial removal of snapshots
2025-03-31 20:08:33 +02:00
Michael Eischer
0b7bdfed7e Merge pull request #5320 from mjnaderi/patch-1
doc: fix typos
2025-03-31 20:07:51 +02:00
Michael Eischer
a4fe94ec82 Merge pull request #5317 from gilbsgilbs/fix-s3-restore-timeout-unit
docs: fix unit for S3 restore timeout
2025-03-31 20:01:22 +02:00
Michael Eischer
6684d1d2f5 Merge pull request #5327 from MichaelEischer/fix-forget-hostname-default
forget: fix ignored RESTIC_HOST environment variable
2025-03-31 19:21:13 +02:00
Michael Eischer
e1f7522174 forget: fix ignored RESTIC_HOST environment variable 2025-03-31 18:10:17 +02:00
Srigovind Nayak
d1649affb2 chore: update changelog for issue-5233 2025-03-30 14:12:06 +05:30
Srigovind Nayak
936c783c0f forget: exit code 3 for snapshot removal failures 2025-03-30 14:11:32 +05:30
Mohammad Javad Naderi
5614cf4758 doc: fix typos 2025-03-29 12:40:47 +03:30
Srigovind Nayak
6db0d84ab0 changelog: add changelog entry for issue-4868 2025-03-29 13:27:50 +05:30
Srigovind Nayak
88b599c4f3 mount: append repository ID to FS name of FUSE mount
* update review comments

mount: append repository ID to FS name of the FUSE mount
2025-03-29 13:22:10 +05:30
Gilbert Gilb's
eefff0d793 docs: fix unit for S3 restore timeout
"d" is not a valid unit.
2025-03-27 21:20:50 +01:00
Alexander Neumann
3d14e92905 Set development version for 0.18.0 2025-03-27 20:17:36 +01:00
Alexander Neumann
d401ad6c1e Add version for 0.18.0 2025-03-27 20:16:56 +01:00
Alexander Neumann
ab024e6a51 Update manpages and auto-completion 2025-03-27 20:16:56 +01:00
Alexander Neumann
0e5f41c842 Generate CHANGELOG.md for 0.18.0 2025-03-27 20:16:25 +01:00
Alexander Neumann
321ac6c1c9 Prepare changelog for 0.18.0 2025-03-27 20:16:25 +01:00
Michael Eischer
94b1af580b Merge pull request #5316 from MichaelEischer/fix-docs
docs: SLSA is only setup for GHCR
2025-03-26 19:18:15 +01:00
Michael Eischer
cc6fbbe6ad Merge pull request #5315 from MichaelEischer/proper-feature-flag-deprecation
Readd feature flags removed too soon
2025-03-26 19:17:17 +01:00
Michael Eischer
3f70485671 docs: SLSA is only setup for GHCR 2025-03-26 18:46:52 +01:00
Michael Eischer
d4772aa469 readd feature flags removed too soon 2025-03-26 18:38:30 +01:00
Michael Eischer
13cb90b83a Merge pull request #5295 from MichaelEischer/randomize-pack-order
Randomize blob to pack file assignment
2025-03-25 18:13:49 +01:00
Michael Eischer
823cc3d93a Polish changelogs (#5308)
* polish changelogs

* Additional changelog polishing

* fix test failure

* Correct changelog for recover command

---------

Co-authored-by: Leo R. Lundgren <leo@finalresort.org>
2025-03-25 18:12:51 +01:00
Michael Eischer
9eee32131a Merge pull request #5307 from Martin2112/dial_tls
Replace deprecated DialTLS with DialTLSContext.
2025-03-25 18:12:10 +01:00
Michael Eischer
5e519a25f7 tweak changelog
Co-authored-by: rawtaz <rawtaz@users.noreply.github.com>
2025-03-24 19:44:13 +01:00
Michael Eischer
c4eb2be31f Merge pull request #5304 from restic/disable-gs-grpc-api
backend/gs: disable GRPC API to reduce binary size bloat
2025-03-24 19:03:09 +01:00
Michael Eischer
0b22d8dc64 Merge pull request #5306 from MichaelEischer/sftp-better-errors
sftp: improve error messages
2025-03-24 18:43:47 +01:00
Michael Eischer
2b65ef5710 backend/gs: disable GRPC API to reduce binary size bloat
Since cloud.google.com/go/storage v1.44.0 the GRPC API is enabled by
default. However, this causes the restic binary size to explode by 20MB.
So just disable it again.
2025-03-24 18:41:45 +01:00
Michael Eischer
ccb92f5bf0 repository/packer: add unit test for Merge method 2025-03-24 17:04:02 +01:00
Michael Eischer
37aa4f824f add changelog and update threat model 2025-03-24 17:03:43 +01:00
Martin Smith
47b048f437 Rename param as it looks like context isn't used. 2025-03-24 15:01:47 +00:00
Martin Smith
cd7f384d77 Replace deprecated DialTLS with DialTLSContext. 2025-03-24 14:05:13 +00:00
Michael Eischer
9d58a27428 Merge pull request #5298 from Martin2112/lock_by_value
Fix lock pass by value and handle error from Release().
2025-03-24 14:42:38 +01:00
Michael Eischer
9aad8e9ea5 Merge pull request #5299 from Martin2112/go_cleanup
A few more small cleanups that should not change behaviour.
2025-03-24 13:59:39 +01:00
Michael Eischer
3adf7d4efb backend/sftp: wrap further errors 2025-03-24 12:45:15 +01:00
Michael Eischer
66ec735ac2 backend/sftp: include file path in error messages 2025-03-24 12:44:42 +01:00
Michael Eischer
63a71f70e3 backend/sftp: ensure all errors are wrapped with the method name 2025-03-24 12:32:52 +01:00
Michael Eischer
e3ddc8a463 Merge pull request #5305 from restic/dependabot/go_modules/github.com/golang-jwt/jwt/v5-5.2.2
build(deps): bump github.com/golang-jwt/jwt/v5 from 5.2.1 to 5.2.2
2025-03-24 11:23:42 +01:00
Michael Eischer
66a8e897a9 Merge pull request #5300 from MichaelEischer/fix-output-race
ui/termstatus: fix race condition in StdioWrapper
2025-03-24 11:17:14 +01:00
Michael Eischer
ffd63f893a Merge pull request #5296 from MichaelEischer/reindex-before-recover
recover: reindex before reassembling snapshot
2025-03-24 11:16:38 +01:00
Michael Eischer
ec19d67512 ui/termstatus: fix race condition in StdioWrapper 2025-03-24 11:07:15 +01:00
dependabot[bot]
ef18feaeeb build(deps): bump github.com/golang-jwt/jwt/v5 from 5.2.1 to 5.2.2
Bumps [github.com/golang-jwt/jwt/v5](https://github.com/golang-jwt/jwt) from 5.2.1 to 5.2.2.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v5.2.1...v5.2.2)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-24 10:00:55 +00:00
Michael Eischer
171f303399 Merge pull request #5302 from restic/update-dependencies
update all direct dependencies
2025-03-24 10:51:59 +01:00
Michael Eischer
dda652614e update all direct dependencies 2025-03-23 21:53:27 +01:00
Michael Eischer
784097a4f8 Merge pull request #5297 from MichaelEischer/fix-overwrite-behavior-help
restore: fix help message on invalid OverwriteBehavior
2025-03-23 20:06:10 +01:00
Michael Eischer
f5989964ed restore: fix redundant default value for --overwrite option 2025-03-23 19:54:22 +01:00
Martin Smith
cfa3c5884d Fix lock pass by value and handle error from Release(). 2025-03-23 18:53:21 +00:00
Michael Eischer
d60acc5697 restore: fix help message on invalid OverwriteBehavior 2025-03-23 19:51:37 +01:00
Michael Eischer
2240d1801c add changelog recover enhancement 2025-03-23 18:17:33 +01:00
Michael Eischer
99fdb00d39 recover: add minimal integration test 2025-03-23 18:07:41 +01:00
Michael Eischer
2409078d55 recover: automatically run repair index before recovering snapshots 2025-03-23 17:55:33 +01:00
Michael Eischer
0b6c355678 recover: refactor to use termstatus 2025-03-23 17:46:49 +01:00
Michael Eischer
f7f48b3026 ui/progress: extend Printer interface with print to stdout method 2025-03-23 17:46:04 +01:00
Michael Eischer
1221453d08 Merge pull request #5264 from restic/dependabot/go_modules/github.com/minio/minio-go/v7-7.0.87
build(deps): bump github.com/minio/minio-go/v7 from 7.0.77 to 7.0.87
2025-03-23 17:38:30 +01:00
Michael Eischer
4b975bda37 backend/s3: increase timeout for test initialization 2025-03-23 17:28:08 +01:00
Michael Eischer
f8b481fd9b backend/s3: resolve credential retrieval deprecation 2025-03-23 17:28:08 +01:00
dependabot[bot]
f88d5adaa2 build(deps): bump github.com/minio/minio-go/v7 from 7.0.77 to 7.0.87
Bumps [github.com/minio/minio-go/v7](https://github.com/minio/minio-go) from 7.0.77 to 7.0.87.
- [Release notes](https://github.com/minio/minio-go/releases)
- [Commits](https://github.com/minio/minio-go/compare/v7.0.77...v7.0.87)

---
updated-dependencies:
- dependency-name: github.com/minio/minio-go/v7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-23 17:28:08 +01:00
Michael Eischer
89909d41aa Merge pull request #5292 from restic/go-1.23
Add Go 1.24 and drop Go 1.22 support
2025-03-23 17:26:31 +01:00
Michael Eischer
06535e62c1 CI: increase timeout to work around slow cloud backend 2025-03-23 16:36:31 +01:00
Michael Eischer
c99c76ada8 backend/test: increase parallelism to run all TestBackend tests in parallel 2025-03-23 16:36:31 +01:00
Michael Eischer
4350b95d27 backend/test: fix delayedRemoval timeout handling
The timeout for all blobs starts to run after the delete calls have been
issue. Thus, use the same start time for all blobs instead of individual
timeouts.
2025-03-23 16:36:31 +01:00
Michael Eischer
2e58561ad6 backend/test: remove redundant test call to the backend 2025-03-23 16:36:31 +01:00
Michael Eischer
17b585f7c7 backend/test: partially parallelize delayedRemove 2025-03-23 16:36:31 +01:00
Michael Eischer
4640b3c41a backend/test: parallelize slow tests 2025-03-23 16:36:31 +01:00
Michael Eischer
c36970074d CI: bump golangci version 2025-03-23 16:36:31 +01:00
Michael Eischer
15e90b7a4c test go 1.24 and drop support for 1.22 2025-03-23 16:36:31 +01:00
Michael Eischer
8d2d50d095 repository: merge small pack files before flushing
This prevents chunk size leaks when a backup only consists of a small
file which is split in two parts, which end up in two individual pack
files.
2025-03-23 12:29:16 +01:00
Michael Eischer
62453f9356 repository: randomly distribute blobs over two pack files 2025-03-23 12:29:16 +01:00
Martin Smith
6caad10840 Remove extra brackets. 2025-03-23 10:11:43 +00:00
Martin Smith
4420fde378 Remove deprecated HTTP option that is now the default. 2025-03-23 10:10:54 +00:00
Martin Smith
a389977bd7 Remove redudnant error check, handled above. 2025-03-23 10:05:13 +00:00
Martin Smith
6e45c51509 Fix name including package name and variable shadowing package. 2025-03-23 10:01:19 +00:00
Martin Smith
5e7333d28d Unify repository receiver name. 2025-03-23 09:57:59 +00:00
Michael Eischer
c617364d15 Merge pull request #5262 from Martin2112/go_cleanup
A set of mostly automated Go cleanups for the code
2025-03-22 23:55:28 +01:00
Martin Smith
e2ccb18e22 Fix lint for missing const, after fixing godoc for the outer type. 2025-03-22 18:42:12 +00:00
Martin Smith
d2c5241961 Revert a fix that broke compile of sd_windows.go. 2025-03-22 18:27:09 +00:00
Martin Smith
f238f81ba6 Renames to fix clashes with reserved words. 2025-03-22 18:20:30 +00:00
Martin Smith
3788605127 Rename unused parameters to '_'. 2025-03-22 18:20:30 +00:00
Martin Smith
29b4680873 Remove unnecessary type conversions, second set. 2025-03-22 18:20:30 +00:00
Martin Smith
092899df8b Remove unnecessary type conversions. 2025-03-22 18:20:30 +00:00
Martin Smith
2099ec1cd6 Remove import aliases that match package name. 2025-03-22 18:20:30 +00:00
Martin Smith
1daf5317f8 Fix import ordering. 2025-03-22 18:20:30 +00:00
Martin Smith
db8daeb192 Fix godoc comments. 2025-03-22 18:20:30 +00:00
Michael Eischer
ef692991a4 Merge pull request #5183 from wplapper/cmd_prune
restic prune: selection of packs to repack based on size
2025-03-22 15:43:32 +01:00
Michael Eischer
062cfc549d prune: fix not working option 2025-03-22 15:34:40 +01:00
Michael Eischer
3e58b15ace prune: allow --repack-smaller-than independently of --repack-small 2025-03-22 15:08:36 +01:00
Michael Eischer
69249372bf Merge pull request #5249 from MichaelEischer/fix-repair-index
Prevent creation of oversized indexes and automatically rewrite them.
2025-03-22 14:29:39 +01:00
Michael Eischer
445477312c Merge pull request #5251 from MichaelEischer/rclone-retries
Retry temporary rclone backend errors
2025-03-22 14:24:47 +01:00
Winfried Plappert
cc4712f8e9 add a test to cmd_ls_integration_test.go: test rest ls --json (#5255)
* cmd_ls: one more test: ls --json to check the JSON lines

validate that the individual JSON lines are valid JSON statements.
Check for snap ID and the path names in the backup.
2025-03-22 14:20:19 +01:00
Michael Eischer
c405e9e748 Merge pull request #5270 from prajwalbharadwajbm/master
build: improve GoVersion comparison logic
2025-03-22 12:05:40 +01:00
Michael Eischer
5f40e4b7c5 Merge pull request #5274 from luzpaz/typos
doc: fix various typos
2025-03-22 11:56:52 +01:00
Michael Eischer
0b0987233f Merge pull request #5263 from restic/dependabot/github_actions/slsa-framework/slsa-github-generator-2.1.0
build(deps): bump slsa-framework/slsa-github-generator from 2.0.0 to 2.1.0
2025-03-22 11:53:09 +01:00
Michael Eischer
d66e9cfff5 Merge pull request #5267 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/azidentity-1.8.2
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity from 1.8.1 to 1.8.2
2025-03-22 11:47:36 +01:00
Michael Eischer
e40996f0f1 Merge pull request #5265 from restic/dependabot/go_modules/github.com/klauspost/compress-1.18.0
build(deps): bump github.com/klauspost/compress from 1.17.11 to 1.18.0
2025-03-22 11:46:18 +01:00
dependabot[bot]
818cb386a5 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity
Bumps [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) from 1.8.1 to 1.8.2.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azidentity/v1.8.1...sdk/azidentity/v1.8.2)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-22 10:39:29 +00:00
Michael Eischer
9f724f7dc5 Merge pull request #5268 from restic/dependabot/go_modules/golang.org/x/sync-0.11.0
build(deps): bump golang.org/x/sync from 0.10.0 to 0.11.0
2025-03-22 11:38:35 +01:00
Winfried Plappert
3f42c0ad96 restic prune changelog/unreleased - corrext typo
changed option from `--small-pack-size` to `--repack-smaller-than`
2025-03-15 12:51:29 +00:00
Luz Paz
794341a494 doc: fix various typos
Found via `codespell -q 3 -L atleast,iinclude,ist,programm,reenable,ser,uptodate`
2025-03-05 20:47:08 -05:00
Prajwal Bharadwaj BM
74b76ca0df build: improve GoVersion comparison logic
Refactor AtLeast method to correctly handle version comparisons by:
- Checking major version first
- Handling minor version comparisons
- Ensuring correct comparison of patch versions
2025-03-01 12:51:11 +05:30
dependabot[bot]
3b21c7da3d build(deps): bump golang.org/x/sync from 0.10.0 to 0.11.0
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.10.0 to 0.11.0.
- [Commits](https://github.com/golang/sync/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-01 01:53:26 +00:00
dependabot[bot]
f838bf1056 build(deps): bump github.com/klauspost/compress from 1.17.11 to 1.18.0
Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.17.11 to 1.18.0.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Changelog](https://github.com/klauspost/compress/blob/master/.goreleaser.yml)
- [Commits](https://github.com/klauspost/compress/compare/v1.17.11...v1.18.0)

---
updated-dependencies:
- dependency-name: github.com/klauspost/compress
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-01 01:53:16 +00:00
dependabot[bot]
664971eb1d build(deps): bump slsa-framework/slsa-github-generator
Bumps [slsa-framework/slsa-github-generator](https://github.com/slsa-framework/slsa-github-generator) from 2.0.0 to 2.1.0.
- [Release notes](https://github.com/slsa-framework/slsa-github-generator/releases)
- [Changelog](https://github.com/slsa-framework/slsa-github-generator/blob/main/CHANGELOG.md)
- [Commits](https://github.com/slsa-framework/slsa-github-generator/compare/v2.0.0...v2.1.0)

---
updated-dependencies:
- dependency-name: slsa-framework/slsa-github-generator
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-01 01:11:52 +00:00
Michael Eischer
de9a040d27 Merge pull request #5256 from abaumg/fix/links-to-backblaze-documentation
Fix links to Backblaze documentation
2025-02-23 21:06:28 +01:00
Andreas Baumgartner
89826ef5ce doc: fix links to Backblaze documentation 2025-02-21 23:43:02 +01:00
Winfried Plappert
a2a1309fd9 prune: make small pack size configureable for prune all changes together
cmd_prune.go: added option `--repack-smaller-than`
prune.go: added field `SmallPackBytes` to `PruneOptions`, including checking and processing
prune_test.go: added test `TestPruneSmall`
doc/060_forget.rst: added description of enhancement
changelog/unreleased/issue-5109: description of enhancement
2025-02-18 16:54:44 +00:00
Michael Eischer
6309952a82 add changelog for rclone retries 2025-02-17 21:33:35 +01:00
Michael Eischer
5e7ce45ede retry: test error retries for flaky backends 2025-02-16 22:56:43 +01:00
Michael Eischer
cb8575f001 rclone: remove redundant Warmup methods 2025-02-16 22:41:22 +01:00
Michael Eischer
8d1185b3b8 retry/rclone: retry errors up to 5 times 2025-02-16 22:40:55 +01:00
Michael Eischer
c970e58739 backend: refactor backend Connections and HasAtomicReplace into Properties 2025-02-16 22:27:58 +01:00
Michael Eischer
5ddda7f5e9 Merge pull request #5242 from MichaelEischer/fix-read-stdin-msg
print password from stdin message only to terminal
2025-02-16 18:29:34 +01:00
Michael Eischer
8c12291f56 Merge pull request #5241 from MichaelEischer/cleanup-cli
Refactor CLI command initialization to use less global state
2025-02-16 18:28:48 +01:00
Michael Eischer
5190933561 Merge pull request #5240 from MichaelEischer/better-json-docs
Improve JSON output type documentation
2025-02-16 18:28:29 +01:00
Michael Eischer
00e69f242e docs: fix datatypes 2025-02-16 18:17:22 +01:00
Michael Eischer
00628e952f add changelog for oversized indexes 2025-02-16 17:58:36 +01:00
Michael Eischer
39e63ee4e3 index: add tests for oversized index handling 2025-02-16 17:42:00 +01:00
Michael Eischer
3b8d15d651 index: rewrite oversized indexes 2025-02-16 17:03:14 +01:00
Michael Eischer
2fd8a3865c index: automatically write full indexes in StorePack 2025-02-16 16:39:38 +01:00
Michael Eischer
0c4e65228a refactor secondary options 2025-02-07 21:29:33 +01:00
Michael Eischer
120bd08c0d move globalOptions initialization into method 2025-02-07 21:29:33 +01:00
Michael Eischer
d378a171c8 cleanup backend initialization 2025-02-07 21:29:33 +01:00
Michael Eischer
c752867f0a fix linter errors 2025-02-07 21:29:33 +01:00
Michael Eischer
412d6d9ec5 Create root command via function 2025-02-07 21:29:33 +01:00
Michael Eischer
5497217018 print password from stdin message only to terminal 2025-02-07 20:54:18 +01:00
Michael Eischer
aa9cdf93cf refactor persistent options to be applied via functions 2025-02-07 19:03:46 +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
4e58902de6 doc: fix broken links 2025-02-06 20:59:36 +01:00
Michael Eischer
39823c5f6c doc: deprecate short_id and add some missing fields 2025-02-06 20:53:01 +01:00
Michael Eischer
421842f41f doc: add datatypes to JSON outputs 2025-02-06 20:10:42 +01:00
Michael Eischer
59b7007534 doc: reformat scripting tables 2025-02-06 19:46:41 +01:00
Michael Eischer
da47967316 Merge pull request #5194 from darkdragon-001/json-check
Json check
2025-02-05 22:15:10 +01:00
Dark Dragon
49a411f7ac Print JSON summary in all error cases 2025-02-05 22:08:06 +01:00
Dark Dragon
7cc1aa0cd4 Add check summary 2025-02-05 22:08:06 +01:00
Dark Dragon
a58a8f2ce0 Add JSON output to check command 2025-02-05 22:08:05 +01:00
Dark Dragon
79d435efb1 Use printer.NewCounter() instead of newTerminalProgressMax()
where possible (max is unknown).
2025-02-05 22:07:47 +01:00
Michael Eischer
9cdf91b406 Merge pull request #5235 from MichaelEischer/refactor-ls-sorting
Refactor ls sorting
2025-02-05 20:44:08 +01:00
Winfried Plappert
4104a8e6a5 Issue: 4942: cmd_rewrite: add snapshot summary data to an existing snapshot. (#5185)
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2025-02-05 20:40:20 +01:00
Michael Eischer
6cc06e0812 ls: add missing error handling 2025-02-03 22:15:59 +01:00
Michael Eischer
c32613a624 ls: extract comparator 2025-02-03 22:15:59 +01:00
Michael Eischer
1807627dda ls: refactor sorting into sortedPrinter struct 2025-02-03 22:15:59 +01:00
Michael Eischer
993eb112cd ls: deduplicate sorting test 2025-02-03 22:15:54 +01:00
Michael Eischer
36d8916354 ls: use numeric based enum for SortMode 2025-02-03 22:11:46 +01:00
Winfried Plappert
060a44202f ls: sort output by size, atime, ctime, mtime, time(=mtime), extension (#5182)
Enhancement: create ability to sort output of restic ls -l by
name, size, atime, ctime, mtime, time(=mtime), X(=extension), extension

---------

Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2025-02-03 22:07:04 +01:00
Michael Eischer
d79681b987 Merge pull request #5223 from restic/dependabot/go_modules/google.golang.org/api-0.219.0
build(deps): bump google.golang.org/api from 0.204.0 to 0.219.0
2025-02-03 21:32:15 +01:00
dependabot[bot]
90e2c419e4 build(deps): bump google.golang.org/api from 0.204.0 to 0.219.0
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.204.0 to 0.219.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.204.0...v0.219.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-03 20:16:08 +00:00
Michael Eischer
7ab5bb6df4 Merge pull request #5232 from MichaelEischer/bump-go-version
Bump minimum go version to 1.22
2025-02-03 21:14:57 +01:00
Michael Eischer
efd2ec086f Merge pull request #5179 from zmanda/fix-gh-5140-forget-reports-incorrect-number-of-files-deleted
forget: report count of deleted files correctly
2025-02-02 20:14:15 +01:00
Srigovind Nayak
8d970e36cf tests: add unit test to check the progress counter for forget/prune 2025-02-02 20:18:56 +05:30
Srigovind Nayak
58f58a995d parallel: increment progress bar before report function which may absorb the error
* sometimes, the report function may absorb the error and return nil, in those cases the bar.Add(1) method would execute even if the file deletion had failed
2025-02-02 19:45:36 +05:30
Michael Eischer
d71ddfb89b bump minimum go version to 1.22 2025-02-02 15:05:47 +01:00
Gilbert Gilb's
536ebefff4 feat(backends/s3): add warmup support before repacks and restores (#5173)
* feat(backends/s3): add warmup support before repacks and restores

This commit introduces basic support for transitioning pack files stored
in cold storage to hot storage on S3 and S3-compatible providers.

To prevent unexpected behavior for existing users, the feature is gated
behind new flags:

- `s3.enable-restore`: opt-in flag (defaults to false)
- `s3.restore-days`: number of days for the restored objects to remain
  in hot storage (defaults to `7`)
- `s3.restore-timeout`: maximum time to wait for a single restoration
  (default to `1 day`)
- `s3.restore-tier`: retrieval tier at which the restore will be
  processed. (default to `Standard`)

As restoration times can be lengthy, this implementation preemptively
restores selected packs to prevent incessant restore-delays during
downloads. This is slightly sub-optimal as we could process packs
out-of-order (as soon as they're transitioned), but this would really
add too much complexity for a marginal gain in speed.

To maintain simplicity and prevent resources exhautions with lots of
packs, no new concurrency mechanisms or goroutines were added. This just
hooks gracefully into the existing routines.

**Limitations:**

- Tests against the backend were not written due to the lack of cold
  storage class support in MinIO. Testing was done manually on
  Scaleway's S3-compatible object storage. If necessary, we could
  explore testing with LocalStack or mocks, though this requires further
  discussion.
- Currently, this feature only warms up before restores and repacks
  (prune/copy), as those are the two main use-cases I came across.
  Support for other commands may be added in future iterations, as long
  as affected packs can be calculated in advance.
- The feature is gated behind a new alpha `s3-restore` feature flag to
  make it explicit that the feature is still wet behind the ears.
- There is no explicit user notification for ongoing pack restorations.
  While I think it is not necessary because of the opt-in flag, showing
  some notice may improve usability (but would probably require major
  refactoring in the progress bar which I didn't want to start). Another
  possibility would be to add a flag to send restores requests and fail
  early.

See https://github.com/restic/restic/issues/3202

* ui: warn user when files are warming up from cold storage

* refactor: remove the PacksWarmer struct

It's easier to handle multiple handles in the backend directly, and it
may open the door to reducing the number of requests made to the backend
in the future.
2025-02-01 18:26:27 +00:00
Michael Eischer
9566e2db4a Merge pull request #5222 from MichaelEischer/docs-edit-links
doc: add edit on github link
2025-02-01 18:37:05 +01:00
Michael Eischer
7829728182 Merge pull request #5225 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob-1.6.0
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob from 1.5.0 to 1.6.0
2025-02-01 17:03:33 +01:00
Michael Eischer
72b343fe5a Merge pull request #5228 from greatroar/cleanup
ui/termstatus: Remove unused bytes.Buffer
2025-02-01 16:58:54 +01:00
Michael Eischer
9c8c59c889 Merge pull request #5226 from restic/dependabot/go_modules/github.com/spf13/pflag-1.0.6
build(deps): bump github.com/spf13/pflag from 1.0.5 to 1.0.6
2025-02-01 16:57:10 +01:00
dependabot[bot]
c4d988faf8 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
Bumps [github.com/Azure/azure-sdk-for-go/sdk/storage/azblob](https://github.com/Azure/azure-sdk-for-go) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.5.0...sdk/azcore/v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-01 15:56:10 +00:00
Michael Eischer
080c8de1a9 Merge pull request #5227 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/azidentity-1.8.1
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity from 1.8.0 to 1.8.1
2025-02-01 16:55:04 +01:00
greatroar
c1781e0abb ui/termstatus: Remove unused bytes.Buffer 2025-02-01 08:21:40 +01:00
dependabot[bot]
2b9113721c build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity
Bumps [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.8.0...sdk/azidentity/v1.8.1)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-01 01:43:20 +00:00
dependabot[bot]
afe4fcc0d9 build(deps): bump github.com/spf13/pflag from 1.0.5 to 1.0.6
Bumps [github.com/spf13/pflag](https://github.com/spf13/pflag) from 1.0.5 to 1.0.6.
- [Release notes](https://github.com/spf13/pflag/releases)
- [Commits](https://github.com/spf13/pflag/compare/v1.0.5...v1.0.6)

---
updated-dependencies:
- dependency-name: github.com/spf13/pflag
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-01 01:43:14 +00:00
Michael Eischer
c2e404a0ee doc: add edit on github link 2025-01-31 18:53:03 +01:00
Winfried Plappert
c4be05dbc2 Issue 4433: Ability to define sort order for output of find command (#5184)
The old sorting behaviour was to sort snapshots from oldest to newest.
The new sorting order is from newest to oldest. If one wants to revert to the
old behaviour, use the option --reverse.

---------

Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2025-01-29 20:44:16 +00:00
rawtaz
d0d887138c Merge pull request #5219 from MichaelEischer/ci-silence-shadow-builtin
CI: bump golangci-lint and silence warnings about shadowed builtins
2025-01-29 01:30:40 +01:00
Michael Eischer
8eaa4b6602 CI: bump golangci-lint to v1.63.4 2025-01-28 19:55:45 +01:00
Michael Eischer
e77681f2cd remove unnecessary min function 2025-01-28 19:52:22 +01:00
Michael Eischer
a63500663a CI: disable shadow builtin rule
Removing the shadowing cases leads to weird workarounds but doesn't help
much with code clarity.
2025-01-28 19:51:14 +01:00
Michael Eischer
fde64133df Merge pull request #5212 from MichaelEischer/prune-fix-unused-size-duplicates
prune: correctly account for duplicates in max-unused check
2025-01-26 22:07:47 +01:00
Snshadow
6301250d83 fix: Windows VSS Event ID 8194 (#5170) 2025-01-26 15:25:38 +00:00
Michael Eischer
9331461a13 prune: correctly account for duplicates in max-unused check
The size comparison for `--max-unused` only accounted for unused but not
for duplicate data. For repositories with a large amount of duplicates
this can result in a situation where no data gets pruned even though
the amount of unused data is much higher than specified.
2025-01-19 17:47:49 +01:00
rawtaz
ed3922ac82 Merge pull request #5211 from MichaelEischer/bump-dockerfile-go-version
Bump dockerfile to go 1.23
2025-01-19 08:32:42 +01:00
Michael Eischer
8b63e1cd72 Merge pull request #5129 from tesshuflower/5089_exclude_xattrs_on_restore
Allow excluding xattrs at restore time
2025-01-18 23:15:11 +01:00
Michael Eischer
5e8654c71d restore: fix xattr filter test on windows 2025-01-18 23:07:39 +01:00
Michael Eischer
d5a94583ed bump dockerfile to go 1.23 2025-01-18 18:27:43 +01:00
Srigovind Nayak
115ecb3c92 tag: output the original ID and new snapshotID (#5144)
* tag: output the original ID and new snapshotID

tag: print changed snapshot information immediately

* print changed snapshot immediately after it has been saved
* add message type to the changedSnapshot
* add a summary type which will share the JSON output of the numer of changed snapshots
* updated verbosity of the changed snapshot in text mode to only work when verbosity > 2
* also use the terminal status printer for a standard handling for stdout messages
2025-01-14 18:57:47 +01:00
Michael Eischer
e6f9cfb8c8 Merge pull request #5168 from MichaelEischer/restrict-repository-unpacked
repository: restrict SaveUnpacked and RemoveUnpacked
2025-01-13 22:49:44 +01:00
Michael Eischer
b7ff8ea9cd repository: expose cache via method 2025-01-13 22:40:18 +01:00
Michael Eischer
99e105eeb6 repository: restrict SaveUnpacked and RemoveUnpacked
Those methods now only allow modifying snapshots. Internal data types
used by the repository are now read-only. The repository-internal code
can bypass the restrictions by wrapping the repository in an
`internalRepository` type.

The restriction itself is implemented by using a new datatype
WriteableFileType in the SaveUnpacked and RemoveUnpacked methods. This
statically ensures that code cannot bypass the access restrictions.

The test changes are somewhat noisy as some of them modify repository
internals and therefore require some way to bypass the access
restrictions. This works by capturing an `internalRepository` or
`Backend` when creating the Repository using a test helper function.
2025-01-13 22:39:57 +01:00
Albin Vass
5bf0204caf Do not skip root tree when searching for trees (#5153)
This fixes an issue where restic cannot find the tree when trying to find the
tree id of a snapshot.

---------

Co-authored-by: Albin Vass <albinvass@gmail.com>
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2025-01-13 21:08:38 +00:00
Michael Eischer
14d02df8bb Merge pull request #5162 from MichaelEischer/promote-feature-gates
Stabilize `explicit-s3-anonymous-auth` and `safe-forget-keep-tags` feature flags
2025-01-13 22:03:06 +01:00
Michael Eischer
bd4ce8aac1 Merge pull request #4990 from m-wild/exclude-cloud-files
backup: allow excluding online-only cloud files
2025-01-13 21:24:53 +01:00
Michael Wildman
da71e77b28 backup: allow excluding online-only cloud files 2025-01-13 21:11:23 +01:00
Michael Eischer
27189e03ee Merge pull request #4999 from konidev20/fix-gh-4983-slsa-provenance-for-ghcr-container-images
docker: sign container images pushed to GHCR with GitHub OIDC tokens
2025-01-12 22:38:33 +01:00
Michael Eischer
4e1eeeb721 Merge pull request #5207 from restic/dependabot/go_modules/golang.org/x/net-0.34.0
build(deps): bump golang.org/x/net from 0.30.0 to 0.34.0
2025-01-11 19:41:07 +01:00
Michael Eischer
3b37983a60 Merge pull request #5196 from restic/dependabot/go_modules/github.com/klauspost/compress-1.17.11
build(deps): bump github.com/klauspost/compress from 1.17.9 to 1.17.11
2025-01-11 19:39:25 +01:00
dependabot[bot]
99646fdf62 build(deps): bump golang.org/x/net from 0.30.0 to 0.34.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.30.0 to 0.34.0.
- [Commits](https://github.com/golang/net/compare/v0.30.0...v0.34.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-11 18:31:06 +00:00
Michael Eischer
0331891545 Merge pull request #5202 from knbr13/remove-duplicate-imports
remove duplicate imports
2025-01-11 19:28:07 +01:00
Michael Eischer
2b45c004be Merge pull request #5200 from restic/dependabot/go_modules/golang.org/x/sys-0.28.0
build(deps): bump golang.org/x/sys from 0.27.0 to 0.28.0
2025-01-11 19:27:52 +01:00
Tesshu Flower
44cef25077 remove bad test xattr
Signed-off-by: Tesshu Flower <tflower@redhat.com>
2025-01-10 21:12:03 -05:00
Tesshu Flower
cd84fe0853 xattrs - restore all by default, doc/chglog update
Signed-off-by: Tesshu Flower <tflower@redhat.com>
2025-01-10 15:25:09 -05:00
Tesshu Flower
3ac697d03d linux default restore only user xattrs, doc update
* On Linux restore only user.* xattrs by default
* restore all for other OSs
* Update docs and changelog about the new restore
flags --exclude-xattr and --include-xattr

Signed-off-by: Tesshu Flower <tflower@redhat.com>
2025-01-10 15:13:45 -05:00
Tesshu Flower
24422e20a6 restore: xattr restore filter tests
Signed-off-by: Tesshu Flower <tflower@redhat.com>
2025-01-10 15:13:44 -05:00
Tesshu Flower
f457b16b23 update nodeRestoreExtendedAttributes() for win
- also other platforms
- move xattr include/exclude filter parsing into
  separate func

Signed-off-by: Tesshu Flower <tflower@redhat.com>
2025-01-10 15:13:44 -05:00
Tesshu Flower
af839f9548 restore: exclude/include xattrs
For: https://github.com/restic/restic/issues/5089

Signed-off-by: Tesshu Flower <tflower@redhat.com>
2025-01-10 15:13:40 -05:00
knbr13
bbb492ee65 remove duplicate imports 2025-01-05 13:53:20 +02:00
dependabot[bot]
01405f1e1b build(deps): bump golang.org/x/sys from 0.27.0 to 0.28.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.27.0 to 0.28.0.
- [Commits](https://github.com/golang/sys/compare/v0.27.0...v0.28.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-01 01:54:17 +00:00
dependabot[bot]
caa59bb81b build(deps): bump github.com/klauspost/compress from 1.17.9 to 1.17.11
Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.17.9 to 1.17.11.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Changelog](https://github.com/klauspost/compress/blob/master/.goreleaser.yml)
- [Commits](https://github.com/klauspost/compress/compare/v1.17.9...v1.17.11)

---
updated-dependencies:
- dependency-name: github.com/klauspost/compress
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-01 01:54:05 +00:00
rawtaz
de3acd7937 Merge pull request #5180 from vmlemon/master
Enable xattr support, on NetBSD 10+
2024-12-23 20:05:06 +01:00
Tyson Key
9e85119d73 Update changelog, for issue 5174 (Enable xattr support, on NetBSD 10+) 2024-12-19 14:32:16 +00:00
Tyson Key
37969ae8e3 Enable xattr support, on NetBSD 10+ 2024-12-18 16:52:44 +00:00
Aneesh N
6808004ad1 Refactor extended attributes and security descriptor helpers to use go-winio (#5040)
* Refactor ea and sd helpers to use go-winio

Import go-winio and instead of copying the functions to encode/decode extended attributes and enable process privileges for security descriptors, call the functions defined in go-winio.
2024-12-09 21:48:38 +01:00
Srigovind Nayak
8d45a4b283 changelog: update to indicate change applies only for GHCR images. 2024-12-02 01:11:26 +05:30
Srigovind Nayak
4fb9aa4351 docker: fix typos and permissions for jobs 2024-12-02 00:16:19 +05:30
Srigovind Nayak
d422e75e08 docs: add instructions for verifying SLSA provenance of Docker images
docs: update the documentation
2024-12-02 00:14:39 +05:30
Srigovind Nayak
144221b430 docker: add SLSA provenance to .github workflow
* the id-token of the GitHub Actions workflow will be used for image signing
* replace branch-based tagging with SHA-based tagging since, branch names are mutable, SLSA provenance requires immutable tagging
* use official SLSA framework Github Reusable workflow

docker: fix incorrect registry name in image output step

* use REGISTRY environment variable instead of IMAGE_REGISTRY

docker: revert change to remove branch tag
2024-12-02 00:14:38 +05:30
Srigovind Nayak
d7d9af4c9f ui: restore --delete indicates number of deleted files (#5100)
* ui: restore --delete indicates number of deleted files

* adds new field `FilesDeleted` to the State struct, JSON and text progress updaters
* increment FilesDeleted count when ReportedDeletedFile

* ui: collect the files to be deleted, delete, then update the count post deletion

* docs: update scripting output fields for restore command

ui: report deleted directories and refactor function name to ReportDeletion
2024-12-01 15:29:11 +01:00
Michael Eischer
2f0049cd6c Merge pull request #5141 from richgrov/missing-azure-env-error
Return error if AZURE_ACCOUNT_NAME not set
2024-12-01 14:01:56 +01:00
Michael Eischer
72c02fa759 Merge pull request #5167 from restic/dependabot/go_modules/github.com/pkg/sftp-1.13.7
build(deps): bump github.com/pkg/sftp from 1.13.6 to 1.13.7
2024-12-01 13:14:03 +01:00
dependabot[bot]
770841f95d build(deps): bump github.com/pkg/sftp from 1.13.6 to 1.13.7
Bumps [github.com/pkg/sftp](https://github.com/pkg/sftp) from 1.13.6 to 1.13.7.
- [Release notes](https://github.com/pkg/sftp/releases)
- [Commits](https://github.com/pkg/sftp/compare/v1.13.6...v1.13.7)

---
updated-dependencies:
- dependency-name: github.com/pkg/sftp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-01 12:02:01 +00:00
Michael Eischer
5e0a045481 Merge pull request #5163 from restic/dependabot/go_modules/golang.org/x/sys-0.27.0
build(deps): bump golang.org/x/sys from 0.26.0 to 0.27.0
2024-12-01 13:00:28 +01:00
Michael Eischer
3fecddafe8 Merge pull request #5165 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob-1.5.0
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob from 1.4.0 to 1.5.0
2024-12-01 12:58:24 +01:00
dependabot[bot]
40987a5f80 build(deps): bump golang.org/x/sys from 0.26.0 to 0.27.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.26.0 to 0.27.0.
- [Commits](https://github.com/golang/sys/compare/v0.26.0...v0.27.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-01 11:48:44 +00:00
Michael Eischer
875976f4a8 Merge pull request #5166 from restic/dependabot/go_modules/golang.org/x/text-0.20.0
build(deps): bump golang.org/x/text from 0.19.0 to 0.20.0
2024-12-01 12:47:55 +01:00
dependabot[bot]
2dc00cfd36 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
Bumps [github.com/Azure/azure-sdk-for-go/sdk/storage/azblob](https://github.com/Azure/azure-sdk-for-go) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.4.0...sdk/azcore/v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-01 11:45:54 +00:00
Michael Eischer
45d2b4cd3c Merge pull request #5161 from restic/bump-backblaze-library
bump backblaze/blazer to v0.7.1
2024-12-01 12:45:00 +01:00
dependabot[bot]
a4d776ec8f build(deps): bump golang.org/x/text from 0.19.0 to 0.20.0
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.19.0 to 0.20.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.19.0...v0.20.0)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-01 01:41:13 +00:00
Michael Eischer
098db935f7 Stabilize explicit-s3-anonymous-auth and safe-forget-keep-tags flags
The features can no longer be disabled.
2024-11-30 21:22:51 +01:00
Michael Eischer
ead57ec501 bump backblaze/blazer to v0.7.1 2024-11-30 21:17:06 +01:00
Michael Eischer
8f9d755b44 Merge pull request #5158 from dnnr/clarify-max-repack-size
Reword description of --max-repack-size for clarity
2024-11-30 19:19:01 +01:00
Daniel Danner
1062546563 Mention size 2024-11-30 17:52:29 +01:00
Michael Eischer
0bf8af7188 Merge pull request #5138 from vmlemon/issue-5131
Implement basic DragonFlyBSD support
2024-11-30 17:32:59 +01:00
Michael Eischer
9a674ecc34 Merge pull request #5146 from MichaelEischer/inline-extended-stat
fs: Inline ExtendedFileInfo
2024-11-30 17:23:34 +01:00
Michael Eischer
9a99141a5f fs: remove os.FileInfo from fs.ExtendedFileInfo
Only the `Sys()` value from os.FileInfo is kept as field `sys` to
support Windows. The os.FileInfo removal ensures that for values like
`ModTime` that existed in both data structures there's no more confusion
which value is actually used.
2024-11-30 17:07:36 +01:00
Michael Eischer
847b2efba2 archiver: remove fs parameter from fileChanged function 2024-11-30 16:19:16 +01:00
Michael Eischer
641390103d fs: inline ExtendedStat 2024-11-30 16:19:16 +01:00
Michael Eischer
806fa534ce Merge pull request #5145 from MichaelEischer/ignore-disappeared-files
backup: Ignore disappeared files
2024-11-30 16:15:31 +01:00
Michael Eischer
5df6bf80b1 fs: retry vss creation on VSS_E_SNAPSHOT_SET_IN_PROGRESS error
Depending on the change packages, the VSS tests from ./cmd/restic and
the fs package may overlap in time. This causes the snapshot creation to
fail. Add retries in that case.
2024-11-30 16:07:18 +01:00
Michael Eischer
dc89aad722 build dragonflybsd binaries 2024-11-30 15:47:39 +01:00
Tyson Key
3c0ceda536 Add basic support for DragonFlyBSD 2024-11-30 15:42:15 +01:00
Michael Eischer
c5fb46da53 archiver: ignore files removed in the meantime 2024-11-30 15:30:42 +01:00
Michael Eischer
8642049532 Merge pull request #5143 from MichaelEischer/fs-handle-interface
fs: rework FS interface to be handle based
2024-11-30 15:29:31 +01:00
Michael Eischer
8644bb145b Merge pull request #5134 from MichaelEischer/better-time-restore-error
restore: improve error if timestamp fails to restore
2024-11-30 13:09:33 +01:00
Daniel Danner
0997f26461 Reword description --max-repack-size for clarity 2024-11-29 23:29:43 +01:00
Michael Eischer
a5c49e5340 Merge pull request #5142 from MichaelEischer/fix-not-ordered-error-message
restic: add missing space in error message
2024-11-29 22:48:16 +01:00
Michael Eischer
b51bf0c0c4 fs: test File implementation of Local FS 2024-11-16 16:09:17 +01:00
Michael Eischer
6cb19e0190 archiver: fix file type change test
The test did not test the case that the type of a file changed
unexpectedly.
2024-11-16 16:09:17 +01:00
Michael Eischer
d7f4b9db60 fs: deduplicate placeholders for generic and xattrs 2024-11-16 16:09:17 +01:00
Michael Eischer
087f95a298 fs: make generic and extended attrs independent of each other 2024-11-16 15:38:56 +01:00
Michael Eischer
6084848e5a fs: fix O_NOFOLLOW for metadata handles on Windows 2024-11-16 15:38:56 +01:00
Michael Eischer
48dbefc37e fs / archiver: convert to handle based interface
The actual implementation still relies on file paths, but with the
abstraction layer in place, an FS implementation can ensure atomic file
accesses in the future.
2024-11-16 12:56:23 +01:00
Michael Eischer
2f2ce9add2 fs: remove Stat from FS interface 2024-11-16 12:56:23 +01:00
Michael Eischer
623ba92b98 fs: drop unused permission parameter from OpenFile 2024-11-16 12:56:23 +01:00
Michael Eischer
b402e8a6fc fs: stricter enforcement to only call readdir on a directory
Use O_DIRECTORY to prevent opening any other than a directory in
readdirnames.
2024-11-16 12:56:23 +01:00
Richard Grover
548fa07577 Add changelog info 2024-11-15 14:46:34 -07:00
Michael Eischer
f8031561f2 archiver: deduplicate error filtering 2024-11-15 17:58:06 +01:00
Michael Eischer
49ef3ebec3 restic: add missing space in error message 2024-11-15 17:52:09 +01:00
Richard Grover
dfbd4fb983 Error if AZURE_ACCOUNT_NAME not set 2024-11-13 08:02:22 -07:00
Michael Eischer
1133498ef8 Merge pull request #5046 from konidev20/fix-gh-4521-azure-blob-storage-add-support-for-access-tiers
azure: add support for access tiers hot, cool and cold
2024-11-11 22:01:52 +01:00
Michael Eischer
9c758313e3 Merge pull request #5119 from MichaelEischer/backup-json-start-end-time
backup: include start and end time in json output
2024-11-11 21:50:30 +01:00
Michael Eischer
82c5043fc9 Reduce checkboxes in PR checklist (#5120)
The basics around how to format commits and PR settings are primarily
relevant when opening a PR for the first time. But for repeated
contributors it is tedious to always tick those checkboxes.

Co-authored-by: rawtaz <rawtaz@users.noreply.github.com>
2024-11-11 21:49:26 +01:00
Michael Eischer
a73ae7ba1a restore: improve error if timestamp fails to restore 2024-11-11 21:37:28 +01:00
Michael Eischer
bd16804812 Merge branch 'patch-release' 2024-11-09 11:43:01 +01:00
Alexander Neumann
e2a98aa955 Set development version for 0.17.3 2024-11-08 20:36:48 +01:00
Michael Eischer
408ec41a1d Merge pull request #5123 from MichaelEischer/fix-removable-media-handling
fs: fallback to low privilege security descriptors on access denied
2024-11-03 21:35:38 +01:00
Michael Eischer
270e7b7679 Merge pull request #5122 from restic/bump-golangci-lint
Bump go and golangci lint version
2024-11-03 21:34:25 +01:00
Michael Eischer
97f3e15039 Merge pull request #5121 from MichaelEischer/improve-release-helper
prepare-release: improve handling of release from non-master branch
2024-11-03 21:31:33 +01:00
Michael Eischer
d5bd3fcda5 Merge pull request #5112 from MichaelEischer/fix-vss-root-volume
Fix VSS metadata error (master)
2024-11-03 21:30:39 +01:00
Michael Eischer
f9a90aae89 fs: fallback to low privilege security descriptors on access denied 2024-11-01 19:10:52 +01:00
Michael Eischer
289159beaf fs: remove redundant fixpath in vss code 2024-11-01 19:03:45 +01:00
Michael Eischer
4052a5927c fs: move getVolumePathName function 2024-11-01 19:03:45 +01:00
Michael Eischer
d3c3390a51 ls: proper error handling if output is not possible 2024-11-01 17:07:43 +01:00
Michael Eischer
569a117a1d improve fprintf related error handling 2024-11-01 17:07:43 +01:00
Michael Eischer
41fa41b28b fix double printf usage 2024-11-01 16:36:23 +01:00
Michael Eischer
3eb9556f6a CI: add go 1.23 2024-11-01 16:34:00 +01:00
Michael Eischer
f5b1f9c8b1 CI: bump golangci-lint to latest version 2024-11-01 16:33:47 +01:00
Michael Eischer
e65f4e2231 backup: include start and end time in json output
The timestamps were already stored in the created snapshot.
2024-11-01 16:31:34 +01:00
Michael Eischer
bcf5fbe498 prepare-release: improve handling of release from non-master branch
The final push command now states the correct branch to push.
2024-11-01 16:22:32 +01:00
Michael Eischer
ded9fc7690 Merge pull request #5101 from MichaelEischer/sftp-load-error
sftp: check for broken connection in Load/List operation
2024-11-01 16:05:29 +01:00
Michael Eischer
b3b173a47c fs: use non existing vss path to avoid flaky test
The test used \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1 , which if
it exists and supports extended attributes can cause the test to fail.
2024-11-01 15:38:05 +01:00
Michael Eischer
e18a2a0072 Merge pull request #5096 from MichaelEischer/prune-allow-dry-run
prune: allow dry-run without taking a lock
2024-11-01 15:34:15 +01:00
Michael Eischer
1eea41c49e Merge pull request #5095 from MichaelEischer/retry-load-config
Retry loading or creating repository config
2024-11-01 15:33:45 +01:00
Michael Eischer
71c185313e sftp: check for broken connection in Load/List operation 2024-11-01 15:33:27 +01:00
Michael Eischer
868efe4968 prune: allow dry-run without taking a lock 2024-11-01 15:27:25 +01:00
Michael Eischer
3be2b8a54b add config retry changelog 2024-11-01 15:22:55 +01:00
Michael Eischer
b5bc76cdc7 test retry on repo opening 2024-11-01 15:17:54 +01:00
Michael Eischer
58dc4a6892 backend/retry: hide final log for stat() method
stat is only used to check the config file's existence. We don't want
log output in this case.
2024-11-01 15:17:54 +01:00
Michael Eischer
74c783b850 retry load or creating repository config
By now missing files are not endlessly retried by the retry backend such
that it can be enabled right from the start.

In addition, this change also enables the retry backend for the `init`
command.
2024-11-01 15:17:54 +01:00
Michael Eischer
fc92a04284 Merge pull request #5116 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/azidentity-1.8.0
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity from 1.7.0 to 1.8.0
2024-11-01 15:07:23 +01:00
Michael Eischer
2f698d1cff Merge pull request #5117 from restic/dependabot/go_modules/google.golang.org/api-0.204.0
build(deps): bump google.golang.org/api from 0.199.0 to 0.204.0
2024-11-01 15:01:10 +01:00
dependabot[bot]
d8bf327d8b build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity
Bumps [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.7.0...sdk/azcore/v1.8.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-01 13:54:05 +00:00
Michael Eischer
2b3672198c Merge pull request #5115 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/azcore-1.16.0
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azcore from 1.14.0 to 1.16.0
2024-11-01 14:53:13 +01:00
dependabot[bot]
de847a48bf build(deps): bump google.golang.org/api from 0.199.0 to 0.204.0
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.199.0 to 0.204.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.199.0...v0.204.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-01 13:52:51 +00:00
Michael Eischer
d1d8ae7368 Merge pull request #5113 from restic/dependabot/go_modules/golang.org/x/time-0.7.0
build(deps): bump golang.org/x/time from 0.6.0 to 0.7.0
2024-11-01 14:52:18 +01:00
Michael Eischer
a32c98a39c Merge pull request #5114 from restic/dependabot/go_modules/golang.org/x/sys-0.26.0
build(deps): bump golang.org/x/sys from 0.25.0 to 0.26.0
2024-11-01 14:51:58 +01:00
dependabot[bot]
53cb6200fa build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azcore
Bumps [github.com/Azure/azure-sdk-for-go/sdk/azcore](https://github.com/Azure/azure-sdk-for-go) from 1.14.0 to 1.16.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.14.0...sdk/azcore/v1.16.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azcore
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-01 01:43:23 +00:00
dependabot[bot]
ae9268dadf build(deps): bump golang.org/x/sys from 0.25.0 to 0.26.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.25.0 to 0.26.0.
- [Commits](https://github.com/golang/sys/compare/v0.25.0...v0.26.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-01 01:43:12 +00:00
dependabot[bot]
a494bf661d build(deps): bump golang.org/x/time from 0.6.0 to 0.7.0
Bumps [golang.org/x/time](https://github.com/golang/time) from 0.6.0 to 0.7.0.
- [Commits](https://github.com/golang/time/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/time
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-01 01:43:08 +00:00
Michael Eischer
51cd1c847b backup: log error if test backup fails 2024-10-31 22:06:50 +01:00
Michael Eischer
14370fbf9e add vss metadata changelog 2024-10-31 22:06:50 +01:00
Michael Eischer
62af5f0b4a restic: test path handling of volume shadow copy root path 2024-10-31 22:06:50 +01:00
Michael Eischer
cb9247530e backup: run test with absolute path 2024-10-31 22:06:50 +01:00
Michael Eischer
1d0d5d87bc fs: fix error in fillGenericAttributes for vss volumes
Extended attributes and security descriptors apparently cannot be
retrieved from a vss volume. Fix the volume check to correctly detect
vss volumes and just completely disable extended attributes for volumes.
2024-10-31 22:06:50 +01:00
Michael Eischer
03aad742d3 fs: add correct vss support to fixpath
Paths that only contain the volume shadow copy snapshot name require
special treatment. These paths must end with a slash for regular file
operations to work.
2024-10-31 22:06:50 +01:00
Michael Eischer
15b7fb784f fs: cleanup fixpath 2024-10-31 21:49:03 +01:00
rawtaz
33da501c35 Merge pull request #5105 from joram-berger/patch-2
doc: Clarify number of blobs are added
2024-10-27 19:11:56 +00:00
Joram Berger
cd44b2bf8b doc: Clarify number of blobs are added
The numbers reported as `data_blobs` and `tree_blobs` are not total numbers of blobs but numbers of blobs added with the given snapshot.
2024-10-27 19:58:21 +01:00
Michael Eischer
1f0f6ad63d Merge branch 'patch-release' 2024-10-27 18:35:32 +01:00
Michael Eischer
ca4bd1b8ca Merge pull request #5094 from MichaelEischer/document-restore-delete-safety
doc: document safety feature for --target / --delete
2024-10-27 18:21:47 +01:00
Michael Eischer
e320edd416 Merge pull request #5048 from MichaelEischer/fix-macos-fuse
Fix unusable `mount` on macOS Sonoma
2024-10-23 22:51:00 +02:00
Michael Eischer
821000cb68 Merge pull request #5097 from MichaelEischer/fix-vss-metadata
backup: read extended metadata from snapshot
2024-10-22 19:23:06 +02:00
Srigovind Nayak
db686592a1 debug: azure add debug log to show access-tier 2024-10-20 20:24:49 +05:30
Srigovind Nayak
bff3341d10 azure: add support for hot, cool, or cool access tiers 2024-10-20 15:27:21 +05:30
Michael Eischer
5fe6607127 Merge pull request #5084 from greatroar/utimesnano
Simplify and refactor restoring of timestamps
2024-10-19 12:47:13 +00:00
greatroar
8f20d5dcd5 fs: Refactor UtimesNano replacements
Previously, nodeRestoreTimestamps would do something like

	if node.Type == restic.NodeTypeSymlink {
	    return nodeRestoreSymlinkTimestamps(...)
	}
	return syscall.UtimesNano(...)

where nodeRestoreSymlinkTimestamps was either a no-op or a
reimplementation of syscall.UtimesNano that handles symlinks, with some
repeated converting between timestamp types. The Linux implementation
was a bit clumsy, requiring three syscalls to set the timestamps.

In this new setup, there is a function utimesNano that has three
implementations:

* on Linux, it's a modified syscall.UtimesNano that uses
  AT_SYMLINK_NOFOLLOW and AT_FDCWD so it can handle any type in a single
  call;
* on other Unix platforms, it just calls the syscall function after
  skipping symlinks;
* on Windows, it's the modified UtimesNano that was previously called
  nodeRestoreSymlinkTimestamps, except with different arguments.
2024-10-19 12:04:09 +02:00
greatroar
f967a33ccc fs: Use AT_FDCWD in Linux nodeRestoreSymlinkTimestamps
There's no need to open the containing directory. This is exactly what
syscall.UtimesNano does, except for the AT_SYMLINK_NOFOLLOW flag.
2024-10-19 11:29:35 +02:00
Michael Eischer
ec43594003 add vss metadata changelog 2024-10-18 22:36:03 +02:00
Michael Eischer
e1faf7b18c backup: work around file deletion error in test 2024-10-18 22:08:10 +02:00
Michael Eischer
fc6f1b4b06 redirect test log output to t.Log() 2024-10-18 21:43:46 +02:00
Michael Eischer
9f206601af backup: test that vss backups work if underlying data was removed 2024-10-18 21:43:46 +02:00
Michael Eischer
ca79cb92e3 fs/vss: test that vss functions actually read from snapshot 2024-10-18 21:43:46 +02:00
Michael Eischer
352605d9f0 fs: remove file.Name() from interface
The only user was archiver.fileSaver.
2024-10-18 21:43:23 +02:00
Michael Eischer
26b77a543d archiver: use correct filepath in fileSaver for vss
When using the VSS FS, then `f.Name()` contained the filename in the
snapshot. This caused a double mapping when calling NodeFromFileInfo.
2024-10-18 21:41:02 +02:00
Michael Eischer
b988754a6d fs/vss: reuse functions from underlying FS
OpenFile, Stat and Lstat should reuse the underlying FS implementation
to avoid diverging behavior.
2024-10-18 19:30:05 +02:00
Michael Eischer
60960d2405 fs/vss: properly create node from vss path
Previously, NodeFromFileInfo used the original file path to create the
node, which also meant that extended metadata was read from there
instead of within the vss snapshot.
2024-10-18 19:27:44 +02:00
Michael Eischer
7c02141548 Merge pull request #5093 from Seefin/fix-containerSAS
Fix Azure Container Token Auth
2024-10-17 18:45:06 +00:00
Connor Findlay
b434f560cc backend/azure: Add tests for both token types
Add two new test cases, TestBackendAzureAccountToken and
TestBackendAzureContainerToken, that ensure that the authorization using
both types of token works.

This introduces two new environment variables,
RESTIC_TEST_AZURE_ACCOUNT_SAS and RESTIC_TEST_AZURE_CONTAINER_SAS, that
contain the tokens to use when testing restic. If an environment
variable is missing, the related test is skipped.
2024-10-17 20:38:03 +02:00
Connor Findlay
7bdfcf13fb changelog: Add changes in issue-4004
Add changelog entry in the 'unreleased' sub-folder for changes
introduced when fixing issue #4004.
2024-10-17 20:38:03 +02:00
Connor Findlay
2e704c69ac backend/azure: Handle Container SAS/SAT
Ignore AuthorizationFailure caused by using a container level SAS/SAT
token when calling GetProperties during the Create() call. This is because the
GetProperties call expects an Account Level token, and the container
level token simply lacks the appropriate permissions. Supressing the
Authorization Failure is OK, because if the token is actually invalid,
this is caught elsewhere when we try to actually use the token to do
work.
2024-10-17 20:38:03 +02:00
Michael Eischer
5838896962 doc: document safety feature for --target / --delete 2024-10-17 19:45:03 +02:00
Michael Eischer
bcd5ac34bb Merge pull request #5060 from MichaelEischer/proper-nodefromfileinfo
fs: move NodeFromFileInfo into FS interface
2024-10-16 21:34:37 +02:00
Michael Eischer
618f306f13 Merge pull request #5054 from phillipp/dump-compress-zip
dump: add --compress flag to compress archives
2024-10-16 19:17:47 +00:00
Michael Eischer
75711446e1 fs: move NodeFromFileInfo into FS interface 2024-10-16 21:17:21 +02:00
Michael Eischer
c3b3120e10 Merge pull request #5057 from MichaelEischer/fix-backup-irregular
backup: fix handling of files with type irregular
2024-10-16 21:13:08 +02:00
Michael Eischer
e29d38f8bf dump/zip: test that files are compressed 2024-10-16 21:11:24 +02:00
Michael Eischer
da3c02405b dump/zip: only compress regular files 2024-10-16 21:09:05 +02:00
Michael Eischer
55c150054d add irregular files bug changelog 2024-10-16 20:54:08 +02:00
Michael Eischer
012cb06fe9 repair snapshots: remove irregular files 2024-10-16 20:54:08 +02:00
Michael Eischer
f44b7cdf8c backup: exclude irregular files from backup
restic cannot backup irregular files as those don't behave like normal
files. Thus skip them with an error.
2024-10-16 20:54:08 +02:00
Michael Eischer
e91a456656 Merge pull request #5061 from MichaelEischer/fix-timestamp-restore-windows
fs: fix restoring timestamps on older Windows versions for long paths
2024-10-16 20:47:17 +02:00
Michael Eischer
e21496f217 Merge pull request #5074 from greatroar/dump
dump: Simplify writeNode and use fewer goroutines
2024-10-16 18:33:35 +00:00
Michael Eischer
0c0d8b8cfd Merge pull request #5083 from greatroar/errors
Some error handling patches
2024-10-16 18:22:49 +00:00
Michael Eischer
60cba55647 Merge pull request #5079 from restic/dependabot/go_modules/google.golang.org/api-0.199.0
build(deps): bump google.golang.org/api from 0.195.0 to 0.199.0
2024-10-09 20:35:03 +00:00
dependabot[bot]
221fa0fa7c build(deps): bump google.golang.org/api from 0.195.0 to 0.199.0
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.195.0 to 0.199.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.195.0...v0.199.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-09 20:26:34 +00:00
Michael Eischer
7cfd8a6715 Merge pull request #5080 from restic/dependabot/go_modules/golang.org/x/oauth2-0.23.0
build(deps): bump golang.org/x/oauth2 from 0.22.0 to 0.23.0
2024-10-09 20:15:43 +00:00
Michael Eischer
0ada0b56b6 Merge pull request #5078 from restic/dependabot/go_modules/github.com/minio/minio-go/v7-7.0.77
build(deps): bump github.com/minio/minio-go/v7 from 7.0.76 to 7.0.77
2024-10-09 20:09:05 +00:00
Michael Eischer
7c12bd59a0 Merge pull request #5053 from rominf/rominf-generate-stdout
generate: allow passing `-` for stdout output
2024-10-09 20:06:54 +00:00
Michael Eischer
888abff7e0 Merge pull request #5058 from MichaelEischer/clarify-changelog
Changelogs should omit problem if its description duplicates the new behavior
2024-10-09 22:06:41 +02:00
Michael Eischer
783901726e Merge pull request #5056 from MichaelEischer/fix-tag-error-handling
tag: fix swallowed error if repository cannot be opened
2024-10-09 22:06:26 +02:00
dependabot[bot]
eac00eb933 build(deps): bump golang.org/x/oauth2 from 0.22.0 to 0.23.0
Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.22.0 to 0.23.0.
- [Commits](https://github.com/golang/oauth2/compare/v0.22.0...v0.23.0)

---
updated-dependencies:
- dependency-name: golang.org/x/oauth2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-09 19:58:42 +00:00
Michael Eischer
96c1c1a0fc Merge pull request #5075 from greatroar/idset
internal/restic: Use IDSet.Clone + use maps package
2024-10-09 19:55:26 +00:00
Michael Eischer
8d7f4574b4 Merge pull request #5077 from restic/dependabot/go_modules/go.uber.org/automaxprocs-1.6.0
build(deps): bump go.uber.org/automaxprocs from 1.5.3 to 1.6.0
2024-10-09 19:51:15 +00:00
Michael Eischer
ddf65b04f3 Merge pull request #5076 from restic/dependabot/go_modules/golang.org/x/sys-0.25.0
build(deps): bump golang.org/x/sys from 0.24.0 to 0.25.0
2024-10-09 19:50:45 +00:00
greatroar
2b609d3e77 errors, fs: Replace CombineErrors with stdlib Join
This does not produce exactly the same messages, as it inserts newlines
instead of "; ". But given how long our error messages can be, that
might be a good thing.
2024-10-05 10:56:40 +02:00
greatroar
19653f9e06 fs: Simplify NodeCreateAt 2024-10-05 10:56:39 +02:00
greatroar
e10e2bb50f fs: Include filename in mknod errors 2024-10-05 10:56:39 +02:00
greatroar
b5c28a7ba2 internal/restic: Use IDSet.Clone + use maps package
One place where IDSet.Clone is useful was reinventing it, using a
conversion to list, a sort, and a conversion back to map.

Also, use the stdlib "maps" package to implement as much of IDSet as
possible. This requires changing one caller, which assumed that cloning
nil would return a non-nil IDSet.
2024-10-03 21:14:29 +02:00
dependabot[bot]
f3f629bb69 build(deps): bump github.com/minio/minio-go/v7 from 7.0.76 to 7.0.77
Bumps [github.com/minio/minio-go/v7](https://github.com/minio/minio-go) from 7.0.76 to 7.0.77.
- [Release notes](https://github.com/minio/minio-go/releases)
- [Commits](https://github.com/minio/minio-go/compare/v7.0.76...v7.0.77)

---
updated-dependencies:
- dependency-name: github.com/minio/minio-go/v7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-01 01:49:46 +00:00
dependabot[bot]
e90085b375 build(deps): bump go.uber.org/automaxprocs from 1.5.3 to 1.6.0
Bumps [go.uber.org/automaxprocs](https://github.com/uber-go/automaxprocs) from 1.5.3 to 1.6.0.
- [Release notes](https://github.com/uber-go/automaxprocs/releases)
- [Changelog](https://github.com/uber-go/automaxprocs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/uber-go/automaxprocs/compare/v1.5.3...v1.6.0)

---
updated-dependencies:
- dependency-name: go.uber.org/automaxprocs
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-01 01:49:41 +00:00
dependabot[bot]
3f08dee685 build(deps): bump golang.org/x/sys from 0.24.0 to 0.25.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.24.0 to 0.25.0.
- [Commits](https://github.com/golang/sys/compare/v0.24.0...v0.25.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-01 01:49:38 +00:00
greatroar
8c7a6daa47 dump: Simplify writeNode and use fewer goroutines
This changes Dumper.writeNode to spawn loader goroutines as needed
instead of as a pool. The code is shorter, fewer goroutines are spawned
for small files, and crash dumps (also for unrelated errors) should be
smaller.
2024-09-30 17:24:05 +02:00
Roman Inflianskas
3d976562fa generate: allow passing - for stdout output
Since generating completions to stdout for multiple shells does not make
sense, enforce `-` is supplied only once.
2024-09-16 10:54:00 +03:00
Phillipp Röll
1a7fafc7eb dump: compress zip archives 2024-09-15 21:04:54 +02:00
Michael Eischer
4469fe1575 fs: fix restoring timestamps on Windows for long paths 2024-09-15 18:28:11 +02:00
Phillipp Röll
bad6c54a33 dump: add --compress-zip flag to compress zip archives 2024-09-15 14:25:02 +02:00
Michael Eischer
7680f48258 Changelogs should omit problem if it duplicates the new behavior
When adding a new feature, the problem description often just says that
feature Y was missing, followed by saying that feature Y is now
supported.

This duplication just makes the changelog entries unnecessarily verbose.
2024-09-14 20:54:27 +02:00
Michael Eischer
efec1a5e96 Merge pull request #5045 from MichaelEischer/fix-preallocate-eintr
Linux: retry preallocate if interrutped by signal
2024-09-14 19:17:51 +02:00
Michael Eischer
bd2c986592 Merge pull request #5051 from rominf/rominf-list-subcommands
list: complete and validate subcommand
2024-09-14 16:43:04 +00:00
Michael Eischer
cab6b15603 tag: fix swallowed error if repository cannot be opened 2024-09-14 18:38:48 +02:00
Michael Eischer
4105e4a356 Merge pull request #5047 from damoclark/patch-1
cache: fix race condition in cache cleanup or similar.
2024-09-14 16:14:48 +00:00
Michael Eischer
ccf5be235a add changelog for fuse fix 2024-09-14 18:11:44 +02:00
Michael Eischer
5ce6ca2219 fuse: test that the same fs.Node is used for the same file 2024-09-14 18:11:44 +02:00
Michael Eischer
51173c5003 fuse: forget fs.Node instances on request by the kernel
Forget fs.Node instances once the kernel frees the corresponding nodeId.
This ensures that restic does not run out of memory on large snapshots.
2024-09-14 18:11:44 +02:00
Michael Eischer
e9940f39dc fuse: add missing type assertion for optional interfaces 2024-09-14 18:11:44 +02:00
Michael Eischer
6ec2b62ec5 fuse: cache fs.Node instances
A particular node should always be represented by a single instance.
This is necessary to allow the fuse library to assign a stable nodeId to
a node. macOS Sonoma trips over the previous, unstable behavior when
using fuse-t.
2024-09-14 18:11:44 +02:00
Damien Clark
4795143d6d cache: fix race condition in cache cleanup
Fix multiple restic processes executing concurrently and racing to remove obsolete snapshots.

Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2024-09-14 18:07:46 +02:00
Roman Inflianskas
a84e65b7f9 list: validate subcommand 2024-09-13 12:23:26 +03:00
Roman Inflianskas
6f08dbb2d7 list: add subcommand completion 2024-09-13 12:22:53 +03:00
Michael Eischer
c1532179d4 Merge pull request #5043 from MichaelEischer/fix-github-release-note-formatting
Fix indentation of blockquotes in github release notes
2024-09-07 17:11:22 +02:00
Michael Eischer
34fe73ea42 fs: retry preallocate on Linux if interrupted by signal 2024-09-07 16:39:40 +02:00
Michael Eischer
37d5bd61a0 Merge pull request #5042 from solracsf/patch-1
docs: Recommend to setup B2 versions lifecycle rules
2024-09-07 14:36:29 +00:00
Michael Eischer
7b1a15916d Merge pull request #5039 from konidev20/fix-gh-4806-forget-add-reason-for-oldest-snapshot-retained
forget: indicate why the oldest snapshot in a group is kept
2024-09-07 14:31:47 +00:00
Git'Fellow
113439c69b fix: shorten sentence 2024-09-07 15:27:15 +02:00
Srigovind Nayak
5468e85222 docs: mention that the oldest snapshot is marked oldest in the reasons of the forget comman 2024-09-07 15:07:23 +05:30
Srigovind Nayak
b69c6408a6 forget: make oldest snapshot marker more strict
Now, a snapshot is only marked as oldest if it's the last in the list AND its values matches the last seen value for that bucket.

Also, updated the corresponding golden files for the tests.
2024-09-07 15:07:23 +05:30
Srigovind Nayak
d656a50852 forget: update tests to reflect specific reasons for keeping oldest snapshots in a group 2024-09-07 15:07:23 +05:30
Srigovind Nayak
87f30bc787 forget: indicate why the oldest snapshot in a group is kept
When the oldest snapshot in the
list is retained, the reason is now prefixed with "oldest" to clearly
indicate why it's being kept.
2024-09-07 15:07:23 +05:30
Michael Eischer
4f0affd4f7 Merge branch 'patch-release' 2024-09-06 22:32:22 +02:00
Michael Eischer
3df8337d63 Fix indentation of blockquotes in github release notes 2024-09-05 22:33:57 +02:00
Git'Fellow
00ca0b371b docs: Recommend to setup B2 versions lifecycle rules 2024-09-04 13:21:37 +02:00
Michael Eischer
8a0edde407 Merge pull request #5038 from restic/dependabot/go_modules/google.golang.org/api-0.195.0
build(deps): bump google.golang.org/api from 0.191.0 to 0.195.0
2024-09-01 22:36:39 +00:00
Michael Eischer
0a225049d8 Merge pull request #5035 from restic/dependabot/go_modules/github.com/minio/minio-go/v7-7.0.76
build(deps): bump github.com/minio/minio-go/v7 from 7.0.74 to 7.0.76
2024-09-01 22:14:47 +00:00
Michael Eischer
3023b2f566 Merge pull request #5033 from MichaelEischer/s3-clarify-docs
docs: make s3-compatible section standalone
2024-09-02 00:14:31 +02:00
dependabot[bot]
a6490feab2 build(deps): bump github.com/minio/minio-go/v7 from 7.0.74 to 7.0.76
Bumps [github.com/minio/minio-go/v7](https://github.com/minio/minio-go) from 7.0.74 to 7.0.76.
- [Release notes](https://github.com/minio/minio-go/releases)
- [Commits](https://github.com/minio/minio-go/compare/v7.0.74...v7.0.76)

---
updated-dependencies:
- dependency-name: github.com/minio/minio-go/v7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-01 22:00:55 +00:00
Michael Eischer
daa6448a77 Merge pull request #5034 from restic/dependabot/go_modules/golang.org/x/sys-0.24.0
build(deps): bump golang.org/x/sys from 0.23.0 to 0.24.0
2024-09-01 21:52:56 +00:00
Michael Eischer
07a8b73f25 Merge pull request #5037 from restic/dependabot/go_modules/github.com/ncw/swift/v2-2.0.3
build(deps): bump github.com/ncw/swift/v2 from 2.0.2 to 2.0.3
2024-09-01 21:52:41 +00:00
Michael Eischer
9a6059eb71 Merge pull request #5032 from dropbigfish/master
chore: fix some function name comments
2024-09-01 21:52:26 +00:00
dependabot[bot]
790dbd442b build(deps): bump google.golang.org/api from 0.191.0 to 0.195.0
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.191.0 to 0.195.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.191.0...v0.195.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-01 01:33:45 +00:00
dependabot[bot]
daf156a76a build(deps): bump github.com/ncw/swift/v2 from 2.0.2 to 2.0.3
Bumps [github.com/ncw/swift/v2](https://github.com/ncw/swift) from 2.0.2 to 2.0.3.
- [Release notes](https://github.com/ncw/swift/releases)
- [Changelog](https://github.com/ncw/swift/blob/master/RELEASE.md)
- [Commits](https://github.com/ncw/swift/compare/v2.0.2...v2.0.3)

---
updated-dependencies:
- dependency-name: github.com/ncw/swift/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-01 01:33:35 +00:00
dependabot[bot]
154ca4d9e8 build(deps): bump golang.org/x/sys from 0.23.0 to 0.24.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.23.0 to 0.24.0.
- [Commits](https://github.com/golang/sys/compare/v0.23.0...v0.24.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-01 01:33:18 +00:00
Michael Eischer
ebd8f0c74a docs: make s3-compatible section standalone 2024-08-31 19:39:30 +02:00
dropbigfish
6f9513d88c chore: fix some function names
Signed-off-by: dropbigfish <fillfish@foxmail.com>
2024-09-01 00:54:39 +08:00
Michael Eischer
d8be8f1e06 Merge pull request #5024 from MichaelEischer/move-node-to-fs
Cleanup FS package
2024-08-31 18:47:11 +02:00
Michael Eischer
b91ef3f1ff fs: remove dead code 2024-08-31 18:40:36 +02:00
Michael Eischer
e2bce1b9ee fs: move WindowsAttributes definition back to restic package 2024-08-31 18:40:36 +02:00
Michael Eischer
ebdd946ac1 fs: unexport nodeRestoreTimestamps 2024-08-31 18:40:36 +02:00
Michael Eischer
2aa1e2615b fs: fix comments 2024-08-31 18:40:36 +02:00
Michael Eischer
6c16733dfd fs: remove unused methods from File interface 2024-08-31 18:40:36 +02:00
Michael Eischer
f0329bb4e6 fs: replace statT with ExtendedFileInfo 2024-08-31 18:40:36 +02:00
Michael Eischer
6d3a5260d3 fs: unexport a several windows functions 2024-08-31 18:40:36 +02:00
Michael Eischer
cf051e777a fs: remove Readdir method from File interface 2024-08-31 18:20:41 +02:00
Michael Eischer
cc7f99125a minimize usage of internal/fs in tests 2024-08-31 18:20:41 +02:00
Michael Eischer
65a7157383 mount: use os instead of fs package 2024-08-31 18:20:41 +02:00
Michael Eischer
24f4e780f1 backend: consistently use os package for filesystem access
The go std library should be good enough to manage the files in the
backend and cache folders.
2024-08-31 18:20:40 +02:00
Michael Eischer
ca1e5e10b6 add proper constants for node type 2024-08-31 18:20:01 +02:00
Michael Eischer
3b438e5c7c Merge pull request #5023 from MichaelEischer/cleanup-archiver
archiver: use FS interface nearly everywhere and cleanup exports
2024-08-31 18:14:47 +02:00
Michael Eischer
7bb92dc7bd archiver: use ExtendedStat from FS interface
With this change, NodeFromFileInfo is the last function that bypasses
the FS interface in the archiver.
2024-08-31 18:05:09 +02:00
Michael Eischer
e79dca644e fs: unexport DeviceID 2024-08-31 18:04:53 +02:00
Michael Eischer
70fbad6623 archiver: minimize imports 2024-08-31 18:04:37 +02:00
Michael Eischer
6fd5d5f2d5 archiver: move helper functions to combine rejects 2024-08-31 18:04:22 +02:00
Michael Eischer
f1585af0f2 move include/exclude options to filter package 2024-08-31 18:04:07 +02:00
Michael Eischer
5d58945718 cleanup include / exclude option setup 2024-08-31 18:03:53 +02:00
Michael Eischer
41c031a19e backup: move RejectFuncs to archiver package 2024-08-31 18:03:35 +02:00
Michael Eischer
f9dbcd2531 backup: convert reject funcs to use FS interface
Depending on parameters the paths in a snapshot do not directly
correspond to real paths on the filesystem. Therefore, reject funcs must
use the FS interface to work correctly.
2024-08-31 18:03:02 +02:00
Michael Eischer
c6fae0320e archiver: hide implementation details 2024-08-31 17:52:45 +02:00
Michael Eischer
e5cdae9c84 Merge pull request #5022 from MichaelEischer/extract-fs-code
Extract filesystem code from restic.Node
2024-08-31 17:52:11 +02:00
Michael Eischer
507842b614 fs: remove Open method from FS interface 2024-08-31 17:37:25 +02:00
Michael Eischer
263709da8c fs: unexport isListxattrPermissionError 2024-08-31 17:37:25 +02:00
Michael Eischer
80ed863aab repository: remove redundant cleanup code
The temp files used by the packer manager are either delete after
creation (unix) or marked as delete on close (windows). Thus, no
explicit cleanup is necessary.
2024-08-31 17:37:25 +02:00
Michael Eischer
0ddb4441d7 fs: clean up helper functions 2024-08-31 17:37:25 +02:00
Michael Eischer
fc549c9462 cleanup imports 2024-08-31 17:37:25 +02:00
Michael Eischer
b9b32e5647 restic: extract Node filesystem code to fs package 2024-08-31 17:37:25 +02:00
Michael Eischer
a2e54eac64 restic: simplify nodeCreateFileAt
The code to write the file content is never used.
2024-08-31 17:37:25 +02:00
Michael Eischer
5644079707 restic: prepare extraction of fs code from Node 2024-08-31 17:37:25 +02:00
Michael Eischer
3e0c081bed Merge pull request #5020 from MichaelEischer/remove-legacy-formats
Remove support for legacy index format and s3 layout
2024-08-31 17:37:09 +02:00
Michael Eischer
97f696b937 backend: remove dead code 2024-08-31 17:25:24 +02:00
Michael Eischer
af989aab4e backend/layout: unexport fields and simplify rest layout 2024-08-31 17:25:24 +02:00
Michael Eischer
6024597028 drop support for s3legacy layout 2024-08-31 17:25:24 +02:00
Michael Eischer
943b6ccfba index: remove support for legacy index format 2024-08-31 17:12:43 +02:00
Michael Eischer
a5533344f9 Merge pull request #5028 from MichaelEischer/windows-allow-specifying-volumes
backup: support specifying volume instead of path on Windows
2024-08-31 16:43:20 +02:00
Michael Eischer
ddf35a60ad Merge pull request #5026 from MichaelEischer/fix-handling-invalid-filenames
cache: Fix handling of invalid filenames
2024-08-31 16:42:13 +02:00
Michael Eischer
4fcedb4bae backup: support specifying volume instead of path on Windows
"C:" (volume name) versus "C:\" (path)
2024-08-30 11:35:43 +02:00
Michael Eischer
a0f2dfbc19 Merge pull request #5019 from MichaelEischer/fix-windows-sd-race
backup: Fix spurious "A Required Privilege Is Not Held by the Client" error
2024-08-29 16:59:06 +02:00
Michael Eischer
0aadfe32bb Merge pull request #5018 from MichaelEischer/rest-retry-http2-goaway
rest: improve handling of HTTP2 goaway
2024-08-29 16:58:04 +02:00
Michael Eischer
dab3e549af Merge pull request #5017 from MichaelEischer/rewrite-data-loss
rewrite: Document handling of "cannot encode tree" errors
2024-08-29 16:57:13 +02:00
Michael Eischer
5c238ea359 Merge pull request #5016 from MichaelEischer/s3-doc-rework
Rework documentation for s3-compatible storages
2024-08-29 16:55:40 +02:00
Michael Eischer
2c85d2468a Merge pull request #5015 from MichaelEischer/update-exit-code-docs
Update exit code docs
2024-08-29 16:53:14 +02:00
Michael Eischer
7bbf75237d Merge pull request #5014 from MichaelEischer/configurable-slow-request-timeout
Make timeout for slow requests configurable
2024-08-29 16:52:24 +02:00
Michael Eischer
dd90e1926b use OrderedListOnceBackend where possible 2024-08-29 16:35:48 +02:00
Michael Eischer
d19f706d50 Add temporary files repositories in integration tests
This is intended to catch problems with temporary files stored in the
backend, even if the responsible component forgets to test for those.
2024-08-29 16:33:18 +02:00
Michael Eischer
8eff4e0e5c cache: correctly ignore files whose filename is no ID
this can for example be the case for temporary files created by the
backend implementation.
2024-08-29 16:32:15 +02:00
Michael Eischer
45d05eb691 add changelog for security descriptor race condition 2024-08-26 19:43:18 +02:00
Michael Eischer
9c70794886 fs: fix error handling for retried get/set of security descriptor
The retry code path did not filter `ERROR_NOT_SUPPORTED`. Just call the
original function a second time to correctly follow the low privilege
code path.
2024-08-26 19:36:43 +02:00
Michael Eischer
6fbfccc2d3 fs: fix race condition in get/set security descriptor
Calling `Load()` twice for an atomic variable can return different
values each time. This resulted in trying to read the security
descriptor with high privileges, but then not entering the code path to
switch to low privileges when another thread has already done so
concurrently.
2024-08-26 19:31:21 +02:00
Michael Eischer
1931beab8e Merge pull request #5012 from MichaelEischer/fix-lock-retries
lock: introduce short delay between failed locking retries
2024-08-26 18:10:30 +02:00
Michael Eischer
2296fdf668 lock: introduce short delay between failed locking retries
Failed locking attempts were immediately retried up to three times
without any delay between the retries. If a lock file is not found while
checking for other locks, with the reworked backend retries there is no
delay between those retries. This is a problem if a backend requires a
few seconds to reflect file deletions in the file listings. To work
around this problem, introduce a short exponentially increasing delay
between the retries. The number of retries is now increased to 4. This
results in delays of 5, 10 and 20 seconds between the retries.
2024-08-26 16:31:42 +02:00
Michael Eischer
89d216ca76 Merge pull request #5011 from MichaelEischer/fix-canceled-retry
backend/retry: don't trip circuit breaker if context is canceled
2024-08-26 16:30:03 +02:00
Michael Eischer
5cffd40002 Merge pull request #5013 from MichaelEischer/group-cli-commands
Group CLI commands and show features/options
2024-08-26 16:23:39 +02:00
Michael Eischer
e24dd5a162 backend/retry: don't trip circuit breaker if context is canceled
When the context used for a load operation is canceled, then the result
is always an error independent of whether the file could be retrieved
from the backend. Do not false positively trip the circuit breaker in
this case.

The old behavior was problematic when trying to lock a repository. When
`Lock.checkForOtherLocks` listed multiple lock files in parallel and one
of them fails to load, then all other loads were canceled. This
cancelation was remembered by the circuit breaker, such that locking
retries would fail.
2024-08-26 16:22:21 +02:00
Michael Eischer
2063bf5de4 Merge pull request #5006 from MichaelEischer/restore-time-last
restic: restore timestamps after extended attributes
2024-08-26 16:21:02 +02:00
Michael Eischer
36c4475ad9 rest: improve handling of HTTP2 goaway
The HTTP client can only retry HTTP2 requests after receiving a GOAWAY
response if it can rewind the body. As we use a custom data type,
explicitly provide an implementation of `GetBody`.
2024-08-26 15:44:17 +02:00
Michael Eischer
dc5d3fc473 doc: full tree blob data structure is in the code 2024-08-26 14:41:09 +02:00
Michael Eischer
05077eaa20 doc: JSON encoder must be deterministic 2024-08-26 14:41:09 +02:00
Michael Eischer
908d097904 doc: mark S3 layout as deprecated 2024-08-26 14:41:09 +02:00
Michael Eischer
828c8bc1e8 doc: describe how to handle rewrite encoding error 2024-08-26 14:41:09 +02:00
Michael Eischer
b8f409723d make timeout for slow requests configurable 2024-08-26 14:14:43 +02:00
Michael Eischer
8a8f5f3986 doc: fix typos 2024-08-26 12:24:02 +02:00
Michael Eischer
7de53a51b8 doc: shrink wasabi / alibaba cloud example
Remove descriptions for both providers and shorten the example to the
minimum.
2024-08-26 12:21:13 +02:00
Michael Eischer
9649a9c62b doc: use regional urls for Amazon S3 and add generic s3 provider section
Split description for non-Amazon S3 providers into separate section. The
section now also includes the `s3.bucket-lookup` extended option. Switch
to using regional URLs for Amazon S3 to replace the need for setting the
region.
2024-08-26 12:17:43 +02:00
Michael Eischer
354c2c38cc doc/backup: move exit status codes section up 2024-08-25 23:53:12 +02:00
Michael Eischer
ff9ef08f65 doc/backup: link to exit code for scripting section 2024-08-25 23:52:33 +02:00
Michael Eischer
311b27ced8 restic: cleanup redundant code in test case 2024-08-25 23:18:55 +02:00
Michael Eischer
43b36ad2b0 restore: test timestamps for macOS resource forks are restored correctly 2024-08-25 23:18:55 +02:00
Michael Eischer
2e55209b34 restic: restore timestamps after extended attributes
restoring the xattr containing resource forks on macOS apparently
modifies the file modification timestamps. Thus, restore the timestamp
after xattrs.
2024-08-25 23:18:55 +02:00
Michael Eischer
e7db5febcf update docs 2024-08-23 23:52:21 +02:00
Michael Eischer
7739aa685c Add missing DisableAutoGenTag flag for commands 2024-08-23 23:49:20 +02:00
Michael Eischer
5988d825b7 group commands and make features/options visible 2024-08-23 23:48:45 +02:00
Michael Eischer
a8efaee03c Merge pull request #5010 from MichaelEischer/cleanup-cli-help
Improve description for  --from-insecure-no-password option
2024-08-23 23:41:08 +02:00
Michael Eischer
8672cef972 Merge pull request #5009 from restic/document-restic-host
Mention RESTIC_HOST environment variable in docs
2024-08-23 23:40:48 +02:00
Michael Eischer
551dfee707 Improve description for no password on secondary repo 2024-08-18 19:45:54 +02:00
Michael Eischer
1b8ca32e7d Mention RESTIC_HOST environment variable in docs 2024-08-18 19:41:58 +02:00
Michael Eischer
489af2a670 Merge pull request #5008 from mikix/doc-typo
docs: correct wrong exit_error message field name
2024-08-18 17:38:31 +00:00
Michael Terry
97df01b9b8 docs: correct wrong exit_error message field name 2024-08-17 15:00:39 -04:00
Michael Eischer
68f7abcff1 Merge pull request #5007 from deining/fix-warnings
GitHub test actions: fix warnings 'Restore cache failed'
2024-08-17 14:31:41 +00:00
Andreas Deininger
ceb45d9816 GitHub test actions: fix warnings 'Restore cache failed' 2024-08-17 12:39:41 +02:00
Michael Eischer
5cca6e66be Merge pull request #4981 from konidev20/fix-gh-4934-cleanup-removed-snaphots-from-cache
cache: clear snapshot files from cache during load index
2024-08-16 19:04:59 +00:00
Srigovind Nayak
c9097994b9 changelog: update changelog 2024-08-17 00:24:19 +05:30
Michael Eischer
c636ad51a8 Merge pull request #4959 from mikix/fatal-wrap
main: return an exit code (12) for "bad password" errors
2024-08-16 18:52:36 +00:00
Srigovind Nayak
88174cd0a4 cache: remove redundant index file cleanup
addressing code review comments
2024-08-17 00:21:49 +05:30
Srigovind Nayak
b7d014b685 Revert "repository: removed redundant prepareCache method from Repository"
This reverts commit 720609f8ba.
2024-08-17 00:18:13 +05:30
Michael Terry
56f28c9bd5 main: return an exit code (12) for "bad password" errors 2024-08-15 16:55:45 -04:00
Michael Eischer
7462471c6b Merge pull request #4952 from mikix/json-exit
Format exit errors as JSON if requested
2024-08-15 20:19:38 +00:00
Michael Eischer
74d3f92cc7 Merge pull request #4993 from MichaelEischer/fix-timeout-error
backend: return correct error on upload/request timeout
2024-08-15 22:07:37 +02:00
Michael Eischer
80f24584a5 Merge pull request #4998 from zmanda/ea_vss_fix
Fix extended attributes handling for VSS snapshots
2024-08-15 19:51:35 +00:00
Michael Eischer
8e00158c34 Merge pull request #5000 from deining/fix-typo
Fix typos
2024-08-15 19:42:14 +00:00
Michael Eischer
36b5580c1c Merge pull request #4989 from plant99/progress-bar-for-restore-verify
restore: Add progress bar to 'restore --verify'
2024-08-15 19:34:05 +00:00
aneesh-n
19f487750e Add test cases and handle volume GUID paths
Gracefully handle errors while checking for EA and add debug logs.
2024-08-11 19:25:58 -06:00
Shivashis Padhi
f1407afd1f restore: Add progress bar to 'restore --verify' 2024-08-11 22:25:21 +02:00
Andreas Deininger
4401265e36 Fix typos 2024-08-11 21:38:15 +02:00
Srigovind Nayak
5fd984ba6f cache: add test for the automated cache clear to cache backend 2024-08-11 23:41:07 +05:30
Srigovind Nayak
506e07127f changelog: add unrelease changelog 2024-08-11 23:41:07 +05:30
Srigovind Nayak
720609f8ba repository: removed redundant prepareCache method from Repository
* remove the prepareCache method from the Repository
* changed the signature of the SetIndex function to no longer return an error
2024-08-11 23:41:07 +05:30
Srigovind Nayak
a23e7bfb82 cache: check for context cancellation before clearing cache 2024-08-11 23:41:07 +05:30
Srigovind Nayak
f66624f5bf cache: backend add List method and a cache clear functionality
* removes files which are no longer in the repository, including index files, snapshot files and pack files from the cache.

cache: fix ids set initialisation with NewIDSet()
2024-08-11 23:40:52 +05:30
Michael Terry
d3f9c05312 docs: update scripting documentation 2024-08-11 12:52:54 -04:00
Michael Terry
6283915f86 main: format exit errors as JSON when using --json 2024-08-11 12:52:50 -04:00
Michael Terry
2d250a9135 version: add message_type in --json mode 2024-08-11 12:51:15 -04:00
Michael Eischer
33c670dd7a Merge pull request #4996 from restic/dependabot/go_modules/google.golang.org/api-0.191.0
build(deps): bump google.golang.org/api from 0.189.0 to 0.191.0
2024-08-11 09:25:19 +00:00
aneesh-n
849c441455 Gracefully handle invalid prepared volume names 2024-08-11 01:48:25 -06:00
aneesh-n
b5b5c1fe8e Add changelog 2024-08-11 01:32:55 -06:00
aneesh-n
1d392a36f9 Fix extended attributes handling for VSS snapshots 2024-08-11 01:23:47 -06:00
dependabot[bot]
049186371f build(deps): bump google.golang.org/api from 0.189.0 to 0.191.0
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.189.0 to 0.191.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.189.0...v0.191.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-10 18:17:20 +00:00
Michael Eischer
910f64ce47 Merge pull request #4997 from restic/dependabot/go_modules/github.com/Azure/azure-sdk-for-go/sdk/azcore-1.14.0
build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azcore from 1.13.0 to 1.14.0
2024-08-10 18:11:28 +00:00
Michael Eischer
b3b71e78cd Merge pull request #4995 from restic/dependabot/go_modules/golang.org/x/crypto-0.26.0
build(deps): bump golang.org/x/crypto from 0.25.0 to 0.26.0
2024-08-10 18:08:20 +00:00
dependabot[bot]
f2e2e5f5ab build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azcore
Bumps [github.com/Azure/azure-sdk-for-go/sdk/azcore](https://github.com/Azure/azure-sdk-for-go) from 1.13.0 to 1.14.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.13.0...sdk/azcore/v1.14.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azcore
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-10 17:58:58 +00:00
dependabot[bot]
ecd03b4fc6 build(deps): bump golang.org/x/crypto from 0.25.0 to 0.26.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.25.0 to 0.26.0.
- [Commits](https://github.com/golang/crypto/compare/v0.25.0...v0.26.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-10 17:58:50 +00:00
Michael Eischer
3f5e2160de Merge pull request #4938 from MichaelEischer/bump-go-version
Bump go version to 1.21
2024-08-10 19:57:59 +02:00
Michael Eischer
400ae55940 replace deprecated usages of math/rand 2024-08-10 19:34:49 +02:00
Michael Eischer
84c79f1456 bump required go version to 1.21 2024-08-10 19:16:10 +02: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
fbecc9db66 upgrade all direct dependencies 2024-08-10 19:16:10 +02:00
Michael Eischer
ad48751adb bump required go version to 1.21 2024-08-10 19:16:10 +02:00
Michael Eischer
853a686994 backend: return correct error on upload/request timeout 2024-08-10 18:06:24 +02:00
628 changed files with 20745 additions and 14730 deletions

12
.dockerignore Normal file
View File

@@ -0,0 +1,12 @@
# Actual layer caching is impossible due to .git, but
# that must be included for provenance reasons. These ignores
# are strictly for hygenic build.
*
!/*.go
!/go.*
!/cmd/*
!/docker/entrypoint.sh
!/internal/*
!/helpers/*
!/VERSION
!/.git/

View File

@@ -28,13 +28,15 @@ Checklist
You do not need to check all the boxes below all at once. Feel free to take
your time and add more commits. If you're done and ready for review, please
check the last box. Enable a checkbox by replacing [ ] with [x].
Please always follow these steps:
- Read the [contribution guidelines](https://github.com/restic/restic/blob/master/CONTRIBUTING.md#providing-patches).
- Enable [maintainer edits](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork).
- Run `gofmt` on the code in all commits.
- Format all commit messages in the same style as [the other commits in the repository](https://github.com/restic/restic/blob/master/CONTRIBUTING.md#git-commits).
-->
- [ ] I have read the [contribution guidelines](https://github.com/restic/restic/blob/master/CONTRIBUTING.md#providing-patches).
- [ ] I have [enabled maintainer edits](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork).
- [ ] I have added tests for all code changes.
- [ ] I have added tests for all code changes, see [writing tests](https://restic.readthedocs.io/en/stable/090_participating.html#writing-tests)
- [ ] I have added documentation for relevant changes (in the manual).
- [ ] There's a new file in `changelog/unreleased/` that describes the changes for our users (see [template](https://github.com/restic/restic/blob/master/changelog/TEMPLATE)).
- [ ] I have run `gofmt` on the code in all commits.
- [ ] All commit messages are formatted in the same style as [the other commits in the repo](https://github.com/restic/restic/blob/master/CONTRIBUTING.md#git-commits).
- [ ] I'm done! This pull request is ready for review.

View File

@@ -5,6 +5,10 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
groups:
golang-x-deps:
patterns:
- "golang.org/x/*"
# Dependencies listed in .github/workflows/*.yml
- package-ecosystem: "github-actions"

View File

@@ -20,12 +20,16 @@ jobs:
contents: read
packages: write
outputs:
image: ${{ steps.image.outputs.image }}
digest: ${{ steps.build-and-push.outputs.digest }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
@@ -37,6 +41,7 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
@@ -55,6 +60,7 @@ jobs:
if: github.ref != 'refs/heads/master'
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@15560696de535e4014efeff63c48f16952e52dd1
with:
push: true
@@ -64,3 +70,26 @@ jobs:
pull: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Output image
id: image
run: |
# NOTE: Set the image as an output because the `env` context is not
# available to the inputs of a reusable workflow call.
image_name="${REGISTRY}/${IMAGE_NAME}"
echo "image=$image_name" >> "$GITHUB_OUTPUT"
provenance:
needs: [build-and-push-image]
permissions:
actions: read # for detecting the Github Actions environment.
id-token: write # for creating OIDC tokens for signing.
packages: write # for uploading attestations.
if: github.repository == 'restic/restic'
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.1.0
with:
image: ${{ needs.build-and-push-image.outputs.image }}
digest: ${{ needs.build-and-push-image.outputs.digest }}
registry-username: ${{ github.actor }}
secrets:
registry-password: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -13,7 +13,7 @@ permissions:
contents: read
env:
latest_go: "1.22.x"
latest_go: "1.25.x"
GO111MODULE: on
jobs:
@@ -23,39 +23,29 @@ jobs:
# list of jobs to run:
include:
- job_name: Windows
go: 1.22.x
go: 1.25.x
os: windows-latest
- job_name: macOS
go: 1.22.x
go: 1.25.x
os: macOS-latest
test_fuse: false
- job_name: Linux
go: 1.22.x
go: 1.25.x
os: ubuntu-latest
test_cloud_backends: true
test_fuse: true
check_changelog: true
- job_name: Linux (race)
go: 1.22.x
go: 1.25.x
os: ubuntu-latest
test_fuse: true
test_opts: "-race"
- job_name: Linux
go: 1.21.x
os: ubuntu-latest
test_fuse: true
- job_name: Linux
go: 1.20.x
os: ubuntu-latest
test_fuse: true
- job_name: Linux
go: 1.19.x
go: 1.24.x
os: ubuntu-latest
test_fuse: true
@@ -67,10 +57,10 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
@@ -195,7 +185,7 @@ jobs:
# prepare credentials for Google Cloud Storage tests in a temp file
export GOOGLE_APPLICATION_CREDENTIALS=$(mktemp --tmpdir restic-gcs-auth-XXXXXXX)
echo $RESTIC_TEST_GS_APPLICATION_CREDENTIALS_B64 | base64 -d > $GOOGLE_APPLICATION_CREDENTIALS
go test -cover -parallel 4 ./internal/backend/...
go test -cover -parallel 5 -timeout 15m ./internal/backend/...
# only run cloud backend tests for pull requests from and pushes to our
# own repo, otherwise the secrets are not available
@@ -214,7 +204,6 @@ jobs:
cross_compile:
strategy:
matrix:
# run cross-compile in three batches parallel so the overall tests run faster
subset:
@@ -231,10 +220,10 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Set up Go ${{ env.latest_go }}
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: ${{ env.latest_go }}
@@ -253,18 +242,18 @@ jobs:
checks: write
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Set up Go ${{ env.latest_go }}
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: ${{ env.latest_go }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.57.1
version: v2.4.0
args: --verbose --timeout 5m
# only run golangci-lint for pull requests, otherwise ALL hints get
@@ -298,7 +287,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Docker meta
id: meta

View File

@@ -1,69 +1,95 @@
# This is the configuration for golangci-lint for the restic project.
#
# A sample config with all settings is here:
# https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
version: "2"
linters:
# only enable the linters listed below
disable-all: true
default: none
enable:
- asciicheck
# ensure that http response bodies are closed
- bodyclose
# restrict imports from other restic packages for internal/backend (cache exempt)
- depguard
- copyloopvar
# make sure all errors returned by functions are handled
- errcheck
# show how code can be simplified
- gosimple
# make sure code is formatted
- gofmt
# examine code and report suspicious constructs, such as Printf calls whose
# arguments do not align with the format string
- govet
# make sure names and comments are used according to the conventions
- revive
# consistent imports
- importas
# detect when assignments to existing variables are not used
- ineffassign
- nolintlint
# make sure names and comments are used according to the conventions
- revive
# run static analysis and find errors
- staticcheck
# find unused variables, functions, structs, types, etc.
- unused
# parse and typecheck code
- typecheck
# ensure that http response bodies are closed
- bodyclose
- importas
issues:
# don't use the default exclude rules, this hides (among others) ignored
# errors from Close() calls
exclude-use-default: false
# list of things to not warn about
exclude:
# revive: do not warn about missing comments for exported stuff
- exported (function|method|var|type|const) .* should have comment or be unexported
# revive: ignore constants in all caps
- don't use ALL_CAPS in Go names; use CamelCase
# revive: lots of packages don't have such a comment
- "package-comments: should have a package comment"
# staticcheck: there's no easy way to replace these packages
- "SA1019: \"golang.org/x/crypto/poly1305\" is deprecated"
- "SA1019: \"golang.org/x/crypto/openpgp\" is deprecated"
exclude-rules:
# revive: ignore unused parameters in tests
- path: (_test\.go|testing\.go|backend/.*/tests\.go)
text: "unused-parameter:"
linters-settings:
importas:
alias:
- pkg: github.com/restic/restic/internal/test
alias: rtest
settings:
depguard:
rules:
# Prevent backend packages from importing the internal/restic package to keep the architectural layers intact.
backend-imports:
files:
- "**/internal/backend/**"
- "!**/internal/backend/cache/**"
- "!**/internal/backend/test/**"
- "!**/*_test.go"
deny:
- pkg: "github.com/restic/restic/internal/restic"
desc: "internal/restic should not be imported to keep the architectural layers intact"
- pkg: "github.com/restic/restic/internal/repository"
desc: "internal/repository should not be imported to keep the architectural layers intact"
importas:
alias:
- pkg: github.com/restic/restic/internal/test
alias: rtest
staticcheck:
checks:
# default
- "all"
- "-ST1000"
- "-ST1003"
- "-ST1016"
- "-ST1020"
- "-ST1021"
- "-ST1022"
# extra disables
- "-QF1008" # don't warn about specifing name of embedded field on access
exclusions:
rules:
# revive: ignore unused parameters in tests
- path: (_test\.go|testing\.go|backend/.*/tests\.go)
text: "unused-parameter:"
# revive: do not warn about missing comments for exported stuff
- path: (.+)\.go$
text: exported (function|method|var|type|const) .* should have comment or be unexported
# revive: ignore constants in all caps
- path: (.+)\.go$
text: don't use ALL_CAPS in Go names; use CamelCase
# revive: lots of packages don't have such a comment
- path: (.+)\.go$
text: "package-comments: should have a package comment"
# staticcheck: there's no easy way to replace these packages
- path: (.+)\.go$
text: 'SA1019: "golang.org/x/crypto/poly1305" is deprecated'
- path: (.+)\.go$
text: 'SA1019: "golang.org/x/crypto/openpgp" is deprecated'
- path: (.+)\.go$
text: "redefines-builtin-id:"
# revive: collection of helpers to implement a backend, more descriptive names would be too repetitive
- path: internal/backend/util/.*.go$
text: "var-naming: avoid meaningless package names"
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
# make sure code is formatted
- gofmt
exclusions:
paths:
- third_party$
- builtin$
- examples$

View File

@@ -1,5 +1,7 @@
# Table of Contents
* [Changelog for 0.18.1](#changelog-for-restic-0181-2025-09-21)
* [Changelog for 0.18.0](#changelog-for-restic-0180-2025-03-27)
* [Changelog for 0.17.3](#changelog-for-restic-0173-2024-11-08)
* [Changelog for 0.17.2](#changelog-for-restic-0172-2024-10-27)
* [Changelog for 0.17.1](#changelog-for-restic-0171-2024-09-05)
@@ -38,6 +40,485 @@
* [Changelog for 0.6.0](#changelog-for-restic-060-2017-05-29)
# Changelog for restic 0.18.1 (2025-09-21)
The following sections list the changes in restic 0.18.1 relevant to
restic users. The changes are ordered by importance.
## Summary
* Fix #5324: Correctly handle `backup --stdin-filename` with directory paths
* Fix #5325: Accept `RESTIC_HOST` environment variable in `forget` command
* Fix #5342: Ignore "chmod not supported" errors when writing files
* Fix #5344: Ignore `EOPNOTSUPP` errors for extended attributes
* Fix #5421: Fix rare crash if directory is removed during backup
* Fix #5429: Stop retrying uploads when rest-server runs out of space
* Fix #5467: Improve handling of download retries in `check` command
## Details
* Bugfix #5324: Correctly handle `backup --stdin-filename` with directory paths
In restic 0.18.0, the `backup` command failed if a filename that includes at
least a directory was passed to `--stdin-filename`. For example,
`--stdin-filename /foo/bar` resulted in the following error:
```
Fatal: unable to save snapshot: open /foo: no such file or directory
```
This has now been fixed.
https://github.com/restic/restic/issues/5324
https://github.com/restic/restic/pull/5356
* Bugfix #5325: Accept `RESTIC_HOST` environment variable in `forget` command
The `forget` command did not use the host name from the `RESTIC_HOST`
environment variable when filtering snapshots. This has now been fixed.
https://github.com/restic/restic/issues/5325
https://github.com/restic/restic/pull/5327
* Bugfix #5342: Ignore "chmod not supported" errors when writing files
Restic 0.18.0 introduced a bug that caused `chmod xxx: operation not supported`
errors to appear when writing to a local file repository that did not support
chmod (like CIFS or WebDAV mounted via FUSE). Restic now ignores those errors.
https://github.com/restic/restic/issues/5342
* Bugfix #5344: Ignore `EOPNOTSUPP` errors for extended attributes
Restic 0.18.0 added extended attribute support for NetBSD 10+, but not all
NetBSD filesystems support extended attributes. Other BSD systems can likewise
return `EOPNOTSUPP`, so restic now ignores these errors.
https://github.com/restic/restic/issues/5344
* Bugfix #5421: Fix rare crash if directory is removed during backup
In restic 0.18.0, the `backup` command could crash if a directory was removed
between reading its metadata and listing its directory content. This has now
been fixed.
https://github.com/restic/restic/pull/5421
* Bugfix #5429: Stop retrying uploads when rest-server runs out of space
When rest-server returns a `507 Insufficient Storage` error, it indicates that
no more storage capacity is available. Restic now correctly stops retrying
uploads in this case.
https://github.com/restic/restic/issues/5429
https://github.com/restic/restic/pull/5452
* Bugfix #5467: Improve handling of download retries in `check` command
In very rare cases, the `check` command could unnecessarily report repository
damage if the backend returned incomplete, corrupted data on the first download
try which is afterwards resolved by a download retry.
This could result in an error output like the following:
```
Load(<data/34567890ab>, 33918928, 0) returned error, retrying after 871.35598ms: readFull: unexpected EOF
Load(<data/34567890ab>, 33918928, 0) operation successful after 1 retries
check successful on second attempt, original error pack 34567890ab[...] contains 6 errors: [blob 12345678[...]: decrypting blob <data/12345678> from 34567890 failed: ciphertext verification failed ...]
[...]
Fatal: repository contains errors
```
This fix only applies to a very specific case where the log shows `operation
successful after 1 retries` followed by a `check successful on second attempt,
original error` that only reports `ciphertext verification failed` errors in the
pack file. If any other errors are reported in the pack file, then the
repository still has to be considered as damaged.
Now, only the check result of the last download retry is reported as intended.
https://github.com/restic/restic/issues/5467
https://github.com/restic/restic/pull/5495
# Changelog for restic 0.18.0 (2025-03-27)
The following sections list the changes in restic 0.18.0 relevant to
restic users. The changes are ordered by importance.
## Summary
* Sec #5291: Mitigate attack on content-defined chunking algorithm
* Fix #1843: Correctly restore long filepaths' timestamp on old Windows
* Fix #2165: Ignore disappeared backup source files
* Fix #5153: Include root tree when searching using `find --tree`
* Fix #5169: Prevent Windows VSS event log 8194 warnings for backup with fs snapshot
* Fix #5212: Fix duplicate data handling in `prune --max-unused`
* Fix #5249: Fix creation of oversized index by `repair index --read-all-packs`
* Fix #5259: Fix rare crash in command output
* Chg #4938: Update dependencies and require Go 1.23 or newer
* Chg #5162: Graduate feature flags
* Enh #1378: Add JSON support to `check` command
* Enh #2511: Support generating shell completions to stdout
* Enh #3697: Allow excluding online-only cloud files (e.g. OneDrive)
* Enh #4179: Add `sort` option to `ls` command
* Enh #4433: Change default sort order for `find` output
* Enh #4521: Add support for Microsoft Blob Storage access tiers
* Enh #4942: Add snapshot summary statistics to rewritten snapshots
* Enh #4948: Format exit errors as JSON when requested
* Enh #4983: Add SLSA provenance to GHCR container images
* Enh #5054: Enable compression for ZIP archives in `dump` command
* Enh #5081: Add retry mechanism for loading repository config
* Enh #5089: Allow including/excluding extended file attributes during `restore`
* Enh #5092: Show count of deleted files and directories during `restore`
* Enh #5109: Make small pack size configurable for `prune`
* Enh #5119: Add start and end timestamps to `backup` JSON output
* Enh #5131: Add DragonFlyBSD support
* Enh #5137: Make `tag` command print which snapshots were modified
* Enh #5141: Provide clear error message if AZURE_ACCOUNT_NAME is not set
* Enh #5173: Add experimental S3 cold storage support
* Enh #5174: Add xattr support for NetBSD 10+
* Enh #5251: Improve retry handling for flaky `rclone` backends
* Enh #5287: Make `recover` automatically rebuild index when needed
## Details
* Security #5291: Mitigate attack on content-defined chunking algorithm
Restic uses [Rabin
Fingerprints](https://restic.net/blog/2015-09-12/restic-foundation1-cdc/) for
its content-defined chunker. The algorithm relies on a secret polynomial to
split files into chunks.
As shown in the paper "[Chunking Attacks on File Backup Services using
Content-Defined Chunking](https://eprint.iacr.org/2025/532.pdf)" by Boris
Alexeev, Colin Percival and Yan X Zhang, an attacker that can observe chunk
sizes for a known file can derive the secret polynomial. Knowledge of the
polynomial might in some cases allow an attacker to check whether certain large
files are stored in a repository.
A practical attack is nevertheless hard as restic merges multiple chunks into
opaque pack files and by default processes multiple files in parallel. This
likely prevents an attacker from matching pack files to the attacker-known file
and thereby prevents the attack.
Despite the low chances of a practical attack, restic now has added mitigation
that randomizes how chunks are assembled into pack files. This prevents
attackers from guessing which chunks are part of a pack file and thereby
prevents learning the chunk sizes.
https://github.com/restic/restic/issues/5291
https://github.com/restic/restic/pull/5295
* Bugfix #1843: Correctly restore long filepaths' timestamp on old Windows
The `restore` command now correctly restores timestamps for files with paths
longer than 256 characters on Windows versions prior to Windows 10 1607.
https://github.com/restic/restic/issues/1843
https://github.com/restic/restic/pull/5061
* Bugfix #2165: Ignore disappeared backup source files
The `backup` command now quietly skips files that are removed between directory
listing and backup, instead of printing errors like:
```
error: lstat /some/file/name: no such file or directory
```
https://github.com/restic/restic/issues/2165
https://github.com/restic/restic/issues/3098
https://github.com/restic/restic/pull/5143
https://github.com/restic/restic/pull/5145
* Bugfix #5153: Include root tree when searching using `find --tree`
The `restic find --tree` command did not find trees referenced by `restic
snapshot --json`. It now correctly includes the root tree when searching.
https://github.com/restic/restic/pull/5153
* Bugfix #5169: Prevent Windows VSS event log 8194 warnings for backup with fs snapshot
When running `backup` with the `--use-fs-snapshot` option in Windows with admin
rights, event logs like
```
Volume Shadow Copy Service error: Unexpected error querying for the IVssWriterCallback interface. hr = 0x80070005, Access is denied.
. This is often caused by incorrect security settings in either the writer or requester process.
Operation:
Gathering Writer Data
Context:
Writer Class Id: {e8132975-6f93-4464-a53e-1050253ae220}
Writer Name: System Writer
Writer Instance ID: {54b151ac-d27d-4628-9cb0-2bc40959f50f}
```
Are created several times even though the backup itself succeeds. This has now
been fixed.
https://github.com/restic/restic/issues/5169
https://github.com/restic/restic/pull/5170
https://forum.restic.net/t/windows-shadow-copy-snapshot-vss-unexpected-provider-error/3674/2
* Bugfix #5212: Fix duplicate data handling in `prune --max-unused`
The `prune --max-unused size` command did not correctly account for duplicate
data. If a repository contained a large amount of duplicate data, this could
previously result in pruning too little data. This has now been fixed.
https://github.com/restic/restic/pull/5212
https://forum.restic.net/t/restic-not-obeying-max-unused-parameter-on-prune/8879
* Bugfix #5249: Fix creation of oversized index by `repair index --read-all-packs`
Since restic 0.17.0, the new index created by `repair index --read-all-packs`
was written as a single large index. This significantly increased memory usage
while loading the index.
The index is now correctly split into multiple smaller indexes, and `repair
index` now also automatically splits oversized indexes.
https://github.com/restic/restic/pull/5249
* Bugfix #5259: Fix rare crash in command output
Some commands could in rare cases crash when trying to print status messages and
request retries at the same time, resulting in an error like the following:
```
panic: runtime error: slice bounds out of range [468:156]
[...]
github.com/restic/restic/internal/ui/termstatus.(*lineWriter).Write(...)
/restic/internal/ui/termstatus/stdio_wrapper.go:36 +0x136
```
This has now been fixed.
https://github.com/restic/restic/issues/5259
https://github.com/restic/restic/pull/5300
* Change #4938: Update dependencies and require Go 1.23 or newer
We have updated all dependencies. Restic now requires Go 1.23 or newer to build.
This also disables support for TLS versions older than TLS 1.2. On Windows,
restic now requires at least Windows 10 or Windows Server 2016. On macOS, restic
now requires at least macOS 11 Big Sur.
https://github.com/restic/restic/pull/4938
* Change #5162: Graduate feature flags
The `deprecate-legacy-index`, `deprecate-s3-legacy-layout`,
`explicit-s3-anonymous-auth` and `safe-forget-keep-tags` features are now stable
and can no longer be disabled. The corresponding feature flags will be removed
in restic 0.19.0.
https://github.com/restic/restic/pull/5162
* Enhancement #1378: Add JSON support to `check` command
The `check` command now supports the `--json` option to output all statistics in
JSON format.
https://github.com/restic/restic/issues/1378
https://github.com/restic/restic/pull/5194
* Enhancement #2511: Support generating shell completions to stdout
The `generate` command now supports using `-` as the filename with the
`--[shell]-completion` option to write the generated output to stdout.
https://github.com/restic/restic/issues/2511
https://github.com/restic/restic/pull/5053
* Enhancement #3697: Allow excluding online-only cloud files (e.g. OneDrive)
Restic treated files synced using OneDrive Files On-Demand as though they were
regular files. This caused issues with VSS and could cause OneDrive to download
all files.
Restic now allows the user to exclude these files when backing up with the
`--exclude-cloud-files` option.
https://github.com/restic/restic/issues/3697
https://github.com/restic/restic/issues/4935
https://github.com/restic/restic/pull/4990
* Enhancement #4179: Add `sort` option to `ls` command
The `ls -l` command output can now be sorted using the new `--sort <field>`
option for the fields `name`, `size`, `time` (same as `mtime`), `mtime`,
`atime`, `ctime` and `extension`. A `--reverse` option is also available.
https://github.com/restic/restic/issues/4179
https://github.com/restic/restic/pull/5182
* Enhancement #4433: Change default sort order for `find` output
The `find` command now sorts snapshots from newest to oldest by default. The
previous oldest-to-newest order can be restored using the new `--reverse`
option.
https://github.com/restic/restic/issues/4433
https://github.com/restic/restic/pull/5184
* Enhancement #4521: Add support for Microsoft Blob Storage access tiers
The new `-o azure.access-tier=<tier>` option allows specifying the access tier
(`Hot`, `Cool` or `Cold`) for objects created in Microsoft Blob Storage. If
unspecified, the storage account's default tier is used.
There is no official `Archive` storage support in restic, use this option at
your own risk. To restore any data, it is necessary to manually warm up the
required data in the `Archive` tier.
https://github.com/restic/restic/issues/4521
https://github.com/restic/restic/pull/5046
* Enhancement #4942: Add snapshot summary statistics to rewritten snapshots
The `rewrite` command now supports a `--snapshot-summary` option to add
statistics data to snapshots. Only two fields in the summary will be non-zero:
`TotalFilesProcessed` and `TotalBytesProcessed`.
For snapshots rewritten using the `--exclude` options, the summary statistics
are updated accordingly.
https://github.com/restic/restic/issues/4942
https://github.com/restic/restic/pull/5185
* Enhancement #4948: Format exit errors as JSON when requested
Restic now formats error messages as JSON when the `--json` flag is used.
https://github.com/restic/restic/issues/4948
https://github.com/restic/restic/pull/4952
* Enhancement #4983: Add SLSA provenance to GHCR container images
Restic's GitHub Container Registry (GHCR) image build workflow now includes SLSA
(Supply-chain Levels for Software Artifacts) provenance generation.
Please see the restic documentation for more information about verifying SLSA
provenance.
https://github.com/restic/restic/issues/4983
https://github.com/restic/restic/pull/4999
* Enhancement #5054: Enable compression for ZIP archives in `dump` command
The `dump` command now compresses ZIP archives using the DEFLATE algorithm,
reducing the size of exported archives.
https://github.com/restic/restic/pull/5054
* Enhancement #5081: Add retry mechanism for loading repository config
Restic now retries loading the repository config file when opening a repository.
The `init` command now also retries backend operations.
https://github.com/restic/restic/issues/5081
https://github.com/restic/restic/pull/5095
* Enhancement #5089: Allow including/excluding extended file attributes during `restore`
The `restore` command now supports the `--exclude-xattr` and `--include-xattr`
options to control which extended file attributes will be restored. By default,
all attributes are restored.
https://github.com/restic/restic/issues/5089
https://github.com/restic/restic/pull/5129
* Enhancement #5092: Show count of deleted files and directories during `restore`
The `restore` command now reports the number of deleted files and directories,
both in the regular output and in the `files_deleted` field of the JSON output.
https://github.com/restic/restic/issues/5092
https://github.com/restic/restic/pull/5100
* Enhancement #5109: Make small pack size configurable for `prune`
The `prune` command now supports the `--repack-smaller-than` option that allows
repacking pack files smaller than a specified size.
https://github.com/restic/restic/issues/5109
https://github.com/restic/restic/pull/5183
* Enhancement #5119: Add start and end timestamps to `backup` JSON output
The JSON output of the `backup` command now includes `backup_start` and
`backup_end` timestamps, containing the start and end time of the backup.
https://github.com/restic/restic/pull/5119
* Enhancement #5131: Add DragonFlyBSD support
Restic can now be compiled on DragonflyBSD.
https://github.com/restic/restic/issues/5131
https://github.com/restic/restic/pull/5138
* Enhancement #5137: Make `tag` command print which snapshots were modified
The `tag` command now outputs which snapshots were modified along with their new
snapshot ID. The command supports the `--json` option for machine-readable
output.
https://github.com/restic/restic/issues/5137
https://github.com/restic/restic/pull/5144
* Enhancement #5141: Provide clear error message if AZURE_ACCOUNT_NAME is not set
If `AZURE_ACCOUNT_NAME` was not set, commands related to an Azure repository
would result in a misleading networking error. Restic now detect this and
provides a clear warning that the variable is not defined.
https://github.com/restic/restic/pull/5141
* Enhancement #5173: Add experimental S3 cold storage support
Introduce S3 backend options for transitioning pack files from cold to hot
storage on S3 and S3-compatible providers. Note: this only works for the
`prune`, `copy` and `restore` commands for now.
This experimental feature is gated behind the "s3-restore" feature flag.
https://github.com/restic/restic/issues/3202
https://github.com/restic/restic/issues/2504
https://github.com/restic/restic/pull/5173
* Enhancement #5174: Add xattr support for NetBSD 10+
Extended attribute support for `backup` and `restore` operations is now
available on NetBSD version 10 and later.
https://github.com/restic/restic/issues/5174
https://github.com/restic/restic/pull/5180
* Enhancement #5251: Improve retry handling for flaky `rclone` backends
Since restic 0.17.0, the backend retry mechanisms rely on backends correctly
reporting when a file does not exist. This is not always the case for some
`rclone` backends, which caused restic to stop retrying after the first failure.
For rclone, failed requests are now retried up to 5 times before giving up.
https://github.com/restic/restic/pull/5251
* Enhancement #5287: Make `recover` automatically rebuild index when needed
When trying to recover data from an interrupted snapshot, it was previously
necessary to manually run `repair index` before runnning `recover`. This now
happens automatically so that only `recover` is necessary.
https://github.com/restic/restic/issues/5287
https://github.com/restic/restic/pull/5296
# Changelog for restic 0.17.3 (2024-11-08)
The following sections list the changes in restic 0.17.3 relevant to
restic users. The changes are ordered by importance.

View File

@@ -202,6 +202,9 @@ we'll be glad to assist. Having a PR with failing integration tests is nothing
to be ashamed of. In contrast, that happens regularly for all of us. That's
what the tests are there for.
More details of how to structure tests can be found here at
[writing tests](https://restic.readthedocs.io/en/stable/090_participating.html#writing-tests).
Git Commits
-----------

View File

@@ -1 +1 @@
0.17.3
0.18.1-dev

View File

@@ -36,7 +36,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//go:build ignore_build_go
// +build ignore_build_go
package main
@@ -53,12 +52,14 @@ import (
// config contains the configuration for the program to build.
var config = Config{
Name: "restic", // name of the program executable and directory
Namespace: "github.com/restic/restic", // subdir of GOPATH, e.g. "github.com/foo/bar"
Main: "./cmd/restic", // package name for the main package
DefaultBuildTags: []string{"selfupdate"}, // specify build tags which are always used
Tests: []string{"./..."}, // tests to run
MinVersion: GoVersion{Major: 1, Minor: 18, Patch: 0}, // minimum Go version supported
Name: "restic", // name of the program executable and directory
Namespace: "github.com/restic/restic", // subdir of GOPATH, e.g. "github.com/foo/bar"
Main: "./cmd/restic", // package name for the main package
// disable_grpc_modules is necessary to reduce the binary size since cloud.google.com/go/storage v1.44.0
// see https://github.com/googleapis/google-cloud-go/issues/11448
DefaultBuildTags: []string{"selfupdate", "disable_grpc_modules"}, // specify build tags which are always used
Tests: []string{"./..."}, // tests to run
MinVersion: GoVersion{Major: 1, Minor: 24, Patch: 0}, // minimum Go version supported
}
// Config configures the build.
@@ -298,19 +299,21 @@ func (v GoVersion) AtLeast(other GoVersion) bool {
return true
}
if v.Major > other.Major {
return true
}
if v.Major < other.Major {
return false
}
if v.Minor > other.Minor {
return true
}
if v.Minor < other.Minor {
return false
}
if v.Patch < other.Patch {
return false
}
return true
return v.Patch >= other.Patch
}
func (v GoVersion) String() string {
@@ -380,12 +383,6 @@ func main() {
}
}
solarisMinVersion := GoVersion{Major: 1, Minor: 20, Patch: 0}
if env["GOARCH"] == "solaris" && !goVersion.AtLeast(solarisMinVersion) {
fmt.Fprintf(os.Stderr, "Detected version %s is too old, restic requires at least %s for Solaris\n", goVersion, solarisMinVersion)
os.Exit(1)
}
verbosePrintf("detected Go version %v\n", goVersion)
preserveSymbols := false

View File

@@ -0,0 +1,7 @@
Enhancement: Add JSON support to `check` command
The `check` command now supports the `--json` option to output all statistics in
JSON format.
https://github.com/restic/restic/issues/1378
https://github.com/restic/restic/pull/5194

View File

@@ -0,0 +1,7 @@
Bugfix: Correctly restore long filepaths' timestamp on old Windows
The `restore` command now correctly restores timestamps for files with paths longer
than 256 characters on Windows versions prior to Windows 10 1607.
https://github.com/restic/restic/issues/1843
https://github.com/restic/restic/pull/5061

View File

@@ -0,0 +1,13 @@
Bugfix: Ignore disappeared backup source files
The `backup` command now quietly skips files that are removed between directory
listing and backup, instead of printing errors like:
```
error: lstat /some/file/name: no such file or directory
```
https://github.com/restic/restic/issues/2165
https://github.com/restic/restic/issues/3098
https://github.com/restic/restic/pull/5143
https://github.com/restic/restic/pull/5145

View File

@@ -0,0 +1,7 @@
Enhancement: Support generating shell completions to stdout
The `generate` command now supports using `-` as the filename with the
`--[shell]-completion` option to write the generated output to stdout.
https://github.com/restic/restic/issues/2511
https://github.com/restic/restic/pull/5053

View File

@@ -0,0 +1,11 @@
Enhancement: Add experimental S3 cold storage support
Introduce S3 backend options for transitioning pack files from cold to hot storage
on S3 and S3-compatible providers. Note: this only works for the `prune`, `copy`
and `restore` commands for now.
This experimental feature is gated behind the "s3-restore" feature flag.
https://github.com/restic/restic/pull/5173
https://github.com/restic/restic/issues/3202
https://github.com/restic/restic/issues/2504

View File

@@ -0,0 +1,12 @@
Enhancement: Allow excluding online-only cloud files (e.g. OneDrive)
Restic treated files synced using OneDrive Files On-Demand as though they
were regular files. This caused issues with VSS and could cause OneDrive to
download all files.
Restic now allows the user to exclude these files when backing up with
the `--exclude-cloud-files` option.
https://github.com/restic/restic/issues/3697
https://github.com/restic/restic/issues/4935
https://github.com/restic/restic/pull/4990

View File

@@ -0,0 +1,8 @@
Enhancement: Add `sort` option to `ls` command
The `ls -l` command output can now be sorted using the new `--sort <field>`
option for the fields `name`, `size`, `time` (same as `mtime`), `mtime`,
`atime`, `ctime` and `extension`. A `--reverse` option is also available.
https://github.com/restic/restic/issues/4179
https://github.com/restic/restic/pull/5182

View File

@@ -0,0 +1,7 @@
Enhancement: Change default sort order for `find` output
The `find` command now sorts snapshots from newest to oldest by default. The
previous oldest-to-newest order can be restored using the new `--reverse` option.
https://github.com/restic/restic/issues/4433
https://github.com/restic/restic/pull/5184

View File

@@ -0,0 +1,12 @@
Enhancement: Add support for Microsoft Blob Storage access tiers
The new `-o azure.access-tier=<tier>` option allows specifying the access tier
(`Hot`, `Cool` or `Cold`) for objects created in Microsoft Blob Storage. If
unspecified, the storage account's default tier is used.
There is no official `Archive` storage support in restic, use this option at
your own risk. To restore any data, it is necessary to manually warm up the
required data in the `Archive` tier.
https://github.com/restic/restic/issues/4521
https://github.com/restic/restic/pull/5046

View File

@@ -0,0 +1,11 @@
Enhancement: Add snapshot summary statistics to rewritten snapshots
The `rewrite` command now supports a `--snapshot-summary` option to add
statistics data to snapshots. Only two fields in the summary will be non-zero:
`TotalFilesProcessed` and `TotalBytesProcessed`.
For snapshots rewritten using the `--exclude` options, the summary
statistics are updated accordingly.
https://github.com/restic/restic/issues/4942
https://github.com/restic/restic/pull/5185

View File

@@ -0,0 +1,6 @@
Enhancement: Format exit errors as JSON when requested
Restic now formats error messages as JSON when the `--json` flag is used.
https://github.com/restic/restic/issues/4948
https://github.com/restic/restic/pull/4952

View File

@@ -0,0 +1,10 @@
Enhancement: Add SLSA provenance to GHCR container images
Restic's GitHub Container Registry (GHCR) image build workflow now includes
SLSA (Supply-chain Levels for Software Artifacts) provenance generation.
Please see the restic documentation for more information about verifying SLSA
provenance.
https://github.com/restic/restic/issues/4983
https://github.com/restic/restic/pull/4999

View File

@@ -0,0 +1,7 @@
Enhancement: Add retry mechanism for loading repository config
Restic now retries loading the repository config file when opening a repository.
The `init` command now also retries backend operations.
https://github.com/restic/restic/issues/5081
https://github.com/restic/restic/pull/5095

View File

@@ -0,0 +1,8 @@
Enhancement: Allow including/excluding extended file attributes during `restore`
The `restore` command now supports the `--exclude-xattr` and `--include-xattr`
options to control which extended file attributes will be restored. By default,
all attributes are restored.
https://github.com/restic/restic/issues/5089
https://github.com/restic/restic/pull/5129

View File

@@ -0,0 +1,7 @@
Enhancement: Show count of deleted files and directories during `restore`
The `restore` command now reports the number of deleted files and directories,
both in the regular output and in the `files_deleted` field of the JSON output.
https://github.com/restic/restic/issues/5092
https://github.com/restic/restic/pull/5100

View File

@@ -0,0 +1,7 @@
Enhancement: Make small pack size configurable for `prune`
The `prune` command now supports the `--repack-smaller-than` option that
allows repacking pack files smaller than a specified size.
https://github.com/restic/restic/issues/5109
https://github.com/restic/restic/pull/5183

View File

@@ -0,0 +1,6 @@
Enhancement: Add DragonFlyBSD support
Restic can now be compiled on DragonflyBSD.
https://github.com/restic/restic/issues/5131
https://github.com/restic/restic/pull/5138

View File

@@ -0,0 +1,8 @@
Enhancement: Make `tag` command print which snapshots were modified
The `tag` command now outputs which snapshots were modified along with their
new snapshot ID. The command supports the `--json` option for machine-readable
output.
https://github.com/restic/restic/issues/5137
https://github.com/restic/restic/pull/5144

View File

@@ -0,0 +1,7 @@
Enhancement: Add xattr support for NetBSD 10+
Extended attribute support for `backup` and `restore` operations
is now available on NetBSD version 10 and later.
https://github.com/restic/restic/issues/5174
https://github.com/restic/restic/pull/5180

View File

@@ -0,0 +1,16 @@
Bugfix: Fix rare crash in command output
Some commands could in rare cases crash when trying to print status messages
and request retries at the same time, resulting in an error like the following:
```
panic: runtime error: slice bounds out of range [468:156]
[...]
github.com/restic/restic/internal/ui/termstatus.(*lineWriter).Write(...)
/restic/internal/ui/termstatus/stdio_wrapper.go:36 +0x136
```
This has now been fixed.
https://github.com/restic/restic/issues/5259
https://github.com/restic/restic/pull/5300

View File

@@ -0,0 +1,8 @@
Enhancement: Make `recover` automatically rebuild index when needed
When trying to recover data from an interrupted snapshot, it was previously
necessary to manually run `repair index` before runnning `recover`. This now
happens automatically so that only `recover` is necessary.
https://github.com/restic/restic/issues/5287
https://github.com/restic/restic/pull/5296

View File

@@ -0,0 +1,24 @@
Security: Mitigate attack on content-defined chunking algorithm
Restic uses [Rabin Fingerprints](https://restic.net/blog/2015-09-12/restic-foundation1-cdc/)
for its content-defined chunker. The algorithm relies on a secret polynomial
to split files into chunks.
As shown in the paper "[Chunking Attacks on File Backup Services using Content-Defined Chunking](https://eprint.iacr.org/2025/532.pdf)"
by Boris Alexeev, Colin Percival and Yan X Zhang, an
attacker that can observe chunk sizes for a known file can derive the secret
polynomial. Knowledge of the polynomial might in some cases allow an attacker
to check whether certain large files are stored in a repository.
A practical attack is nevertheless hard as restic merges multiple chunks into
opaque pack files and by default processes multiple files in parallel. This
likely prevents an attacker from matching pack files to the attacker-known file
and thereby prevents the attack.
Despite the low chances of a practical attack, restic now has added mitigation
that randomizes how chunks are assembled into pack files. This prevents attackers
from guessing which chunks are part of a pack file and thereby prevents learning
the chunk sizes.
https://github.com/restic/restic/issues/5291
https://github.com/restic/restic/pull/5295

View File

@@ -0,0 +1,9 @@
Change: Update dependencies and require Go 1.23 or newer
We have updated all dependencies. Restic now requires Go 1.23 or newer to build.
This also disables support for TLS versions older than TLS 1.2. On Windows,
restic now requires at least Windows 10 or Windows Server 2016. On macOS,
restic now requires at least macOS 11 Big Sur.
https://github.com/restic/restic/pull/4938

View File

@@ -0,0 +1,6 @@
Enhancement: Enable compression for ZIP archives in `dump` command
The `dump` command now compresses ZIP archives using the DEFLATE algorithm,
reducing the size of exported archives.
https://github.com/restic/restic/pull/5054

View File

@@ -0,0 +1,6 @@
Enhancement: Add start and end timestamps to `backup` JSON output
The JSON output of the `backup` command now includes `backup_start` and
`backup_end` timestamps, containing the start and end time of the backup.
https://github.com/restic/restic/pull/5119

View File

@@ -0,0 +1,7 @@
Enhancement: Provide clear error message if AZURE_ACCOUNT_NAME is not set
If `AZURE_ACCOUNT_NAME` was not set, commands related to an Azure repository
would result in a misleading networking error. Restic now detect this and
provides a clear warning that the variable is not defined.
https://github.com/restic/restic/pull/5141

View File

@@ -0,0 +1,7 @@
Bugfix: Include root tree when searching using `find --tree`
The `restic find --tree` command did not find trees referenced by
`restic snapshot --json`. It now correctly includes the root tree
when searching.
https://github.com/restic/restic/pull/5153

View File

@@ -0,0 +1,8 @@
Change: Graduate feature flags
The `deprecate-legacy-index`, `deprecate-s3-legacy-layout`,
`explicit-s3-anonymous-auth` and `safe-forget-keep-tags` features are
now stable and can no longer be disabled. The corresponding feature flags
will be removed in restic 0.19.0.
https://github.com/restic/restic/pull/5162

View File

@@ -0,0 +1,22 @@
Bugfix: Prevent Windows VSS event log 8194 warnings for backup with fs snapshot
When running `backup` with the `--use-fs-snapshot` option in Windows with admin rights, event logs like
```
Volume Shadow Copy Service error: Unexpected error querying for the IVssWriterCallback interface. hr = 0x80070005, Access is denied.
. This is often caused by incorrect security settings in either the writer or requester process.
Operation:
Gathering Writer Data
Context:
Writer Class Id: {e8132975-6f93-4464-a53e-1050253ae220}
Writer Name: System Writer
Writer Instance ID: {54b151ac-d27d-4628-9cb0-2bc40959f50f}
```
are created several times even though the backup itself succeeds. This has now been fixed.
https://github.com/restic/restic/issues/5169
https://github.com/restic/restic/pull/5170
https://forum.restic.net/t/windows-shadow-copy-snapshot-vss-unexpected-provider-error/3674/2

View File

@@ -0,0 +1,8 @@
Bugfix: Fix duplicate data handling in `prune --max-unused`
The `prune --max-unused size` command did not correctly account for duplicate
data. If a repository contained a large amount of duplicate data, this could
previously result in pruning too little data. This has now been fixed.
https://github.com/restic/restic/pull/5212
https://forum.restic.net/t/restic-not-obeying-max-unused-parameter-on-prune/8879

View File

@@ -0,0 +1,10 @@
Bugfix: Fix creation of oversized index by `repair index --read-all-packs`
Since restic 0.17.0, the new index created by `repair index --read-all-packs` was
written as a single large index. This significantly increased memory usage while
loading the index.
The index is now correctly split into multiple smaller indexes, and `repair index`
now also automatically splits oversized indexes.
https://github.com/restic/restic/pull/5249

View File

@@ -0,0 +1,9 @@
Enhancement: Improve retry handling for flaky `rclone` backends
Since restic 0.17.0, the backend retry mechanisms rely on backends correctly
reporting when a file does not exist. This is not always the case for some
`rclone` backends, which caused restic to stop retrying after the first failure.
For rclone, failed requests are now retried up to 5 times before giving up.
https://github.com/restic/restic/pull/5251

View File

@@ -0,0 +1,14 @@
Bugfix: Correctly handle `backup --stdin-filename` with directory paths
In restic 0.18.0, the `backup` command failed if a filename that includes
at least a directory was passed to `--stdin-filename`. For example,
`--stdin-filename /foo/bar` resulted in the following error:
```
Fatal: unable to save snapshot: open /foo: no such file or directory
```
This has now been fixed.
https://github.com/restic/restic/issues/5324
https://github.com/restic/restic/pull/5356

View File

@@ -0,0 +1,7 @@
Bugfix: Accept `RESTIC_HOST` environment variable in `forget` command
The `forget` command did not use the host name from the `RESTIC_HOST`
environment variable when filtering snapshots. This has now been fixed.
https://github.com/restic/restic/issues/5325
https://github.com/restic/restic/pull/5327

View File

@@ -0,0 +1,7 @@
Bugfix: Ignore "chmod not supported" errors when writing files
Restic 0.18.0 introduced a bug that caused `chmod xxx: operation not supported`
errors to appear when writing to a local file repository that did not support
chmod (like CIFS or WebDAV mounted via FUSE). Restic now ignores those errors.
https://github.com/restic/restic/issues/5342

View File

@@ -0,0 +1,7 @@
Bugfix: Ignore `EOPNOTSUPP` errors for extended attributes
Restic 0.18.0 added extended attribute support for NetBSD 10+, but not all
NetBSD filesystems support extended attributes. Other BSD systems can
likewise return `EOPNOTSUPP`, so restic now ignores these errors.
https://github.com/restic/restic/issues/5344

View File

@@ -0,0 +1,8 @@
Bugfix: Stop retrying uploads when rest-server runs out of space
When rest-server returns a `507 Insufficient Storage` error, it indicates
that no more storage capacity is available. Restic now correctly stops
retrying uploads in this case.
https://github.com/restic/restic/issues/5429
https://github.com/restic/restic/pull/5452

View File

@@ -0,0 +1,27 @@
Bugfix: Improve handling of download retries in `check` command
In very rare cases, the `check` command could unnecessarily report repository
damage if the backend returned incomplete, corrupted data on the first download
try which is afterwards resolved by a download retry.
This could result in an error output like the following:
```
Load(<data/34567890ab>, 33918928, 0) returned error, retrying after 871.35598ms: readFull: unexpected EOF
Load(<data/34567890ab>, 33918928, 0) operation successful after 1 retries
check successful on second attempt, original error pack 34567890ab[...] contains 6 errors: [blob 12345678[...]: decrypting blob <data/12345678> from 34567890 failed: ciphertext verification failed ...]
[...]
Fatal: repository contains errors
```
This fix only applies to a very specific case where the log shows
`operation successful after 1 retries` followed by a
`check successful on second attempt, original error` that only reports
`ciphertext verification failed` errors in the pack file. If any other errors
are reported in the pack file, then the repository still has to be considered
as damaged.
Now, only the check result of the last download retry is reported as intended.
https://github.com/restic/restic/issues/5467
https://github.com/restic/restic/pull/5495

View File

@@ -0,0 +1,7 @@
Bugfix: Fix rare crash if directory is removed during backup
In restic 0.18.0, the `backup` command could crash if a directory was removed
between reading its metadata and listing its directory content. This has now
been fixed.
https://github.com/restic/restic/pull/5421

View File

@@ -5,6 +5,8 @@ Enhancement: Allow custom bar in the foo command
# Describe the problem in the past tense, the new behavior in the present
# tense. Mention the affected commands, backends, operating systems, etc.
# If the problem description just says that a feature was missing, then
# only explain the new behavior.
# Focus on user-facing behavior, not the implementation.
# Use "Restic now ..." instead of "We have changed ...".

View File

@@ -0,0 +1,9 @@
Enhancement: `restic check` for specified snapshot(s) via snapshot filtering
Snapshots can now be specified for the command `restic check` on the command line
via the standard snapshot filter, (`--tag`, `--host`, `--path` or specifying
snapshot IDs directly) and will be used for checking the packfiles used by these snapshots.
https://github.com/restic/restic/issues/3326
https://github.com/restic/restic/pull/5469
https://github.com/restic/restic/pull/5644

View File

@@ -0,0 +1,9 @@
Enhancement: Support restoring ownership by name on UNIX systems
Restic restore used to restore file ownership on UNIX systems by UID and GID.
It now allows restoring the file ownership by user name and group name with `--ownership-by-name`.
This allows restoring snapshots on a system where the UID/GID are not the same as they were on the system where the snapshot was created.
However it does not include support for POSIX ACLs, which are still restored by their numeric value.
https://github.com/restic/restic/issues/3572
https://github.com/restic/restic/pull/5449

View File

@@ -0,0 +1,8 @@
Enhancement: Allow Github personal access token to be specified for `self-update`
`restic self-update` previously only used unauthenticated GitHub API requests when checking for the latest release. This caused some users sharing IP addresses to hit the GitHub rate limit, resulting in a 403 Forbidden error and preventing updates.
Restic still uses unauthenticated requests by default, but it now optionally supports authenticated GitHub API requests during `self-update`. Users can set the `$GITHUB_ACCESS_TOKEN` environment variable to use a [personal access token](https://github.com/settings/tokens) for this effect, avoiding update failures due to rate limiting.
https://github.com/restic/restic/issues/3738
https://github.com/restic/restic/pull/5568

View File

@@ -0,0 +1,12 @@
Enhancement: Support include filters in `rewrite` command
The enhancement enables the standard include filter options
--iinclude pattern same as --include pattern but ignores the casing of filenames
--iinclude-file file same as --include-file but ignores casing of filenames in patterns
-i, --include pattern include a pattern (can be specified multiple times)
--include-file file read include patterns from a file (can be specified multiple times)
The exclusion or inclusion of filter parameters is exclusive, as in other commands.
https://github.com/restic/restic/issues/4278
https://github.com/restic/restic/pull/5191

View File

@@ -0,0 +1,11 @@
Bugfix: Exit with code 3 when some `backup` source files do not exist
Restic used to exit with code 0 even when some backup sources did not exist. Restic
would exit with code 3 only when child directories or files did not exist. This
could cause confusion and unexpected behavior in scripts that relied on the exit
code to determine if the backup was successful.
Restic now exits with code 3 when some backup sources do not exist.
https://github.com/restic/restic/issues/4467
https://github.com/restic/restic/pull/5347

View File

@@ -0,0 +1,7 @@
Enhancement: Added support for zstd compression levels `fastest` and `better`
Restic now supports the zstd compression modes `fastest` and `better`. Set the
environment variable `RESTIC_COMPRESSION` to `fastest` or `better` to use these
compression levels. This can also be set with the `--compression` flag.
https://github.com/restic/restic/issues/4728

View File

@@ -0,0 +1,14 @@
Enhancement: Include repository id in filesystem name used by `mount`
The filesystem created by restic's `mount` command now includes the repository
id in the filesystem name. The repository id is printed by restic when opening
a repository or can be looked up using `restic cat config`.
```
[restic-user@hostname restic]$ df ./test-mount/
Filesystem 1K-blocks Used Available Use% Mounted on
restic:d3b07384d1 0 0 0 - /mnt/my-restic-repo
```
https://github.com/restic/restic/issues/4868
https://github.com/restic/restic/pull/5243

View File

@@ -0,0 +1,8 @@
Bugfix: forget command returns exit code 3 on partial removal of snapshots
The `forget` command now returns exit code 3 when it fails to remove one or
more snapshots. Previously, it returned exit code 0, which could lead to
confusion if the command was used in a script.
https://github.com/restic/restic/issues/5233
https://github.com/restic/restic/pull/5322

View File

@@ -0,0 +1,7 @@
Bugfix: Exit with correct code on SIGINT
Restic previously returned exit code 1 on SIGINT, which is incorrect.
Restic now returns 130 on SIGINT.
https://github.com/restic/restic/issues/5258
https://github.com/restic/restic/pull/5363

View File

@@ -0,0 +1,7 @@
Bugfix: `restic find` now checks for correct ordering of time related options
`restic find` now immediately fails with an error if both `--oldest` and `--newest` are specified
and `--oldest` is a timestamp after `--newest`.
https://github.com/restic/restic/issues/5280
https://github.com/restic/restic/pull/5310

View File

@@ -0,0 +1,11 @@
Enhancement: Add support for --exclude-cloud-files on macOS (e.g. iCloud drive)
Restic treated files stored in iCloud drive as though they were regular files.
This caused restic to download all files (including files marked as cloud only) while iterating over them.
Restic now allows the user to exclude these files when backing up with the `--exclude-cloud-files` option.
Works from Sonoma (macOS 14.0) onwards. Older macOS versions materialize files when `stat` is called on the file.
https://github.com/restic/restic/pull/4990
https://github.com/restic/restic/issues/5352

View File

@@ -0,0 +1,14 @@
Bugfix: Allow use of rclone/sftp backend when running restic in background
When starting restic in the background, this could result in unexpected behavior
when using the rclone or sftp backend.
For example running `restic -r rclone:./example --insecure-no-password init &`
could cause the calling `bash` shell to exit unexpectedly.
This has been fixed.
https://github.com/restic/restic/issues/5354
https://github.com/restic/restic/pull/5358
https://github.com/restic/restic/pull/5493
https://github.com/restic/restic/pull/5494

View File

@@ -0,0 +1,10 @@
Enhancement: Reduce progress bar refresh rates to reduce energy usage
Progress bars were updated with 60fps which can cause high CPU or GPU usage
for some terminal emulators. Reduce it to 10fps to conserve energy.
In addition, this lower frequency seem to be necessary to allow selecting
anything in the terminal with certain terminal emulators.
https://github.com/restic/restic/issues/5383
https://github.com/restic/restic/pull/5551
https://github.com/restic/restic/pull/5626

View File

@@ -0,0 +1,12 @@
Enhancement: Allow overriding RESTIC_HOST environment variable with --host flag
When the `RESTIC_HOST` environment variable was set, there was no way to list or
operate on snapshots from all hosts, as the environment variable would always
filter to that specific host. Restic now allows overriding `RESTIC_HOST` by
explicitly providing the `--host` flag with an empty string (e.g., `--host=""` or
`--host=`), which will show snapshots from all hosts. This works for all commands
that support snapshot filtering: `snapshots`, `forget`, `find`, `stats`, `copy`,
`tag`, `repair snapshots`, `rewrite`, `mount`, `restore`, `dump`, and `ls`.
https://github.com/restic/restic/issues/5440
https://github.com/restic/restic/pull/5541

View File

@@ -0,0 +1,10 @@
Enhancement: `copy` copies snapshots in batches
The `copy` command used to copy snapshots individually, even if this resulted in creating pack files
smaller than the target pack size. In particular, this resulted in many small files
when copying small incremental snapshots.
Now, `copy` copies multiple snapshots at once to avoid creating small files.
https://github.com/restic/restic/issues/5175
https://github.com/restic/restic/pull/5464

View File

@@ -0,0 +1,7 @@
Bugfix: Password prompt was sometimes not shown
The password prompt for a repository was sometimes not shown when running
the `backup -v` command. This has been fixed.
https://github.com/restic/restic/issues/5477
https://github.com/restic/restic/pull/5554

View File

@@ -0,0 +1,8 @@
Bugfix: Mark files as readonly when using the SFTP backend
Files created by the SFTP backend previously allowed writes to those files.
Restic now restricts the file permissions on SFTP backend to readonly.
This change only has an effect for sftp servers with support for the chmod operation.
https://github.com/restic/restic/issues/5487
https://github.com/restic/restic/pull/5497

View File

@@ -0,0 +1,15 @@
Enhancement: Reduce Azure storage costs by optimizing upload method
Restic previously used Azure's PutBlock and PutBlockList APIs for all file
uploads, which resulted in two transactions per file and doubled the storage
operation costs. For backups with many pack files, this could lead to
significant Azure storage transaction fees.
Restic now uses the more efficient PutBlob API for files up to 256 MiB,
requiring only a single transaction per file. This reduces Azure storage
operation costs by approximately 50% for typical backup workloads. Files
larger than 256 MiB continue to use the block-based upload method as required
by Azure's API limits.
https://github.com/restic/restic/issues/5531
https://github.com/restic/restic/pull/5544

View File

@@ -0,0 +1,7 @@
Bugfix: correctly handle `snapshots --group-by` in combination with `--latest`
For the `snapshots` command, the `--latest` option did not correctly handle the
case where an non-default value was passed to `--group-by`. This has been fixed.
https://github.com/restic/restic/issues/5586
https://github.com/restic/restic/pull/5601

View File

@@ -0,0 +1,8 @@
Bugfix: Fix "chmod not supported" errors when unlocking
Restic 0.18.0 introduced a bug that caused "chmod xxx: operation not supported"
errors to appear when unlocking with a stale lock, on a local file repository
that did not support chmod (like CIFS or WebDAV mounted via FUSE). Restic now
just doesn't bother calling chmod in that case on Unix, as it is unnecessary.
https://github.com/restic/restic/issues/5595

View File

@@ -0,0 +1,5 @@
Change: Update dependencies and require Go 1.24 or newer
We have updated all dependencies. Restic now requires Go 1.24 or newer to build.
https://github.com/restic/restic/pull/5619

View File

@@ -0,0 +1,9 @@
Enhancement: add more status counters to `restic copy`
`restic copy` now produces more status counters in text format. The new counters
are the number of blobs to copy, their size on disk and the number of packfiles
used from the source repository. The additional statistics is only produced when
the `--verbose` option is specified.
https://github.com/restic/restic/issues/5175
https://github.com/restic/restic/pull/5319

View File

@@ -0,0 +1,11 @@
Enhancement: Enable file system privileges on Windows before access
Restic attempted to enable Windows file system privileges when
reading or writing security descriptors - after potentially being wholly
denied access to previous items. It also read file extended attributes without
using the privilege, possibly missing them and producing errors.
Restic now attempts to enable all file system privileges before any file
access. It also requests extended attribute reads use the backup privilege.
https://github.com/restic/restic/pull/5424

View File

@@ -0,0 +1,11 @@
Enhancement: Allow nice and ionice configuration for restic containers
The official restic docker now supports the following environment variables:
`NICE`: set the desired nice scheduling. See `man nice`.
`IONICE_CLASS`: set the desired I/O scheduling class. See `man ionice`. Note that real time support requires the invoker to manually add the `SYS_NICE` capability.
`IONICE_PRIORITY`: set the prioritization for ionice in the given `IONICE_CLASS`. This does nothing without `IONICE_CLASS`, but defaults to `4` (no priority, no penalties).
See https://restic.readthedocs.io/en/stable/020_installation.html#docker-container for further details.
https://github.com/restic/restic/pull/5448

View File

@@ -0,0 +1,10 @@
Bugfix: Correctly restore ACL inheritance state on Windows
Since the introduction of Security Descriptor backups in restic 0.17.0, the inheritance property of Access Control Entries (ACEs) was not restored correctly. This resulted in all restored permissions being marked as explicit (IsInherited: False), even if they were originally inherited from a parent folder.
The issue was caused by sending conflicting inheritance flags (PROTECTED_... and UNPROTECTED_...) to the Windows API during the restore process. The API would default to the more restrictive PROTECTED state, effectively disabling inheritance.
This has been fixed by ensuring that only the correct, non-conflicting inheritance flag is used when applying the security descriptor, preserving the original permission structure from the backup.
https://github.com/restic/restic/pull/5465
https://github.com/restic/restic/issues/5427

View File

@@ -0,0 +1,6 @@
Enhancement: Add OpenContainers labels to Dockerfile.release
The restic Docker image now includes labels from the OpenContainers Annotations Spec.
This information can be used by third party services.
https://github.com/restic/restic/pull/5523

View File

@@ -0,0 +1,10 @@
Enhancement: Display timezone information in snapshots output
The `snapshots` command now displays which timezone is being used to show
timestamps. Since snapshots can be created in different timezones but are
always displayed in the local timezone, a footer line is now shown indicating
the timezone used for display (e.g., "Timestamps shown in CET timezone").
This helps prevent confusion when comparing snapshots in a multi-user
environment.
https://github.com/restic/restic/pull/5588

View File

@@ -0,0 +1,7 @@
Bugfix: Return error if `RESTIC_PACK_SIZE` contains invalid value
If the environment variable `RESTIC_PACK_SIZE` could not be parsed, then
restic ignored its value. Now, the restic commands fail with an error, unless
the command-line option `--pack-size` was specified.
https://github.com/restic/restic/pull/5592

View File

@@ -0,0 +1,7 @@
Enhancement: reduce memory usage of check/copy/diff/stats commands
We have optimized the memory usage of the `check`, `copy`, `diff` and
`stats` commands. These now require less memory when processing large
snapshots.
https://github.com/restic/restic/pull/5610

View File

@@ -0,0 +1,9 @@
Enhancement: stricter early mountpoint validation in `mount`
`restic mount` accepted parameters that would lead to a FUSE mount operation
failing after having done computationally intensive work to prepare the mount.
The `mountpoint` argument supplied must now refer to the name of a directory
that the current user can access and write to, otherwise `restic mount` will
exit with an error before interacting with the repository.
https://github.com/restic/restic/pull/5718

View File

@@ -2,6 +2,8 @@ package main
import (
"context"
"fmt"
"io"
"os"
"os/signal"
"syscall"
@@ -9,26 +11,27 @@ import (
"github.com/restic/restic/internal/debug"
)
func createGlobalContext() context.Context {
func createGlobalContext(stderr io.Writer) context.Context {
ctx, cancel := context.WithCancel(context.Background())
ch := make(chan os.Signal, 1)
go cleanupHandler(ch, cancel)
go cleanupHandler(ch, cancel, stderr)
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
return ctx
}
// cleanupHandler handles the SIGINT and SIGTERM signals.
func cleanupHandler(c <-chan os.Signal, cancel context.CancelFunc) {
func cleanupHandler(c <-chan os.Signal, cancel context.CancelFunc, stderr io.Writer) {
s := <-c
debug.Log("signal %v received, cleaning up", s)
Warnf("%ssignal %v received, cleaning up\n", clearLine(0), s)
// ignore error as there's no good way to handle it
_, _ = fmt.Fprintf(stderr, "\rsignal %v received, cleaning up \n", s)
if val, _ := os.LookupEnv("RESTIC_DEBUG_STACKTRACE_SIGINT"); val != "" {
_, _ = os.Stderr.WriteString("\n--- STACKTRACE START ---\n\n")
_, _ = os.Stderr.WriteString(debug.DumpStacktrace())
_, _ = os.Stderr.WriteString("\n--- STACKTRACE END ---\n")
_, _ = stderr.Write([]byte("\n--- STACKTRACE START ---\n\n"))
_, _ = stderr.Write([]byte(debug.DumpStacktrace()))
_, _ = stderr.Write([]byte("\n--- STACKTRACE END ---\n"))
}
cancel()

View File

@@ -15,23 +15,30 @@ import (
"time"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"golang.org/x/sync/errgroup"
"github.com/restic/restic/internal/archiver"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/filter"
"github.com/restic/restic/internal/fs"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/repository"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/textfile"
"github.com/restic/restic/internal/ui"
"github.com/restic/restic/internal/ui/backup"
"github.com/restic/restic/internal/ui/termstatus"
)
var cmdBackup = &cobra.Command{
Use: "backup [flags] [FILE/DIR] ...",
Short: "Create a new backup of files and/or directories",
Long: `
func newBackupCommand(globalOptions *global.Options) *cobra.Command {
var opts BackupOptions
cmd := &cobra.Command{
Use: "backup [flags] [FILE/DIR] ...",
Short: "Create a new backup of files and/or directories",
Long: `
The "backup" command creates a new snapshot and saves the files and directories
given as the arguments.
@@ -45,40 +52,43 @@ Exit status is 10 if the repository does not exist.
Exit status is 11 if the repository is already locked.
Exit status is 12 if the password is incorrect.
`,
PreRun: func(_ *cobra.Command, _ []string) {
if backupOptions.Host == "" {
hostname, err := os.Hostname()
if err != nil {
debug.Log("os.Hostname() returned err: %v", err)
return
PreRun: func(_ *cobra.Command, _ []string) {
if opts.Host == "" {
hostname, err := os.Hostname()
if err != nil {
debug.Log("os.Hostname() returned err: %v", err)
return
}
opts.Host = hostname
}
backupOptions.Host = hostname
}
},
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
term, cancel := setupTermstatus()
defer cancel()
return runBackup(cmd.Context(), backupOptions, globalOptions, term, args)
},
},
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runBackup(cmd.Context(), opts, *globalOptions, globalOptions.Term, args)
},
}
opts.AddFlags(cmd.Flags())
return cmd
}
// BackupOptions bundles all options for the backup command.
type BackupOptions struct {
excludePatternOptions
filter.ExcludePatternOptions
Parent string
GroupBy restic.SnapshotGroupByOptions
GroupBy data.SnapshotGroupByOptions
Force bool
ExcludeOtherFS bool
ExcludeIfPresent []string
ExcludeCaches bool
ExcludeLargerThan string
ExcludeCloudFiles bool
Stdin bool
StdinFilename string
StdinCommand bool
Tags restic.TagLists
Tags data.TagLists
Host string
FilesFrom []string
FilesFromVerbatim []string
@@ -94,70 +104,72 @@ type BackupOptions struct {
SkipIfUnchanged bool
}
var backupOptions BackupOptions
var backupFSTestHook func(fs fs.FS) fs.FS
func (opts *BackupOptions) AddFlags(f *pflag.FlagSet) {
f.StringVar(&opts.Parent, "parent", "", "use this parent `snapshot` (default: latest snapshot in the group determined by --group-by and not newer than the timestamp determined by --time)")
opts.GroupBy = data.SnapshotGroupByOptions{Host: true, Path: true}
f.VarP(&opts.GroupBy, "group-by", "g", "`group` snapshots by host, paths and/or tags, separated by comma (disable grouping with '')")
f.BoolVarP(&opts.Force, "force", "f", false, `force re-reading the source files/directories (overrides the "parent" flag)`)
// ErrInvalidSourceData is used to report an incomplete backup
var ErrInvalidSourceData = errors.New("at least one source file could not be read")
opts.ExcludePatternOptions.Add(f)
func init() {
cmdRoot.AddCommand(cmdBackup)
f := cmdBackup.Flags()
f.StringVar(&backupOptions.Parent, "parent", "", "use this parent `snapshot` (default: latest snapshot in the group determined by --group-by and not newer than the timestamp determined by --time)")
backupOptions.GroupBy = restic.SnapshotGroupByOptions{Host: true, Path: true}
f.VarP(&backupOptions.GroupBy, "group-by", "g", "`group` snapshots by host, paths and/or tags, separated by comma (disable grouping with '')")
f.BoolVarP(&backupOptions.Force, "force", "f", false, `force re-reading the source files/directories (overrides the "parent" flag)`)
initExcludePatternOptions(f, &backupOptions.excludePatternOptions)
f.BoolVarP(&backupOptions.ExcludeOtherFS, "one-file-system", "x", false, "exclude other file systems, don't cross filesystem boundaries and subvolumes")
f.StringArrayVar(&backupOptions.ExcludeIfPresent, "exclude-if-present", nil, "takes `filename[:header]`, exclude contents of directories containing filename (except filename itself) if header of that file is as provided (can be specified multiple times)")
f.BoolVar(&backupOptions.ExcludeCaches, "exclude-caches", false, `excludes cache directories that are marked with a CACHEDIR.TAG file. See https://bford.info/cachedir/ for the Cache Directory Tagging Standard`)
f.StringVar(&backupOptions.ExcludeLargerThan, "exclude-larger-than", "", "max `size` of the files to be backed up (allowed suffixes: k/K, m/M, g/G, t/T)")
f.BoolVar(&backupOptions.Stdin, "stdin", false, "read backup from stdin")
f.StringVar(&backupOptions.StdinFilename, "stdin-filename", "stdin", "`filename` to use when reading from stdin")
f.BoolVar(&backupOptions.StdinCommand, "stdin-from-command", false, "interpret arguments as command to execute and store its stdout")
f.Var(&backupOptions.Tags, "tag", "add `tags` for the new snapshot in the format `tag[,tag,...]` (can be specified multiple times)")
f.UintVar(&backupOptions.ReadConcurrency, "read-concurrency", 0, "read `n` files concurrently (default: $RESTIC_READ_CONCURRENCY or 2)")
f.StringVarP(&backupOptions.Host, "host", "H", "", "set the `hostname` for the snapshot manually (default: $RESTIC_HOST). To prevent an expensive rescan use the \"parent\" flag")
f.StringVar(&backupOptions.Host, "hostname", "", "set the `hostname` for the snapshot manually")
f.BoolVarP(&opts.ExcludeOtherFS, "one-file-system", "x", false, "exclude other file systems, don't cross filesystem boundaries and subvolumes")
f.StringArrayVar(&opts.ExcludeIfPresent, "exclude-if-present", nil, "takes `filename[:header]`, exclude contents of directories containing filename (except filename itself) if header of that file is as provided (can be specified multiple times)")
f.BoolVar(&opts.ExcludeCaches, "exclude-caches", false, `excludes cache directories that are marked with a CACHEDIR.TAG file. See https://bford.info/cachedir/ for the Cache Directory Tagging Standard`)
f.StringVar(&opts.ExcludeLargerThan, "exclude-larger-than", "", "max `size` of the files to be backed up (allowed suffixes: k/K, m/M, g/G, t/T)")
f.BoolVar(&opts.Stdin, "stdin", false, "read backup from stdin")
f.StringVar(&opts.StdinFilename, "stdin-filename", "stdin", "`filename` to use when reading from stdin")
f.BoolVar(&opts.StdinCommand, "stdin-from-command", false, "interpret arguments as command to execute and store its stdout")
f.Var(&opts.Tags, "tag", "add `tags` for the new snapshot in the format `tag[,tag,...]` (can be specified multiple times)")
f.UintVar(&opts.ReadConcurrency, "read-concurrency", 0, "read `n` files concurrently (default: $RESTIC_READ_CONCURRENCY or 2)")
f.StringVarP(&opts.Host, "host", "H", "", "set the `hostname` for the snapshot manually (default: $RESTIC_HOST). To prevent an expensive rescan use the \"parent\" flag")
f.StringVar(&opts.Host, "hostname", "", "set the `hostname` for the snapshot manually")
err := f.MarkDeprecated("hostname", "use --host")
if err != nil {
// MarkDeprecated only returns an error when the flag could not be found
panic(err)
}
f.StringArrayVar(&backupOptions.FilesFrom, "files-from", nil, "read the files to backup from `file` (can be combined with file args; can be specified multiple times)")
f.StringArrayVar(&backupOptions.FilesFromVerbatim, "files-from-verbatim", nil, "read the files to backup from `file` (can be combined with file args; can be specified multiple times)")
f.StringArrayVar(&backupOptions.FilesFromRaw, "files-from-raw", nil, "read the files to backup from `file` (can be combined with file args; can be specified multiple times)")
f.StringVar(&backupOptions.TimeStamp, "time", "", "`time` of the backup (ex. '2012-11-01 22:08:41') (default: now)")
f.BoolVar(&backupOptions.WithAtime, "with-atime", false, "store the atime for all files and directories")
f.BoolVar(&backupOptions.IgnoreInode, "ignore-inode", false, "ignore inode number and ctime changes when checking for modified files")
f.BoolVar(&backupOptions.IgnoreCtime, "ignore-ctime", false, "ignore ctime changes when checking for modified files")
f.BoolVarP(&backupOptions.DryRun, "dry-run", "n", false, "do not upload or write any data, just show what would be done")
f.BoolVar(&backupOptions.NoScan, "no-scan", false, "do not run scanner to estimate size of backup")
f.StringArrayVar(&opts.FilesFrom, "files-from", nil, "read the files to backup from `file` (can be combined with file args; can be specified multiple times)")
f.StringArrayVar(&opts.FilesFromVerbatim, "files-from-verbatim", nil, "read the files to backup from `file` (can be combined with file args; can be specified multiple times)")
f.StringArrayVar(&opts.FilesFromRaw, "files-from-raw", nil, "read the files to backup from `file` (can be combined with file args; can be specified multiple times)")
f.StringVar(&opts.TimeStamp, "time", "", "`time` of the backup (ex. '2012-11-01 22:08:41') (default: now)")
f.BoolVar(&opts.WithAtime, "with-atime", false, "store the atime for all files and directories")
f.BoolVar(&opts.IgnoreInode, "ignore-inode", false, "ignore inode number and ctime changes when checking for modified files")
f.BoolVar(&opts.IgnoreCtime, "ignore-ctime", false, "ignore ctime changes when checking for modified files")
f.BoolVarP(&opts.DryRun, "dry-run", "n", false, "do not upload or write any data, just show what would be done")
f.BoolVar(&opts.NoScan, "no-scan", false, "do not run scanner to estimate size of backup")
if runtime.GOOS == "windows" {
f.BoolVar(&backupOptions.UseFsSnapshot, "use-fs-snapshot", false, "use filesystem snapshot where possible (currently only Windows VSS)")
f.BoolVar(&opts.UseFsSnapshot, "use-fs-snapshot", false, "use filesystem snapshot where possible (currently only Windows VSS)")
}
f.BoolVar(&backupOptions.SkipIfUnchanged, "skip-if-unchanged", false, "skip snapshot creation if identical to parent snapshot")
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
f.BoolVar(&opts.ExcludeCloudFiles, "exclude-cloud-files", false, "excludes online-only cloud files (such as OneDrive, iCloud drive, …)")
}
f.BoolVar(&opts.SkipIfUnchanged, "skip-if-unchanged", false, "skip snapshot creation if identical to parent snapshot")
// parse read concurrency from env, on error the default value will be used
readConcurrency, _ := strconv.ParseUint(os.Getenv("RESTIC_READ_CONCURRENCY"), 10, 32)
backupOptions.ReadConcurrency = uint(readConcurrency)
opts.ReadConcurrency = uint(readConcurrency)
// parse host from env, if not exists or empty the default value will be used
if host := os.Getenv("RESTIC_HOST"); host != "" {
backupOptions.Host = host
opts.Host = host
}
}
var backupFSTestHook func(fs fs.FS) fs.FS
// ErrInvalidSourceData is used to report an incomplete backup
var ErrInvalidSourceData = errors.New("at least one source file could not be read")
// ErrNoSourceData is used to report that no source data was found
var ErrNoSourceData = errors.Fatal("all source directories/files do not exist")
// filterExisting returns a slice of all existing items, or an error if no
// items exist at all.
func filterExisting(items []string) (result []string, err error) {
func filterExisting(items []string, warnf func(msg string, args ...interface{})) (result []string, err error) {
for _, item := range items {
_, err := fs.Lstat(item)
if errors.Is(err, os.ErrNotExist) {
Warnf("%v does not exist, skipping\n", item)
warnf("%v does not exist, skipping\n", item)
continue
}
@@ -165,10 +177,12 @@ func filterExisting(items []string) (result []string, err error) {
}
if len(result) == 0 {
return nil, errors.Fatal("all source directories/files do not exist")
return nil, ErrNoSourceData
} else if len(result) < len(items) {
return result, ErrInvalidSourceData
}
return
return result, nil
}
// readLines reads all lines from the named file and returns them as a
@@ -177,7 +191,7 @@ func filterExisting(items []string) (result []string, err error) {
// If filename is empty, readPatternsFromFile returns an empty slice.
// If filename is a dash (-), readPatternsFromFile will read the lines from the
// standard input.
func readLines(filename string) ([]string, error) {
func readLines(filename string, stdin io.ReadCloser) ([]string, error) {
if filename == "" {
return nil, nil
}
@@ -188,7 +202,7 @@ func readLines(filename string) ([]string, error) {
)
if filename == "-" {
data, err = io.ReadAll(os.Stdin)
data, err = io.ReadAll(stdin)
} else {
data, err = textfile.Read(filename)
}
@@ -213,8 +227,8 @@ func readLines(filename string) ([]string, error) {
// readFilenamesFromFileRaw reads a list of filenames from the given file,
// or stdin if filename is "-". Each filename is terminated by a zero byte,
// which is stripped off.
func readFilenamesFromFileRaw(filename string) (names []string, err error) {
f := os.Stdin
func readFilenamesFromFileRaw(filename string, stdin io.ReadCloser) (names []string, err error) {
f := stdin
if filename != "-" {
if f, err = os.Open(filename); err != nil {
return nil, err
@@ -263,8 +277,8 @@ func readFilenamesRaw(r io.Reader) (names []string, err error) {
}
// Check returns an error when an invalid combination of options was set.
func (opts BackupOptions) Check(gopts GlobalOptions, args []string) error {
if gopts.password == "" && !gopts.InsecureNoPassword {
func (opts BackupOptions) Check(gopts global.Options, args []string) error {
if gopts.Password == "" && !gopts.InsecureNoPassword {
if opts.Stdin {
return errors.Fatal("cannot read both password and data from stdin")
}
@@ -298,9 +312,9 @@ func (opts BackupOptions) Check(gopts GlobalOptions, args []string) error {
// collectRejectByNameFuncs returns a list of all functions which may reject data
// from being saved in a snapshot based on path only
func collectRejectByNameFuncs(opts BackupOptions, repo *repository.Repository) (fs []RejectByNameFunc, err error) {
func collectRejectByNameFuncs(opts BackupOptions, repo *repository.Repository, warnf func(msg string, args ...interface{})) (fs []archiver.RejectByNameFunc, err error) {
// exclude restic cache
if repo.Cache != nil {
if repo.Cache() != nil {
f, err := rejectResticCache(repo)
if err != nil {
return nil, err
@@ -309,23 +323,12 @@ func collectRejectByNameFuncs(opts BackupOptions, repo *repository.Repository) (
fs = append(fs, f)
}
fsPatterns, err := opts.excludePatternOptions.CollectPatterns()
fsPatterns, err := opts.ExcludePatternOptions.CollectPatterns(warnf)
if err != nil {
return nil, err
}
fs = append(fs, fsPatterns...)
if opts.ExcludeCaches {
opts.ExcludeIfPresent = append(opts.ExcludeIfPresent, "CACHEDIR.TAG:Signature: 8a477f597d28d172789f06886806bc55")
}
for _, spec := range opts.ExcludeIfPresent {
f, err := rejectIfPresent(spec)
if err != nil {
return nil, err
}
fs = append(fs, f)
for _, pat := range fsPatterns {
fs = append(fs, archiver.RejectByNameFunc(pat))
}
return fs, nil
@@ -333,35 +336,61 @@ func collectRejectByNameFuncs(opts BackupOptions, repo *repository.Repository) (
// collectRejectFuncs returns a list of all functions which may reject data
// from being saved in a snapshot based on path and file info
func collectRejectFuncs(opts BackupOptions, targets []string) (fs []RejectFunc, err error) {
func collectRejectFuncs(opts BackupOptions, targets []string, fs fs.FS, warnf func(msg string, args ...interface{})) (funcs []archiver.RejectFunc, err error) {
// allowed devices
if opts.ExcludeOtherFS && !opts.Stdin {
f, err := rejectByDevice(targets)
if opts.ExcludeOtherFS && !opts.Stdin && !opts.StdinCommand {
f, err := archiver.RejectByDevice(targets, fs)
if err != nil {
return nil, err
}
fs = append(fs, f)
funcs = append(funcs, f)
}
if len(opts.ExcludeLargerThan) != 0 && !opts.Stdin {
f, err := rejectBySize(opts.ExcludeLargerThan)
if len(opts.ExcludeLargerThan) != 0 && !opts.Stdin && !opts.StdinCommand {
maxSize, err := ui.ParseBytes(opts.ExcludeLargerThan)
if err != nil {
return nil, err
}
fs = append(fs, f)
f, err := archiver.RejectBySize(maxSize)
if err != nil {
return nil, err
}
funcs = append(funcs, f)
}
return fs, nil
if opts.ExcludeCloudFiles && !opts.Stdin && !opts.StdinCommand {
f, err := archiver.RejectCloudFiles(warnf)
if err != nil {
return nil, err
}
funcs = append(funcs, f)
}
if opts.ExcludeCaches {
opts.ExcludeIfPresent = append(opts.ExcludeIfPresent, "CACHEDIR.TAG:Signature: 8a477f597d28d172789f06886806bc55")
}
for _, spec := range opts.ExcludeIfPresent {
f, err := archiver.RejectIfPresent(spec, warnf)
if err != nil {
return nil, err
}
funcs = append(funcs, f)
}
return funcs, nil
}
// collectTargets returns a list of target files/dirs from several sources.
func collectTargets(opts BackupOptions, args []string) (targets []string, err error) {
func collectTargets(opts BackupOptions, args []string, warnf func(msg string, args ...interface{}), stdin io.ReadCloser) (targets []string, err error) {
if opts.Stdin || opts.StdinCommand {
return nil, nil
}
for _, file := range opts.FilesFrom {
fromfile, err := readLines(file)
fromfile, err := readLines(file, stdin)
if err != nil {
return nil, err
}
@@ -379,14 +408,14 @@ func collectTargets(opts BackupOptions, args []string) (targets []string, err er
return nil, fmt.Errorf("pattern: %s: %w", line, err)
}
if len(expanded) == 0 {
Warnf("pattern %q does not match any files, skipping\n", line)
warnf("pattern %q does not match any files, skipping\n", line)
}
targets = append(targets, expanded...)
}
}
for _, file := range opts.FilesFromVerbatim {
fromfile, err := readLines(file)
fromfile, err := readLines(file, stdin)
if err != nil {
return nil, err
}
@@ -399,7 +428,7 @@ func collectTargets(opts BackupOptions, args []string) (targets []string, err er
}
for _, file := range opts.FilesFromRaw {
fromfile, err := readFilenamesFromFileRaw(file)
fromfile, err := readFilenamesFromFileRaw(file, stdin)
if err != nil {
return nil, err
}
@@ -413,17 +442,12 @@ func collectTargets(opts BackupOptions, args []string) (targets []string, err er
return nil, errors.Fatal("nothing to backup, please specify source files/dirs")
}
targets, err = filterExisting(targets)
if err != nil {
return nil, err
}
return targets, nil
return filterExisting(targets, warnf)
}
// parent returns the ID of the parent snapshot. If there is none, nil is
// returned.
func findParentSnapshot(ctx context.Context, repo restic.ListerLoaderUnpacked, opts BackupOptions, targets []string, timeStampLimit time.Time) (*restic.Snapshot, error) {
func findParentSnapshot(ctx context.Context, repo restic.ListerLoaderUnpacked, opts BackupOptions, targets []string, timeStampLimit time.Time) (*data.Snapshot, error) {
if opts.Force {
return nil, nil
}
@@ -432,7 +456,7 @@ func findParentSnapshot(ctx context.Context, repo restic.ListerLoaderUnpacked, o
if snName == "" {
snName = "latest"
}
f := restic.SnapshotFilter{TimestampLimit: timeStampLimit}
f := data.SnapshotFilter{TimestampLimit: timeStampLimit}
if opts.GroupBy.Host {
f.Hosts = []string{opts.Host}
}
@@ -440,23 +464,29 @@ func findParentSnapshot(ctx context.Context, repo restic.ListerLoaderUnpacked, o
f.Paths = targets
}
if opts.GroupBy.Tag {
f.Tags = []restic.TagList{opts.Tags.Flatten()}
f.Tags = []data.TagList{opts.Tags.Flatten()}
}
sn, _, err := f.FindLatest(ctx, repo, repo, snName)
// Snapshot not found is ok if no explicit parent was set
if opts.Parent == "" && errors.Is(err, restic.ErrNoSnapshotFound) {
if opts.Parent == "" && errors.Is(err, data.ErrNoSnapshotFound) {
err = nil
}
return sn, err
}
func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, term *termstatus.Terminal, args []string) error {
func runBackup(ctx context.Context, opts BackupOptions, gopts global.Options, term ui.Terminal, args []string) error {
var vsscfg fs.VSSConfig
var err error
var printer backup.ProgressPrinter
if gopts.JSON {
printer = backup.NewJSONProgress(term, gopts.Verbosity)
} else {
printer = backup.NewTextProgress(term, gopts.Verbosity)
}
if runtime.GOOS == "windows" {
if vsscfg, err = fs.ParseVSSConfig(gopts.extended); err != nil {
if vsscfg, err = fs.ParseVSSConfig(gopts.Extended); err != nil {
return err
}
}
@@ -466,53 +496,46 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
return err
}
targets, err := collectTargets(opts, args)
success := true
targets, err := collectTargets(opts, args, printer.E, term.InputRaw())
if err != nil {
return err
if errors.Is(err, ErrInvalidSourceData) {
success = false
} else {
return err
}
}
timeStamp := time.Now()
backupStart := timeStamp
if opts.TimeStamp != "" {
timeStamp, err = time.ParseInLocation(TimeFormat, opts.TimeStamp, time.Local)
timeStamp, err = time.ParseInLocation(global.TimeFormat, opts.TimeStamp, time.Local)
if err != nil {
return errors.Fatalf("error in time option: %v\n", err)
return errors.Fatalf("error in time option: %v", err)
}
}
if gopts.verbosity >= 2 && !gopts.JSON {
Verbosef("open repository\n")
if gopts.Verbosity >= 2 && !gopts.JSON {
printer.P("open repository")
}
ctx, repo, unlock, err := openWithAppendLock(ctx, gopts, opts.DryRun)
ctx, repo, unlock, err := openWithAppendLock(ctx, gopts, opts.DryRun, printer)
if err != nil {
return err
}
defer unlock()
var progressPrinter backup.ProgressPrinter
if gopts.JSON {
progressPrinter = backup.NewJSONProgress(term, gopts.verbosity)
} else {
progressPrinter = backup.NewTextProgress(term, gopts.verbosity)
}
progressReporter := backup.NewProgress(progressPrinter,
calculateProgressInterval(!gopts.Quiet, gopts.JSON))
progressReporter := backup.NewProgress(printer,
ui.CalculateProgressInterval(!gopts.Quiet, gopts.JSON, term.CanUpdateStatus()))
defer progressReporter.Done()
// rejectByNameFuncs collect functions that can reject items from the backup based on path only
rejectByNameFuncs, err := collectRejectByNameFuncs(opts, repo)
rejectByNameFuncs, err := collectRejectByNameFuncs(opts, repo, printer.E)
if err != nil {
return err
}
// rejectFuncs collect functions that can reject items from the backup based on path and file info
rejectFuncs, err := collectRejectFuncs(opts, targets)
if err != nil {
return err
}
var parentSnapshot *restic.Snapshot
var parentSnapshot *data.Snapshot
if !opts.Stdin {
parentSnapshot, err = findParentSnapshot(ctx, repo, opts, targets, timeStamp)
if err != nil {
@@ -521,42 +544,22 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
if !gopts.JSON {
if parentSnapshot != nil {
progressPrinter.P("using parent snapshot %v\n", parentSnapshot.ID().Str())
printer.P("using parent snapshot %v\n", parentSnapshot.ID().Str())
} else {
progressPrinter.P("no parent snapshot found, will read all files\n")
printer.P("no parent snapshot found, will read all files\n")
}
}
}
if !gopts.JSON {
progressPrinter.V("load index files")
printer.V("load index files")
}
bar := newIndexTerminalProgress(gopts.Quiet, gopts.JSON, term)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
selectByNameFilter := func(item string) bool {
for _, reject := range rejectByNameFuncs {
if reject(item) {
return false
}
}
return true
}
selectFilter := func(item string, fi os.FileInfo) bool {
for _, reject := range rejectFuncs {
if reject(item, fi) {
return false
}
}
return true
}
var targetFS fs.FS = fs.Local{}
if runtime.GOOS == "windows" && opts.UseFsSnapshot {
if err = fs.HasSufficientPrivilegesForVSS(); err != nil {
@@ -569,7 +572,7 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
messageHandler := func(msg string, args ...interface{}) {
if !gopts.JSON {
progressPrinter.P(msg, args...)
printer.P(msg, args...)
}
}
@@ -580,21 +583,22 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
if opts.Stdin || opts.StdinCommand {
if !gopts.JSON {
progressPrinter.V("read data from stdin")
printer.V("read data from stdin")
}
filename := path.Join("/", opts.StdinFilename)
var source io.ReadCloser = os.Stdin
source := term.InputRaw()
if opts.StdinCommand {
source, err = fs.NewCommandReader(ctx, args, globalOptions.stderr)
source, err = fs.NewCommandReader(ctx, args, printer.E)
if err != nil {
return err
}
}
targetFS = &fs.Reader{
ModTime: timeStamp,
Name: filename,
Mode: 0644,
ReadCloser: source,
targetFS, err = fs.NewReader(filename, source, fs.ReaderOptions{
ModTime: timeStamp,
Mode: 0644,
})
if err != nil {
return fmt.Errorf("failed to backup from stdin: %w", err)
}
targets = []string{filename}
}
@@ -603,6 +607,15 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
targetFS = backupFSTestHook(targetFS)
}
// rejectFuncs collect functions that can reject items from the backup based on path and file info
rejectFuncs, err := collectRejectFuncs(opts, targets, targetFS, printer.E)
if err != nil {
return err
}
selectByNameFilter := archiver.CombineRejectByNames(rejectByNameFuncs)
selectFilter := archiver.CombineRejects(rejectFuncs)
wg, wgCtx := errgroup.WithContext(ctx)
cancelCtx, cancel := context.WithCancel(wgCtx)
defer cancel()
@@ -611,11 +624,11 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
sc := archiver.NewScanner(targetFS)
sc.SelectByName = selectByNameFilter
sc.Select = selectFilter
sc.Error = progressPrinter.ScannerError
sc.Error = printer.ScannerError
sc.Result = progressReporter.ReportTotal
if !gopts.JSON {
progressPrinter.V("start scan on %v", targets)
printer.V("start scan on %v", targets)
}
wg.Go(func() error { return sc.Scan(cancelCtx, targets) })
}
@@ -624,7 +637,7 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
arch.SelectByName = selectByNameFilter
arch.Select = selectFilter
arch.WithAtime = opts.WithAtime
success := true
arch.Error = func(item string, err error) error {
success = false
reterr := progressReporter.Error(item, err)
@@ -655,12 +668,12 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
Time: timeStamp,
Hostname: opts.Host,
ParentSnapshot: parentSnapshot,
ProgramVersion: "restic " + version,
ProgramVersion: "restic " + global.Version,
SkipIfUnchanged: opts.SkipIfUnchanged,
}
if !gopts.JSON {
progressPrinter.V("start backup on %v", targets)
printer.V("start backup on %v", targets)
}
_, id, summary, err := arch.Snapshot(ctx, targets, snapshotOpts)

View File

@@ -3,35 +3,36 @@ package main
import (
"context"
"fmt"
"io"
"os"
"path/filepath"
"runtime"
"testing"
"time"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/fs"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/restic"
rtest "github.com/restic/restic/internal/test"
"github.com/restic/restic/internal/ui/termstatus"
)
func testRunBackupAssumeFailure(t testing.TB, dir string, target []string, opts BackupOptions, gopts GlobalOptions) error {
return withTermStatus(gopts, func(ctx context.Context, term *termstatus.Terminal) error {
func testRunBackupAssumeFailure(t testing.TB, dir string, target []string, opts BackupOptions, gopts global.Options) error {
return withTermStatus(t, gopts, func(ctx context.Context, gopts global.Options) error {
t.Logf("backing up %v in %v", target, dir)
if dir != "" {
cleanup := rtest.Chdir(t, dir)
defer cleanup()
}
opts.GroupBy = restic.SnapshotGroupByOptions{Host: true, Path: true}
return runBackup(ctx, opts, gopts, term, target)
opts.GroupBy = data.SnapshotGroupByOptions{Host: true, Path: true}
return runBackup(ctx, opts, gopts, gopts.Term, target)
})
}
func testRunBackup(t testing.TB, dir string, target []string, opts BackupOptions, gopts GlobalOptions) {
func testRunBackup(t testing.TB, dir string, target []string, opts BackupOptions, gopts global.Options) {
err := testRunBackupAssumeFailure(t, dir, target, opts, gopts)
rtest.Assert(t, err == nil, "Error while backing up")
rtest.Assert(t, err == nil, "Error while backing up: %v", err)
}
func TestBackup(t *testing.T) {
@@ -56,13 +57,13 @@ func testBackup(t *testing.T, useFsSnapshot bool) {
testListSnapshots(t, env.gopts, 1)
testRunCheck(t, env.gopts)
stat1 := dirStats(env.repo)
stat1 := dirStats(t, env.repo)
// second backup, implicit incremental
testRunBackup(t, "", []string{env.testdata}, opts, env.gopts)
snapshotIDs := testListSnapshots(t, env.gopts, 2)
stat2 := dirStats(env.repo)
stat2 := dirStats(t, env.repo)
if stat2.size > stat1.size+stat1.size/10 {
t.Error("repository size has grown by more than 10 percent")
}
@@ -74,7 +75,7 @@ func testBackup(t *testing.T, useFsSnapshot bool) {
testRunBackup(t, "", []string{env.testdata}, opts, env.gopts)
snapshotIDs = testListSnapshots(t, env.gopts, 3)
stat3 := dirStats(env.repo)
stat3 := dirStats(t, env.repo)
if stat3.size > stat1.size+stat1.size/10 {
t.Error("repository size has grown by more than 10 percent")
}
@@ -85,7 +86,7 @@ func testBackup(t *testing.T, useFsSnapshot bool) {
restoredir := filepath.Join(env.base, fmt.Sprintf("restore%d", i))
t.Logf("restoring snapshot %v to %v", snapshotID.Str(), restoredir)
testRunRestore(t, env.gopts, restoredir, snapshotID.String()+":"+toPathInSnapshot(filepath.Dir(env.testdata)))
diff := directoriesContentsDiff(env.testdata, filepath.Join(restoredir, "testdata"))
diff := directoriesContentsDiff(t, env.testdata, filepath.Join(restoredir, "testdata"))
rtest.Assert(t, diff == "", "directories are not equal: %v", diff)
}
@@ -132,7 +133,7 @@ type vssDeleteOriginalFS struct {
hasRemoved bool
}
func (f *vssDeleteOriginalFS) Lstat(name string) (os.FileInfo, error) {
func (f *vssDeleteOriginalFS) Lstat(name string) (*fs.ExtendedFileInfo, error) {
if !f.hasRemoved {
// call Lstat to trigger snapshot creation
_, _ = f.FS.Lstat(name)
@@ -218,41 +219,41 @@ func TestDryRunBackup(t *testing.T) {
// dry run before first backup
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, dryOpts, env.gopts)
snapshotIDs := testListSnapshots(t, env.gopts, 0)
packIDs := testRunList(t, "packs", env.gopts)
packIDs := testRunList(t, env.gopts, "packs")
rtest.Assert(t, len(packIDs) == 0,
"expected no data, got %v", snapshotIDs)
indexIDs := testRunList(t, "index", env.gopts)
indexIDs := testRunList(t, env.gopts, "index")
rtest.Assert(t, len(indexIDs) == 0,
"expected no index, got %v", snapshotIDs)
// first backup
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts)
snapshotIDs = testListSnapshots(t, env.gopts, 1)
packIDs = testRunList(t, "packs", env.gopts)
indexIDs = testRunList(t, "index", env.gopts)
packIDs = testRunList(t, env.gopts, "packs")
indexIDs = testRunList(t, env.gopts, "index")
// dry run between backups
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, dryOpts, env.gopts)
snapshotIDsAfter := testListSnapshots(t, env.gopts, 1)
rtest.Equals(t, snapshotIDs, snapshotIDsAfter)
dataIDsAfter := testRunList(t, "packs", env.gopts)
dataIDsAfter := testRunList(t, env.gopts, "packs")
rtest.Equals(t, packIDs, dataIDsAfter)
indexIDsAfter := testRunList(t, "index", env.gopts)
indexIDsAfter := testRunList(t, env.gopts, "index")
rtest.Equals(t, indexIDs, indexIDsAfter)
// second backup, implicit incremental
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts)
snapshotIDs = testListSnapshots(t, env.gopts, 2)
packIDs = testRunList(t, "packs", env.gopts)
indexIDs = testRunList(t, "index", env.gopts)
packIDs = testRunList(t, env.gopts, "packs")
indexIDs = testRunList(t, env.gopts, "index")
// another dry run
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, dryOpts, env.gopts)
snapshotIDsAfter = testListSnapshots(t, env.gopts, 2)
rtest.Equals(t, snapshotIDs, snapshotIDsAfter)
dataIDsAfter = testRunList(t, "packs", env.gopts)
dataIDsAfter = testRunList(t, env.gopts, "packs")
rtest.Equals(t, packIDs, dataIDsAfter)
indexIDsAfter = testRunList(t, "index", env.gopts)
indexIDsAfter = testRunList(t, env.gopts, "index")
rtest.Equals(t, indexIDs, indexIDsAfter)
}
@@ -262,22 +263,27 @@ func TestBackupNonExistingFile(t *testing.T) {
testSetupBackupData(t, env)
_ = withRestoreGlobalOptions(func() error {
globalOptions.stderr = io.Discard
p := filepath.Join(env.testdata, "0", "0", "9")
dirs := []string{
filepath.Join(p, "0"),
filepath.Join(p, "1"),
filepath.Join(p, "nonexisting"),
filepath.Join(p, "5"),
}
p := filepath.Join(env.testdata, "0", "0", "9")
dirs := []string{
filepath.Join(p, "0"),
filepath.Join(p, "1"),
filepath.Join(p, "nonexisting"),
filepath.Join(p, "5"),
}
opts := BackupOptions{}
opts := BackupOptions{}
testRunBackup(t, "", dirs, opts, env.gopts)
return nil
})
// mix of existing and non-existing files
err := testRunBackupAssumeFailure(t, "", dirs, opts, env.gopts)
rtest.Assert(t, err != nil, "expected error for non-existing file")
rtest.Assert(t, errors.Is(err, ErrInvalidSourceData), "expected ErrInvalidSourceData; got %v", err)
// only non-existing file
dirs = []string{
filepath.Join(p, "nonexisting"),
}
err = testRunBackupAssumeFailure(t, "", dirs, opts, env.gopts)
rtest.Assert(t, err != nil, "expected error for non-existing file")
rtest.Assert(t, errors.Is(err, ErrNoSourceData), "expected ErrNoSourceData; got %v", err)
}
func TestBackupSelfHealing(t *testing.T) {
@@ -365,12 +371,7 @@ func TestBackupExclude(t *testing.T) {
for _, filename := range backupExcludeFilenames {
fp := filepath.Join(datadir, filename)
rtest.OK(t, os.MkdirAll(filepath.Dir(fp), 0755))
f, err := os.Create(fp)
rtest.OK(t, err)
fmt.Fprint(f, filename)
rtest.OK(t, f.Close())
rtest.OK(t, os.WriteFile(fp, []byte(filename), 0o666))
}
snapshots := make(map[string]struct{})
@@ -443,13 +444,13 @@ func TestIncrementalBackup(t *testing.T) {
testRunBackup(t, "", []string{datadir}, opts, env.gopts)
testRunCheck(t, env.gopts)
stat1 := dirStats(env.repo)
stat1 := dirStats(t, env.repo)
rtest.OK(t, appendRandomData(testfile, incrementalSecondWrite))
testRunBackup(t, "", []string{datadir}, opts, env.gopts)
testRunCheck(t, env.gopts)
stat2 := dirStats(env.repo)
stat2 := dirStats(t, env.repo)
if stat2.size-stat1.size > incrementalFirstWrite {
t.Errorf("repository size has grown by more than %d bytes", incrementalFirstWrite)
}
@@ -459,14 +460,13 @@ func TestIncrementalBackup(t *testing.T) {
testRunBackup(t, "", []string{datadir}, opts, env.gopts)
testRunCheck(t, env.gopts)
stat3 := dirStats(env.repo)
stat3 := dirStats(t, env.repo)
if stat3.size-stat2.size > incrementalFirstWrite {
t.Errorf("repository size has grown by more than %d bytes", incrementalFirstWrite)
}
t.Logf("repository grown by %d bytes", stat3.size-stat2.size)
}
// nolint: staticcheck // false positive nil pointer dereference check
func TestBackupTags(t *testing.T) {
env, cleanup := withTestEnvironment(t)
defer cleanup()
@@ -486,7 +486,7 @@ func TestBackupTags(t *testing.T) {
"expected no tags, got %v", newest.Tags)
parent := newest
opts.Tags = restic.TagLists{[]string{"NL"}}
opts.Tags = data.TagLists{[]string{"NL"}}
testRunBackup(t, "", []string{env.testdata}, opts, env.gopts)
testRunCheck(t, env.gopts)
newest, _ = testRunSnapshots(t, env.gopts)
@@ -502,7 +502,6 @@ func TestBackupTags(t *testing.T) {
"expected parent to be %v, got %v", parent.ID, newest.Parent)
}
// nolint: staticcheck // false positive nil pointer dereference check
func TestBackupProgramVersion(t *testing.T) {
env, cleanup := withTestEnvironment(t)
defer cleanup()
@@ -514,7 +513,7 @@ func TestBackupProgramVersion(t *testing.T) {
if newest == nil {
t.Fatal("expected a backup, got nil")
}
resticVersion := "restic " + version
resticVersion := "restic " + global.Version
rtest.Assert(t, newest.ProgramVersion == resticVersion,
"expected %v, got %v", resticVersion, newest.ProgramVersion)
}
@@ -572,7 +571,7 @@ func TestHardLink(t *testing.T) {
restoredir := filepath.Join(env.base, fmt.Sprintf("restore%d", i))
t.Logf("restoring snapshot %v to %v", snapshotID.Str(), restoredir)
testRunRestore(t, env.gopts, restoredir, snapshotID.String())
diff := directoriesContentsDiff(env.testdata, filepath.Join(restoredir, "testdata"))
diff := directoriesContentsDiff(t, env.testdata, filepath.Join(restoredir, "testdata"))
rtest.Assert(t, diff == "", "directories are not equal %v", diff)
linkResults := createFileSetPerHardlink(filepath.Join(restoredir, "testdata"))
@@ -637,12 +636,15 @@ func TestStdinFromCommand(t *testing.T) {
testSetupBackupData(t, env)
opts := BackupOptions{
StdinCommand: true,
StdinFilename: "stdin",
StdinCommand: true,
// test that subdirectories are handled correctly
StdinFilename: "stdin/subdir/file",
}
testRunBackup(t, filepath.Dir(env.testdata), []string{"python", "-c", "import sys; print('something'); sys.exit(0)"}, opts, env.gopts)
testListSnapshots(t, env.gopts, 1)
snapshots := testListSnapshots(t, env.gopts, 1)
files := testRunLs(t, env.gopts, snapshots[0].String())
rtest.Assert(t, includes(files, "/stdin/subdir/file"), "file %q missing from snapshot, got %v", "stdin/subdir/file", files)
testRunCheck(t, env.gopts)
}
@@ -705,7 +707,7 @@ func TestBackupEmptyPassword(t *testing.T) {
env, cleanup := withTestEnvironment(t)
defer cleanup()
env.gopts.password = ""
env.gopts.Password = ""
env.gopts.InsecureNoPassword = true
testSetupBackupData(t, env)

View File

@@ -39,21 +39,24 @@ func TestCollectTargets(t *testing.T) {
f1, err := os.Create(filepath.Join(dir, "fromfile"))
rtest.OK(t, err)
// Empty lines should be ignored. A line starting with '#' is a comment.
fmt.Fprintf(f1, "\n%s*\n # here's a comment\n", f1.Name())
_, err = fmt.Fprintf(f1, "\n%s*\n # here's a comment\n", f1.Name())
rtest.OK(t, err)
rtest.OK(t, f1.Close())
f2, err := os.Create(filepath.Join(dir, "fromfile-verbatim"))
rtest.OK(t, err)
for _, filename := range []string{fooSpace, barStar} {
// Empty lines should be ignored. CR+LF is allowed.
fmt.Fprintf(f2, "%s\r\n\n", filepath.Join(dir, filename))
_, err = fmt.Fprintf(f2, "%s\r\n\n", filepath.Join(dir, filename))
rtest.OK(t, err)
}
rtest.OK(t, f2.Close())
f3, err := os.Create(filepath.Join(dir, "fromfile-raw"))
rtest.OK(t, err)
for _, filename := range []string{"baz", "quux"} {
fmt.Fprintf(f3, "%s\x00", filepath.Join(dir, filename))
_, err = fmt.Fprintf(f3, "%s\x00", filepath.Join(dir, filename))
rtest.OK(t, err)
}
rtest.OK(t, err)
rtest.OK(t, f3.Close())
@@ -64,10 +67,13 @@ func TestCollectTargets(t *testing.T) {
FilesFromRaw: []string{f3.Name()},
}
targets, err := collectTargets(opts, []string{filepath.Join(dir, "cmdline arg")})
targets, err := collectTargets(opts, []string{filepath.Join(dir, "cmdline arg")}, t.Logf, nil)
rtest.OK(t, err)
sort.Strings(targets)
rtest.Equals(t, expect, targets)
_, err = collectTargets(opts, []string{filepath.Join(dir, "cmdline arg"), filepath.Join(dir, "non-existing-file")}, t.Logf, nil)
rtest.Assert(t, err == ErrInvalidSourceData, "expected error when not all targets exist")
}
func TestReadFilenamesRaw(t *testing.T) {

View File

@@ -10,16 +10,20 @@ import (
"github.com/restic/restic/internal/backend/cache"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/fs"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/ui"
"github.com/restic/restic/internal/ui/table"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
var cmdCache = &cobra.Command{
Use: "cache",
Short: "Operate on local cache directories",
Long: `
func newCacheCommand(globalOptions *global.Options) *cobra.Command {
var opts CacheOptions
cmd := &cobra.Command{
Use: "cache",
Short: "Operate on local cache directories",
Long: `
The "cache" command allows listing and cleaning local cache directories.
EXIT STATUS
@@ -28,11 +32,15 @@ EXIT STATUS
Exit status is 0 if the command was successful.
Exit status is 1 if there was any error.
`,
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(_ *cobra.Command, args []string) error {
return runCache(cacheOptions, globalOptions, args)
},
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(_ *cobra.Command, args []string) error {
return runCache(opts, *globalOptions, args, globalOptions.Term)
},
}
opts.AddFlags(cmd.Flags())
return cmd
}
// CacheOptions bundles all options for the snapshots command.
@@ -42,18 +50,15 @@ type CacheOptions struct {
NoSize bool
}
var cacheOptions CacheOptions
func init() {
cmdRoot.AddCommand(cmdCache)
f := cmdCache.Flags()
f.BoolVar(&cacheOptions.Cleanup, "cleanup", false, "remove old cache directories")
f.UintVar(&cacheOptions.MaxAge, "max-age", 30, "max age in `days` for cache directories to be considered old")
f.BoolVar(&cacheOptions.NoSize, "no-size", false, "do not output the size of the cache directories")
func (opts *CacheOptions) AddFlags(f *pflag.FlagSet) {
f.BoolVar(&opts.Cleanup, "cleanup", false, "remove old cache directories")
f.UintVar(&opts.MaxAge, "max-age", 30, "max age in `days` for cache directories to be considered old")
f.BoolVar(&opts.NoSize, "no-size", false, "do not output the size of the cache directories")
}
func runCache(opts CacheOptions, gopts GlobalOptions, args []string) error {
func runCache(opts CacheOptions, gopts global.Options, args []string, term ui.Terminal) error {
printer := ui.NewProgressPrinter(false, gopts.Verbosity, term)
if len(args) > 0 {
return errors.Fatal("the cache command expects no arguments, only options - please see `restic help cache` for usage and flags")
}
@@ -81,17 +86,17 @@ func runCache(opts CacheOptions, gopts GlobalOptions, args []string) error {
}
if len(oldDirs) == 0 {
Verbosef("no old cache dirs found\n")
printer.P("no old cache dirs found")
return nil
}
Verbosef("remove %d old cache directories\n", len(oldDirs))
printer.P("remove %d old cache directories", len(oldDirs))
for _, item := range oldDirs {
dir := filepath.Join(cachedir, item.Name())
err = fs.RemoveAll(dir)
err = os.RemoveAll(dir)
if err != nil {
Warnf("unable to remove %v: %v\n", dir, err)
printer.E("unable to remove %v: %v", dir, err)
}
}
@@ -121,7 +126,7 @@ func runCache(opts CacheOptions, gopts GlobalOptions, args []string) error {
}
if len(dirs) == 0 {
Printf("no cache dirs found, basedir is %v\n", cachedir)
printer.S("no cache dirs found, basedir is %v", cachedir)
return nil
}
@@ -157,8 +162,8 @@ func runCache(opts CacheOptions, gopts GlobalOptions, args []string) error {
})
}
_ = tab.Write(globalOptions.stdout)
Printf("%d cache dirs in %s\n", len(dirs), cachedir)
_ = tab.Write(gopts.Term.OutputWriter())
printer.S("%d cache dirs in %s", len(dirs), cachedir)
return nil
}

View File

@@ -7,17 +7,21 @@ import (
"github.com/spf13/cobra"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/repository"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/ui"
)
var catAllowedCmds = []string{"config", "index", "snapshot", "key", "masterkey", "lock", "pack", "blob", "tree"}
var cmdCat = &cobra.Command{
Use: "cat [flags] [masterkey|config|pack ID|blob ID|snapshot ID|index ID|key ID|lock ID|tree snapshot:subfolder]",
Short: "Print internal objects to stdout",
Long: `
func newCatCommand(globalOptions *global.Options) *cobra.Command {
cmd := &cobra.Command{
Use: "cat [flags] [masterkey|config|pack ID|blob ID|snapshot ID|index ID|key ID|lock ID|tree snapshot:subfolder]",
Short: "Print internal objects to stdout",
Long: `
The "cat" command is used to print internal objects to stdout.
EXIT STATUS
@@ -29,16 +33,14 @@ Exit status is 10 if the repository does not exist.
Exit status is 11 if the repository is already locked.
Exit status is 12 if the password is incorrect.
`,
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runCat(cmd.Context(), globalOptions, args)
},
ValidArgs: catAllowedCmds,
}
func init() {
cmdRoot.AddCommand(cmdCat)
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runCat(cmd.Context(), *globalOptions, args, globalOptions.Term)
},
ValidArgs: catAllowedCmds,
}
return cmd
}
func validateCatArgs(args []string) error {
@@ -64,12 +66,14 @@ func validateCatArgs(args []string) error {
return nil
}
func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
func runCat(ctx context.Context, gopts global.Options, args []string, term ui.Terminal) error {
printer := ui.NewProgressPrinter(gopts.JSON, gopts.Verbosity, term)
if err := validateCatArgs(args); err != nil {
return err
}
ctx, repo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock)
ctx, repo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock, printer)
if err != nil {
return err
}
@@ -81,7 +85,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
if tpe != "masterkey" && tpe != "config" && tpe != "snapshot" && tpe != "tree" {
id, err = restic.ParseID(args[1])
if err != nil {
return errors.Fatalf("unable to parse ID: %v\n", err)
return errors.Fatalf("unable to parse ID: %v", err)
}
}
@@ -92,7 +96,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
return err
}
Println(string(buf))
printer.S(string(buf))
return nil
case "index":
buf, err := repo.LoadUnpacked(ctx, restic.IndexFile, id)
@@ -100,12 +104,12 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
return err
}
Println(string(buf))
printer.S(string(buf))
return nil
case "snapshot":
sn, _, err := restic.FindSnapshot(ctx, repo, repo, args[1])
sn, _, err := data.FindSnapshot(ctx, repo, repo, args[1])
if err != nil {
return errors.Fatalf("could not find snapshot: %v\n", err)
return errors.Fatalf("could not find snapshot: %v", err)
}
buf, err := json.MarshalIndent(sn, "", " ")
@@ -113,7 +117,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
return err
}
Println(string(buf))
printer.S(string(buf))
return nil
case "key":
key, err := repository.LoadKey(ctx, repo, id)
@@ -126,7 +130,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
return err
}
Println(string(buf))
printer.S(string(buf))
return nil
case "masterkey":
buf, err := json.MarshalIndent(repo.Key(), "", " ")
@@ -134,7 +138,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
return err
}
Println(string(buf))
printer.S(string(buf))
return nil
case "lock":
lock, err := restic.LoadLock(ctx, repo, id)
@@ -147,7 +151,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
return err
}
Println(string(buf))
printer.S(string(buf))
return nil
case "pack":
@@ -159,15 +163,14 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
hash := restic.Hash(buf)
if !hash.Equal(id) {
Warnf("Warning: hash of data does not match ID, want\n %v\ngot:\n %v\n", id.String(), hash.String())
printer.E("Warning: hash of data does not match ID, want\n %v\ngot:\n %v", id.String(), hash.String())
}
_, err = globalOptions.stdout.Write(buf)
_, err = term.OutputRaw().Write(buf)
return err
case "blob":
bar := newIndexProgress(gopts.Quiet, gopts.JSON)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
@@ -182,25 +185,24 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
return err
}
_, err = globalOptions.stdout.Write(buf)
_, err = term.OutputRaw().Write(buf)
return err
}
return errors.Fatal("blob not found")
case "tree":
sn, subfolder, err := restic.FindSnapshot(ctx, repo, repo, args[1])
sn, subfolder, err := data.FindSnapshot(ctx, repo, repo, args[1])
if err != nil {
return errors.Fatalf("could not find snapshot: %v\n", err)
return errors.Fatalf("could not find snapshot: %v", err)
}
bar := newIndexProgress(gopts.Quiet, gopts.JSON)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
sn.Tree, err = restic.FindTreeDirectory(ctx, repo, sn.Tree, subfolder)
sn.Tree, err = data.FindTreeDirectory(ctx, repo, sn.Tree, subfolder)
if err != nil {
return err
}
@@ -209,7 +211,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
if err != nil {
return err
}
_, err = globalOptions.stdout.Write(buf)
_, err = term.OutputRaw().Write(buf)
return err
default:

View File

@@ -2,6 +2,7 @@ package main
import (
"context"
"fmt"
"math/rand"
"os"
"strconv"
@@ -10,22 +11,25 @@ import (
"time"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/restic/restic/internal/backend/cache"
"github.com/restic/restic/internal/checker"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/fs"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/repository"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/ui"
"github.com/restic/restic/internal/ui/progress"
"github.com/restic/restic/internal/ui/termstatus"
)
var cmdCheck = &cobra.Command{
Use: "check [flags]",
Short: "Check the repository for errors",
Long: `
func newCheckCommand(globalOptions *global.Options) *cobra.Command {
var opts CheckOptions
cmd := &cobra.Command{
Use: "check [flags]",
Short: "Check the repository for errors",
Long: `
The "check" command tests the repository for errors and reports any errors it
finds. It can also be used to read all data and therefore simulate a restore.
@@ -41,16 +45,26 @@ Exit status is 10 if the repository does not exist.
Exit status is 11 if the repository is already locked.
Exit status is 12 if the password is incorrect.
`,
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
term, cancel := setupTermstatus()
defer cancel()
return runCheck(cmd.Context(), checkOptions, globalOptions, args, term)
},
PreRunE: func(_ *cobra.Command, _ []string) error {
return checkFlags(checkOptions)
},
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
finalizeSnapshotFilter(&opts.SnapshotFilter)
summary, err := runCheck(cmd.Context(), opts, *globalOptions, args, globalOptions.Term)
if globalOptions.JSON {
if err != nil && summary.NumErrors == 0 {
summary.NumErrors = 1
}
globalOptions.Term.Print(ui.ToJSONString(summary))
}
return err
},
PreRunE: func(_ *cobra.Command, _ []string) error {
return checkFlags(opts)
},
}
opts.AddFlags(cmd.Flags())
return cmd
}
// CheckOptions bundles all options for the 'check' command.
@@ -59,16 +73,12 @@ type CheckOptions struct {
ReadDataSubset string
CheckUnused bool
WithCache bool
data.SnapshotFilter
}
var checkOptions CheckOptions
func init() {
cmdRoot.AddCommand(cmdCheck)
f := cmdCheck.Flags()
f.BoolVar(&checkOptions.ReadData, "read-data", false, "read all data blobs")
f.StringVar(&checkOptions.ReadDataSubset, "read-data-subset", "", "read a `subset` of data packs, specified as 'n/t' for specific part, or either 'x%' or 'x.y%' or a size in bytes with suffixes k/K, m/M, g/G, t/T for a random subset")
func (opts *CheckOptions) AddFlags(f *pflag.FlagSet) {
f.BoolVar(&opts.ReadData, "read-data", false, "read all data blobs")
f.StringVar(&opts.ReadDataSubset, "read-data-subset", "", "read a `subset` of data packs, specified as 'n/t' for specific part, or either 'x%' or 'x.y%' or a size in bytes with suffixes k/K, m/M, g/G, t/T for a random subset")
var ignored bool
f.BoolVar(&ignored, "check-unused", false, "find unused blobs")
err := f.MarkDeprecated("check-unused", "`--check-unused` is deprecated and will be ignored")
@@ -76,7 +86,8 @@ func init() {
// MarkDeprecated only returns an error when the flag is not found
panic(err)
}
f.BoolVar(&checkOptions.WithCache, "with-cache", false, "use existing cache, only read uncached data from repository")
f.BoolVar(&opts.WithCache, "with-cache", false, "use existing cache, only read uncached data from repository")
initMultiSnapshotFilter(f, &opts.SnapshotFilter, true)
}
func checkFlags(opts CheckOptions) error {
@@ -164,7 +175,7 @@ func parsePercentage(s string) (float64, error) {
// - if the user explicitly requested --no-cache, we don't use any cache
// - if the user provides --cache-dir, we use a cache in a temporary sub-directory of the specified directory and the sub-directory is deleted after the check
// - by default, we use a cache in a temporary directory that is deleted after the check
func prepareCheckCache(opts CheckOptions, gopts *GlobalOptions, printer progress.Printer) (cleanup func()) {
func prepareCheckCache(opts CheckOptions, gopts *global.Options, printer progress.Printer) (cleanup func()) {
cleanup = func() {}
if opts.WithCache {
// use the default cache, no setup needed
@@ -185,7 +196,7 @@ func prepareCheckCache(opts CheckOptions, gopts *GlobalOptions, printer progress
// use a cache in a temporary directory
err := os.MkdirAll(cachedir, 0755)
if err != nil {
Warnf("unable to create cache directory %s, disabling cache: %v\n", cachedir, err)
printer.E("unable to create cache directory %s, disabling cache: %v", cachedir, err)
gopts.NoCache = true
return cleanup
}
@@ -202,7 +213,7 @@ func prepareCheckCache(opts CheckOptions, gopts *GlobalOptions, printer progress
printer.P("using temporary cache in %v\n", tempdir)
cleanup = func() {
err := fs.RemoveAll(tempdir)
err := os.RemoveAll(tempdir)
if err != nil {
printer.E("error removing temporary cache directory: %v\n", err)
}
@@ -211,12 +222,15 @@ func prepareCheckCache(opts CheckOptions, gopts *GlobalOptions, printer progress
return cleanup
}
func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args []string, term *termstatus.Terminal) error {
if len(args) != 0 {
return errors.Fatal("the check command expects no arguments, only options - please see `restic help check` for usage and flags")
}
func runCheck(ctx context.Context, opts CheckOptions, gopts global.Options, args []string, term ui.Terminal) (checkSummary, error) {
summary := checkSummary{MessageType: "summary"}
printer := newTerminalProgressPrinter(gopts.verbosity, term)
var printer progress.Printer
if !gopts.JSON {
printer = ui.NewProgressPrinter(gopts.JSON, gopts.Verbosity, term)
} else {
printer = newJSONErrorPrinter(term)
}
cleanup := prepareCheckCache(opts, &gopts, printer)
defer cleanup()
@@ -224,55 +238,44 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
if !gopts.NoLock {
printer.P("create exclusive lock for repository\n")
}
ctx, repo, unlock, err := openWithExclusiveLock(ctx, gopts, gopts.NoLock)
ctx, repo, unlock, err := openWithExclusiveLock(ctx, gopts, gopts.NoLock, printer)
if err != nil {
return err
return summary, err
}
defer unlock()
chkr := checker.New(repo, opts.CheckUnused)
err = chkr.LoadSnapshots(ctx)
err = chkr.LoadSnapshots(ctx, &opts.SnapshotFilter, args)
if err != nil {
return err
return summary, err
}
printer.P("load indexes\n")
bar := newIndexTerminalProgress(gopts.Quiet, gopts.JSON, term)
hints, errs := chkr.LoadIndex(ctx, bar)
hints, errs := chkr.LoadIndex(ctx, printer)
if ctx.Err() != nil {
return ctx.Err()
return summary, ctx.Err()
}
errorsFound := false
suggestIndexRebuild := false
suggestLegacyIndexRebuild := false
mixedFound := false
for _, hint := range hints {
switch hint.(type) {
case *checker.ErrDuplicatePacks:
term.Print(hint.Error())
suggestIndexRebuild = true
case *checker.ErrOldIndexFormat:
printer.E("error: %v\n", hint)
suggestLegacyIndexRebuild = true
errorsFound = true
case *checker.ErrMixedPack:
term.Print(hint.Error())
mixedFound = true
case *repository.ErrDuplicatePacks:
printer.S("%s", hint.Error())
summary.HintRepairIndex = true
case *repository.ErrMixedPack:
printer.S("%s", hint.Error())
summary.HintPrune = true
default:
printer.E("error: %v\n", hint)
errorsFound = true
}
}
if suggestIndexRebuild {
term.Print("Duplicate packs are non-critical, you can run `restic repair index' to correct this.\n")
if summary.HintRepairIndex {
printer.S("Duplicate packs are non-critical, you can run `restic repair index' to correct this.\n")
}
if suggestLegacyIndexRebuild {
printer.E("error: Found indexes using the legacy format, you must run `restic repair index' to correct this.\n")
}
if mixedFound {
term.Print("Mixed packs with tree and data blobs are non-critical, you can run `restic prune` to correct this.\n")
if summary.HintPrune {
printer.S("Mixed packs with tree and data blobs are non-critical, you can run `restic prune` to correct this.\n")
}
if len(errs) > 0 {
@@ -280,8 +283,10 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
printer.E("error: %v\n", err)
}
summary.NumErrors += len(errs)
summary.HintRepairIndex = true
printer.E("\nThe repository index is damaged and must be repaired. You must run `restic repair index' to correct this.\n\n")
return errors.Fatal("repository contains errors")
return summary, errors.Fatal("repository contains errors")
}
orphanedPacks := 0
@@ -292,7 +297,7 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
go chkr.Packs(ctx, errChan)
for err := range errChan {
var packErr *checker.PackError
var packErr *repository.PackError
if errors.As(err, &packErr) {
if packErr.Orphaned {
orphanedPacks++
@@ -302,23 +307,24 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
salvagePacks.Insert(packErr.ID)
}
errorsFound = true
summary.NumErrors++
printer.E("%v\n", err)
}
} else if err == checker.ErrLegacyLayout {
errorsFound = true
printer.E("error: repository still uses the S3 legacy layout\nYou must run `restic migrate s3legacy` to correct this.\n")
} else {
errorsFound = true
printer.E("%v\n", err)
}
}
if orphanedPacks > 0 && !errorsFound {
// hide notice if repository is damaged
printer.P("%d additional files were found in the repo, which likely contain duplicate data.\nThis is non-critical, you can run `restic prune` to correct this.\n", orphanedPacks)
if orphanedPacks > 0 {
summary.HintPrune = true
if !errorsFound {
// hide notice if repository is damaged
printer.P("%d additional files were found in the repo, which likely contain duplicate data.\nThis is non-critical, you can run `restic prune` to correct this.\n", orphanedPacks)
}
}
if ctx.Err() != nil {
return ctx.Err()
return summary, ctx.Err()
}
printer.P("check snapshots, trees and blobs\n")
@@ -328,7 +334,7 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
wg.Add(1)
go func() {
defer wg.Done()
bar := newTerminalProgressMax(!gopts.Quiet, 0, "snapshots", term)
bar := printer.NewCounter("snapshots")
defer bar.Done()
chkr.Structure(ctx, bar, errChan)
}()
@@ -338,9 +344,11 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
if e, ok := err.(*checker.TreeError); ok {
printer.E("error for tree %v:\n", e.ID.Str())
for _, treeErr := range e.Errors {
summary.NumErrors++
printer.E(" %v\n", treeErr)
}
} else {
summary.NumErrors++
printer.E("error: %v\n", err)
}
}
@@ -350,13 +358,14 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
// deadlocking in the case of errors.
wg.Wait()
if ctx.Err() != nil {
return ctx.Err()
return summary, ctx.Err()
}
// the following block only used for tests
if opts.CheckUnused {
unused, err := chkr.UnusedBlobs(ctx)
if err != nil {
return err
return summary, err
}
for _, id := range unused {
printer.P("unused blob %v\n", id)
@@ -364,16 +373,20 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
}
}
doReadData := func(packs map[restic.ID]int64) {
packCount := uint64(len(packs))
readDataFilter, err := buildPacksFilter(opts, printer, chkr.IsFiltered())
if err != nil {
return summary, err
}
p := newTerminalProgressMax(!gopts.Quiet, packCount, "packs", term)
if readDataFilter != nil {
p := printer.NewCounter("packs")
errChan := make(chan error)
go chkr.ReadPacks(ctx, packs, p, errChan)
go chkr.ReadPacks(ctx, readDataFilter, p, errChan)
for err := range errChan {
errorsFound = true
summary.NumErrors++
printer.E("%v\n", err)
if err, ok := err.(*repository.ErrPackData); ok {
salvagePacks.Insert(err.PackID)
@@ -382,70 +395,85 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
p.Done()
}
switch {
case opts.ReadData:
printer.P("read all data\n")
doReadData(selectPacksByBucket(chkr.GetPacks(), 1, 1))
case opts.ReadDataSubset != "":
var packs map[restic.ID]int64
dataSubset, err := stringToIntSlice(opts.ReadDataSubset)
if err == nil {
bucket := dataSubset[0]
totalBuckets := dataSubset[1]
packs = selectPacksByBucket(chkr.GetPacks(), bucket, totalBuckets)
packCount := uint64(len(packs))
printer.P("read group #%d of %d data packs (out of total %d packs in %d groups)\n", bucket, packCount, chkr.CountPacks(), totalBuckets)
} else if strings.HasSuffix(opts.ReadDataSubset, "%") {
percentage, err := parsePercentage(opts.ReadDataSubset)
if err == nil {
packs = selectRandomPacksByPercentage(chkr.GetPacks(), percentage)
printer.P("read %.1f%% of data packs\n", percentage)
}
} else {
repoSize := int64(0)
allPacks := chkr.GetPacks()
for _, size := range allPacks {
repoSize += size
}
if repoSize == 0 {
return errors.Fatal("Cannot read from a repository having size 0")
}
subsetSize, _ := ui.ParseBytes(opts.ReadDataSubset)
if subsetSize > repoSize {
subsetSize = repoSize
}
packs = selectRandomPacksByFileSize(chkr.GetPacks(), subsetSize, repoSize)
printer.P("read %d bytes of data packs\n", subsetSize)
}
if packs == nil {
return errors.Fatal("internal error: failed to select packs to check")
}
doReadData(packs)
}
if len(salvagePacks) > 0 {
printer.E("\nThe repository contains damaged pack files. These damaged files must be removed to repair the repository. This can be done using the following commands. Please read the troubleshooting guide at https://restic.readthedocs.io/en/stable/077_troubleshooting.html first.\n\n")
var strIDs []string
for id := range salvagePacks {
strIDs = append(strIDs, id.String())
summary.BrokenPacks = append(summary.BrokenPacks, id.String())
}
printer.E("restic repair packs %v\nrestic repair snapshots --forget\n\n", strings.Join(strIDs, " "))
printer.E("restic repair packs %v\nrestic repair snapshots --forget\n\n", strings.Join(summary.BrokenPacks, " "))
printer.E("Damaged pack files can be caused by backend problems, hardware problems or bugs in restic. Please open an issue at https://github.com/restic/restic/issues/new/choose for further troubleshooting!\n")
}
if ctx.Err() != nil {
return ctx.Err()
return summary, ctx.Err()
}
if errorsFound {
if len(salvagePacks) == 0 {
printer.E("\nThe repository is damaged and must be repaired. Please follow the troubleshooting guide at https://restic.readthedocs.io/en/stable/077_troubleshooting.html .\n\n")
}
return errors.Fatal("repository contains errors")
return summary, errors.Fatal("repository contains errors")
}
printer.P("no errors were found\n")
return summary, nil
}
return nil
func buildPacksFilter(opts CheckOptions, printer progress.Printer,
filteredStatus bool) (func(packs map[restic.ID]int64) map[restic.ID]int64, error) {
typeData := ""
if filteredStatus {
typeData = "filtered "
}
switch {
case opts.ReadData:
return func(packs map[restic.ID]int64) map[restic.ID]int64 {
printer.P("read all %sdata", typeData)
return packs
}, nil
case opts.ReadDataSubset != "":
dataSubset, err := stringToIntSlice(opts.ReadDataSubset)
if err == nil {
bucket := dataSubset[0]
totalBuckets := dataSubset[1]
return func(packs map[restic.ID]int64) map[restic.ID]int64 {
packCount := uint64(len(packs))
packs = selectPacksByBucket(packs, bucket, totalBuckets)
printer.P("read group #%d of %d %sdata packs (out of total %d packs in %d groups", bucket, len(packs), typeData, packCount, totalBuckets)
return packs
}, nil
} else if strings.HasSuffix(opts.ReadDataSubset, "%") {
percentage, err := parsePercentage(opts.ReadDataSubset)
if err != nil {
return nil, err
}
return func(packs map[restic.ID]int64) map[restic.ID]int64 {
printer.P("read %.1f%% of %spackfiles", percentage, typeData)
return selectRandomPacksByPercentage(packs, percentage)
}, nil
}
repoSize := int64(0)
return func(packs map[restic.ID]int64) map[restic.ID]int64 {
for _, size := range packs {
repoSize += size
}
subsetSize, _ := ui.ParseBytes(opts.ReadDataSubset)
if subsetSize > repoSize {
subsetSize = repoSize
}
if repoSize > 0 {
packs = selectRandomPacksByFileSize(packs, subsetSize, repoSize)
}
percentage := float64(subsetSize) / float64(repoSize) * 100.0
if repoSize == 0 {
percentage = 100
}
printer.P("read %d bytes (%.1f%%) of %sdata packs\n", subsetSize, percentage, typeData)
return packs
}, nil
}
return nil, nil
}
// selectPacksByBucket selects subsets of packs by ranges of buckets.
@@ -491,3 +519,47 @@ func selectRandomPacksByFileSize(allPacks map[restic.ID]int64, subsetSize int64,
packs := selectRandomPacksByPercentage(allPacks, subsetPercentage)
return packs
}
type checkSummary struct {
MessageType string `json:"message_type"` // "summary"
NumErrors int `json:"num_errors"`
BrokenPacks []string `json:"broken_packs"` // run "restic repair packs ID..." and "restic repair snapshots --forget" to remove damaged files
HintRepairIndex bool `json:"suggest_repair_index"` // run "restic repair index"
HintPrune bool `json:"suggest_prune"` // run "restic prune"
}
type checkError struct {
MessageType string `json:"message_type"` // "error"
Message string `json:"message"`
}
type jsonErrorPrinter struct {
term ui.Terminal
}
func newJSONErrorPrinter(term ui.Terminal) *jsonErrorPrinter {
return &jsonErrorPrinter{
term: term,
}
}
func (*jsonErrorPrinter) NewCounter(_ string) *progress.Counter {
return nil
}
func (*jsonErrorPrinter) NewCounterTerminalOnly(_ string) *progress.Counter {
return nil
}
func (p *jsonErrorPrinter) E(msg string, args ...interface{}) {
status := checkError{
MessageType: "error",
Message: fmt.Sprintf(msg, args...),
}
p.term.Error(ui.ToJSONString(status))
}
func (*jsonErrorPrinter) S(_ string, _ ...interface{}) {}
func (*jsonErrorPrinter) P(_ string, _ ...interface{}) {}
func (*jsonErrorPrinter) PT(_ string, _ ...interface{}) {}
func (*jsonErrorPrinter) V(_ string, _ ...interface{}) {}
func (*jsonErrorPrinter) VV(_ string, _ ...interface{}) {}

View File

@@ -1,38 +1,101 @@
package main
import (
"bytes"
"context"
"strings"
"testing"
"github.com/restic/restic/internal/global"
rtest "github.com/restic/restic/internal/test"
"github.com/restic/restic/internal/ui/termstatus"
)
func testRunCheck(t testing.TB, gopts GlobalOptions) {
func testRunCheck(t testing.TB, gopts global.Options) {
t.Helper()
output, err := testRunCheckOutput(gopts, true)
output, err := testRunCheckOutput(t, gopts, true)
if err != nil {
t.Error(output)
t.Fatalf("unexpected error: %+v", err)
}
}
func testRunCheckMustFail(t testing.TB, gopts GlobalOptions) {
func testRunCheckMustFail(t testing.TB, gopts global.Options) {
t.Helper()
_, err := testRunCheckOutput(gopts, false)
_, err := testRunCheckOutput(t, gopts, false)
rtest.Assert(t, err != nil, "expected non nil error after check of damaged repository")
}
func testRunCheckOutput(gopts GlobalOptions, checkUnused bool) (string, error) {
buf := bytes.NewBuffer(nil)
gopts.stdout = buf
err := withTermStatus(gopts, func(ctx context.Context, term *termstatus.Terminal) error {
func testRunCheckOutput(t testing.TB, gopts global.Options, checkUnused bool) (string, error) {
buf, err := withCaptureStdout(t, gopts, func(ctx context.Context, gopts global.Options) error {
opts := CheckOptions{
ReadData: true,
CheckUnused: checkUnused,
}
return runCheck(context.TODO(), opts, gopts, nil, term)
_, err := runCheck(context.TODO(), opts, gopts, nil, gopts.Term)
return err
})
return buf.String(), err
}
func testRunCheckOutputWithOpts(t testing.TB, gopts global.Options, opts CheckOptions, args []string) (string, error) {
buf, err := withCaptureStdout(t, gopts, func(ctx context.Context, gopts global.Options) error {
gopts.Verbosity = 2
_, err := runCheck(context.TODO(), opts, gopts, args, gopts.Term)
return err
})
return buf.String(), err
}
func TestCheckWithSnaphotFilter(t *testing.T) {
testCases := []struct {
opts CheckOptions
args []string
expectedOutput string
}{
{ // full --read-data, all snapshots
CheckOptions{ReadData: true},
nil,
"4 / 4 packs",
},
{ // full --read-data, all snapshots
CheckOptions{ReadData: true},
nil,
"2 / 2 snapshots",
},
{ // full --read-data, latest snapshot
CheckOptions{ReadData: true},
[]string{"latest"},
"2 / 2 packs",
},
{ // full --read-data, latest snapshot
CheckOptions{ReadData: true},
[]string{"latest"},
"1 / 1 snapshots",
},
{ // --read-data-subset, latest snapshot
CheckOptions{ReadDataSubset: "1%"},
[]string{"latest"},
"1 / 1 packs",
},
{ // --read-data-subset, latest snapshot
CheckOptions{ReadDataSubset: "1%"},
[]string{"latest"},
"filtered",
},
}
env, cleanup := withTestEnvironment(t)
defer cleanup()
testSetupBackupData(t, env)
opts := BackupOptions{}
testRunBackup(t, env.testdata+"/0", []string{"for_cmd_ls"}, opts, env.gopts)
testRunBackup(t, env.testdata+"/0", []string{"0/9"}, opts, env.gopts)
for _, testCase := range testCases {
output, err := testRunCheckOutputWithOpts(t, env.gopts, testCase.opts, testCase.args)
rtest.OK(t, err)
hasOutput := strings.Contains(output, testCase.expectedOutput)
rtest.Assert(t, hasOutput, `expected to find substring %q, but did not find it`, testCase.expectedOutput)
}
}

View File

@@ -9,6 +9,7 @@ import (
"testing"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/restic"
rtest "github.com/restic/restic/internal/test"
"github.com/restic/restic/internal/ui/progress"
@@ -202,7 +203,7 @@ func TestPrepareCheckCache(t *testing.T) {
err := os.Remove(tmpDirBase)
rtest.OK(t, err)
}
gopts := GlobalOptions{CacheDir: tmpDirBase}
gopts := global.Options{CacheDir: tmpDirBase}
cleanup := prepareCheckCache(testCase.opts, &gopts, &progress.NoopPrinter{})
files, err := os.ReadDir(tmpDirBase)
rtest.OK(t, err)
@@ -232,7 +233,7 @@ func TestPrepareCheckCache(t *testing.T) {
}
func TestPrepareDefaultCheckCache(t *testing.T) {
gopts := GlobalOptions{CacheDir: ""}
gopts := global.Options{CacheDir: ""}
cleanup := prepareCheckCache(CheckOptions{}, &gopts, &progress.NoopPrinter{})
_, err := os.ReadDir(gopts.CacheDir)
rtest.OK(t, err)

View File

@@ -3,20 +3,29 @@ package main
import (
"context"
"fmt"
"iter"
"sync"
"time"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/repository"
"github.com/restic/restic/internal/restic"
"golang.org/x/sync/errgroup"
"github.com/restic/restic/internal/ui"
"github.com/restic/restic/internal/ui/progress"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
var cmdCopy = &cobra.Command{
Use: "copy [flags] [snapshotID ...]",
Short: "Copy snapshots from one repository to another",
Long: `
func newCopyCommand(globalOptions *global.Options) *cobra.Command {
var opts CopyOptions
cmd := &cobra.Command{
Use: "copy [flags] [snapshotID ...]",
Short: "Copy snapshots from one repository to another",
Long: `
The "copy" command copies one or more snapshots from one repository to another.
NOTE: This process will have to both download (read) and upload (write) the
@@ -40,31 +49,65 @@ Exit status is 10 if the repository does not exist.
Exit status is 11 if the repository is already locked.
Exit status is 12 if the password is incorrect.
`,
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runCopy(cmd.Context(), copyOptions, globalOptions, args)
},
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
finalizeSnapshotFilter(&opts.SnapshotFilter)
return runCopy(cmd.Context(), opts, *globalOptions, args, globalOptions.Term)
},
}
opts.AddFlags(cmd.Flags())
return cmd
}
// CopyOptions bundles all options for the copy command.
type CopyOptions struct {
secondaryRepoOptions
restic.SnapshotFilter
global.SecondaryRepoOptions
data.SnapshotFilter
}
var copyOptions CopyOptions
func init() {
cmdRoot.AddCommand(cmdCopy)
f := cmdCopy.Flags()
initSecondaryRepoOptions(f, &copyOptions.secondaryRepoOptions, "destination", "to copy snapshots from")
initMultiSnapshotFilter(f, &copyOptions.SnapshotFilter, true)
func (opts *CopyOptions) AddFlags(f *pflag.FlagSet) {
opts.SecondaryRepoOptions.AddFlags(f, "destination", "to copy snapshots from")
initMultiSnapshotFilter(f, &opts.SnapshotFilter, true)
}
func runCopy(ctx context.Context, opts CopyOptions, gopts GlobalOptions, args []string) error {
secondaryGopts, isFromRepo, err := fillSecondaryGlobalOpts(ctx, opts.secondaryRepoOptions, gopts, "destination")
// collectAllSnapshots: select all snapshot trees to be copied
func collectAllSnapshots(ctx context.Context, opts CopyOptions,
srcSnapshotLister restic.Lister, srcRepo restic.Repository,
dstSnapshotByOriginal map[restic.ID][]*data.Snapshot, args []string, printer progress.Printer,
) iter.Seq[*data.Snapshot] {
return func(yield func(*data.Snapshot) bool) {
for sn := range FindFilteredSnapshots(ctx, srcSnapshotLister, srcRepo, &opts.SnapshotFilter, args, printer) {
// check whether the destination has a snapshot with the same persistent ID which has similar snapshot fields
srcOriginal := *sn.ID()
if sn.Original != nil {
srcOriginal = *sn.Original
}
if originalSns, ok := dstSnapshotByOriginal[srcOriginal]; ok {
isCopy := false
for _, originalSn := range originalSns {
if similarSnapshots(originalSn, sn) {
printer.V("\n%v", sn)
printer.V("skipping source snapshot %s, was already copied to snapshot %s", sn.ID().Str(), originalSn.ID().Str())
isCopy = true
break
}
}
if isCopy {
continue
}
}
if !yield(sn) {
return
}
}
}
}
func runCopy(ctx context.Context, opts CopyOptions, gopts global.Options, args []string, term ui.Terminal) error {
printer := ui.NewProgressPrinter(false, gopts.Verbosity, term)
secondaryGopts, isFromRepo, err := opts.SecondaryRepoOptions.FillGlobalOpts(ctx, gopts, "destination")
if err != nil {
return err
}
@@ -73,13 +116,13 @@ func runCopy(ctx context.Context, opts CopyOptions, gopts GlobalOptions, args []
gopts, secondaryGopts = secondaryGopts, gopts
}
ctx, srcRepo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock)
ctx, srcRepo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock, printer)
if err != nil {
return err
}
defer unlock()
ctx, dstRepo, unlock, err := openWithAppendLock(ctx, secondaryGopts, false)
ctx, dstRepo, unlock, err := openWithAppendLock(ctx, secondaryGopts, false, printer)
if err != nil {
return err
}
@@ -96,18 +139,16 @@ func runCopy(ctx context.Context, opts CopyOptions, gopts GlobalOptions, args []
}
debug.Log("Loading source index")
bar := newIndexProgress(gopts.Quiet, gopts.JSON)
if err := srcRepo.LoadIndex(ctx, bar); err != nil {
if err := srcRepo.LoadIndex(ctx, printer); err != nil {
return err
}
bar = newIndexProgress(gopts.Quiet, gopts.JSON)
debug.Log("Loading destination index")
if err := dstRepo.LoadIndex(ctx, bar); err != nil {
if err := dstRepo.LoadIndex(ctx, printer); err != nil {
return err
}
dstSnapshotByOriginal := make(map[restic.ID][]*restic.Snapshot)
for sn := range FindFilteredSnapshots(ctx, dstSnapshotLister, dstRepo, &opts.SnapshotFilter, nil) {
dstSnapshotByOriginal := make(map[restic.ID][]*data.Snapshot)
for sn := range FindFilteredSnapshots(ctx, dstSnapshotLister, dstRepo, &opts.SnapshotFilter, nil, printer) {
if sn.Original != nil && !sn.Original.IsNull() {
dstSnapshotByOriginal[*sn.Original] = append(dstSnapshotByOriginal[*sn.Original], sn)
}
@@ -118,53 +159,16 @@ func runCopy(ctx context.Context, opts CopyOptions, gopts GlobalOptions, args []
return ctx.Err()
}
// remember already processed trees across all snapshots
visitedTrees := restic.NewIDSet()
selectedSnapshots := collectAllSnapshots(ctx, opts, srcSnapshotLister, srcRepo, dstSnapshotByOriginal, args, printer)
for sn := range FindFilteredSnapshots(ctx, srcSnapshotLister, srcRepo, &opts.SnapshotFilter, args) {
// check whether the destination has a snapshot with the same persistent ID which has similar snapshot fields
srcOriginal := *sn.ID()
if sn.Original != nil {
srcOriginal = *sn.Original
}
if originalSns, ok := dstSnapshotByOriginal[srcOriginal]; ok {
isCopy := false
for _, originalSn := range originalSns {
if similarSnapshots(originalSn, sn) {
Verboseff("\n%v\n", sn)
Verboseff("skipping source snapshot %s, was already copied to snapshot %s\n", sn.ID().Str(), originalSn.ID().Str())
isCopy = true
break
}
}
if isCopy {
continue
}
}
Verbosef("\n%v\n", sn)
Verbosef(" copy started, this may take a while...\n")
if err := copyTree(ctx, srcRepo, dstRepo, visitedTrees, *sn.Tree, gopts.Quiet); err != nil {
return err
}
debug.Log("tree copied")
// save snapshot
sn.Parent = nil // Parent does not have relevance in the new repo.
// Use Original as a persistent snapshot ID
if sn.Original == nil {
sn.Original = sn.ID()
}
newID, err := restic.SaveSnapshot(ctx, dstRepo, sn)
if err != nil {
return err
}
Verbosef("snapshot %s saved\n", newID.Str())
if err := copyTreeBatched(ctx, srcRepo, dstRepo, selectedSnapshots, printer); err != nil {
return err
}
return ctx.Err()
}
func similarSnapshots(sna *restic.Snapshot, snb *restic.Snapshot) bool {
func similarSnapshots(sna *data.Snapshot, snb *data.Snapshot) bool {
// everything except Parent and Original must match
if !sna.Time.Equal(snb.Time) || !sna.Tree.Equal(*snb.Tree) || sna.Hostname != snb.Hostname ||
sna.Username != snb.Username || sna.UID != snb.UID || sna.GID != snb.GID ||
@@ -183,64 +187,158 @@ func similarSnapshots(sna *restic.Snapshot, snb *restic.Snapshot) bool {
return true
}
func copyTree(ctx context.Context, srcRepo restic.Repository, dstRepo restic.Repository,
visitedTrees restic.IDSet, rootTreeID restic.ID, quiet bool) error {
// copyTreeBatched copies multiple snapshots in one go. Snapshots are written after
// data equivalent to at least 10 packfiles was written.
func copyTreeBatched(ctx context.Context, srcRepo restic.Repository, dstRepo restic.Repository,
selectedSnapshots iter.Seq[*data.Snapshot], printer progress.Printer) error {
wg, wgCtx := errgroup.WithContext(ctx)
// remember already processed trees across all snapshots
visitedTrees := srcRepo.NewAssociatedBlobSet()
treeStream := restic.StreamTrees(wgCtx, wg, srcRepo, restic.IDs{rootTreeID}, func(treeID restic.ID) bool {
visited := visitedTrees.Has(treeID)
visitedTrees.Insert(treeID)
return visited
}, nil)
targetSize := uint64(dstRepo.PackSize()) * 100
minDuration := 1 * time.Minute
copyBlobs := restic.NewBlobSet()
packList := restic.NewIDSet()
// use pull-based iterator to allow iteration in multiple steps
next, stop := iter.Pull(selectedSnapshots)
defer stop()
enqueue := func(h restic.BlobHandle) {
pb := srcRepo.LookupBlob(h.Type, h.ID)
copyBlobs.Insert(h)
for _, p := range pb {
packList.Insert(p.PackID)
for {
var batch []*data.Snapshot
batchSize := uint64(0)
startTime := time.Now()
// call WithBlobUploader() once and then loop over all selectedSnapshots
err := dstRepo.WithBlobUploader(ctx, func(ctx context.Context, uploader restic.BlobSaverWithAsync) error {
for batchSize < targetSize || time.Since(startTime) < minDuration {
sn, ok := next()
if !ok {
break
}
batch = append(batch, sn)
printer.P("\n%v", sn)
printer.P(" copy started, this may take a while...")
sizeBlobs, err := copyTree(ctx, srcRepo, dstRepo, visitedTrees, *sn.Tree, printer, uploader)
if err != nil {
return err
}
debug.Log("tree copied")
batchSize += sizeBlobs
}
return nil
})
if err != nil {
return err
}
// if no snapshots were processed in this batch, we're done
if len(batch) == 0 {
break
}
// add a newline to separate saved snapshot messages from the other messages
if len(batch) > 1 {
printer.P("")
}
// save all the snapshots
for _, sn := range batch {
err := copySaveSnapshot(ctx, sn, dstRepo, printer)
if err != nil {
return err
}
}
}
wg.Go(func() error {
for tree := range treeStream {
if tree.Error != nil {
return fmt.Errorf("LoadTree(%v) returned error %v", tree.ID.Str(), tree.Error)
}
return nil
}
// Do we already have this tree blob?
treeHandle := restic.BlobHandle{ID: tree.ID, Type: restic.TreeBlob}
if _, ok := dstRepo.LookupBlobSize(treeHandle.Type, treeHandle.ID); !ok {
// copy raw tree bytes to avoid problems if the serialization changes
enqueue(treeHandle)
}
func copyTree(ctx context.Context, srcRepo restic.Repository, dstRepo restic.Repository,
visitedTrees restic.AssociatedBlobSet, rootTreeID restic.ID, printer progress.Printer, uploader restic.BlobSaverWithAsync) (uint64, error) {
for _, entry := range tree.Nodes {
// Recursion into directories is handled by StreamTrees
// Copy the blobs for this file.
for _, blobID := range entry.Content {
h := restic.BlobHandle{Type: restic.DataBlob, ID: blobID}
if _, ok := dstRepo.LookupBlobSize(h.Type, h.ID); !ok {
enqueue(h)
}
}
copyBlobs := srcRepo.NewAssociatedBlobSet()
packList := restic.NewIDSet()
var lock sync.Mutex
enqueue := func(h restic.BlobHandle) {
lock.Lock()
defer lock.Unlock()
if _, ok := dstRepo.LookupBlobSize(h.Type, h.ID); !ok {
pb := srcRepo.LookupBlob(h.Type, h.ID)
copyBlobs.Insert(h)
for _, p := range pb {
packList.Insert(p.PackID)
}
}
}
err := data.StreamTrees(ctx, srcRepo, restic.IDs{rootTreeID}, nil, func(treeID restic.ID) bool {
handle := restic.BlobHandle{ID: treeID, Type: restic.TreeBlob}
visited := visitedTrees.Has(handle)
visitedTrees.Insert(handle)
return visited
}, func(treeID restic.ID, err error, nodes data.TreeNodeIterator) error {
if err != nil {
return fmt.Errorf("LoadTree(%v) returned error %v", treeID.Str(), err)
}
// copy raw tree bytes to avoid problems if the serialization changes
enqueue(restic.BlobHandle{ID: treeID, Type: restic.TreeBlob})
for item := range nodes {
if item.Error != nil {
return item.Error
}
// Recursion into directories is handled by StreamTrees
// Copy the blobs for this file.
for _, blobID := range item.Node.Content {
enqueue(restic.BlobHandle{Type: restic.DataBlob, ID: blobID})
}
}
return nil
})
err := wg.Wait()
if err != nil {
return 0, err
}
sizeBlobs := copyStats(srcRepo, copyBlobs, packList, printer)
bar := printer.NewCounter("packs copied")
err = repository.CopyBlobs(ctx, srcRepo, dstRepo, uploader, packList, copyBlobs, bar, printer.P)
if err != nil {
return 0, errors.Fatalf("%s", err)
}
return sizeBlobs, nil
}
// copyStats: print statistics for the blobs to be copied
func copyStats(srcRepo restic.Repository, copyBlobs restic.AssociatedBlobSet, packList restic.IDSet, printer progress.Printer) uint64 {
// count and size
countBlobs := 0
sizeBlobs := uint64(0)
for blob := range copyBlobs.Keys() {
for _, blob := range srcRepo.LookupBlob(blob.Type, blob.ID) {
countBlobs++
sizeBlobs += uint64(blob.Length)
break
}
}
printer.V(" copy %d blobs with disk size %s in %d packfiles\n",
countBlobs, ui.FormatBytes(uint64(sizeBlobs)), len(packList))
return sizeBlobs
}
func copySaveSnapshot(ctx context.Context, sn *data.Snapshot, dstRepo restic.Repository, printer progress.Printer) error {
sn.Parent = nil // Parent does not have relevance in the new repo.
// Use Original as a persistent snapshot ID
if sn.Original == nil {
sn.Original = sn.ID()
}
newID, err := data.SaveSnapshot(ctx, dstRepo, sn)
if err != nil {
return err
}
bar := newProgressMax(!quiet, uint64(len(packList)), "packs copied")
_, err = repository.Repack(ctx, srcRepo, dstRepo, packList, copyBlobs, bar)
bar.Done()
if err != nil {
return errors.Fatal(err.Error())
}
printer.P("snapshot %s saved, copied from source snapshot %s", newID.Str(), sn.ID().Str())
return nil
}

View File

@@ -6,23 +6,28 @@ import (
"path/filepath"
"testing"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/restic"
rtest "github.com/restic/restic/internal/test"
"github.com/restic/restic/internal/ui"
)
func testRunCopy(t testing.TB, srcGopts GlobalOptions, dstGopts GlobalOptions) {
func testRunCopy(t testing.TB, srcGopts global.Options, dstGopts global.Options) {
gopts := srcGopts
gopts.Repo = dstGopts.Repo
gopts.password = dstGopts.password
gopts.Password = dstGopts.Password
gopts.InsecureNoPassword = dstGopts.InsecureNoPassword
copyOpts := CopyOptions{
secondaryRepoOptions: secondaryRepoOptions{
SecondaryRepoOptions: global.SecondaryRepoOptions{
Repo: srcGopts.Repo,
password: srcGopts.password,
Password: srcGopts.Password,
InsecureNoPassword: srcGopts.InsecureNoPassword,
},
}
rtest.OK(t, runCopy(context.TODO(), copyOpts, gopts, nil))
rtest.OK(t, withTermStatus(t, gopts, func(ctx context.Context, gopts global.Options) error {
return runCopy(context.TODO(), copyOpts, gopts, nil, gopts.Term)
}))
}
func TestCopy(t *testing.T) {
@@ -45,8 +50,8 @@ func TestCopy(t *testing.T) {
copiedSnapshotIDs := testListSnapshots(t, env2.gopts, 3)
// Check that the copies size seems reasonable
stat := dirStats(env.repo)
stat2 := dirStats(env2.repo)
stat := dirStats(t, env.repo)
stat2 := dirStats(t, env2.repo)
sizeDiff := int64(stat.size) - int64(stat2.size)
if sizeDiff < 0 {
sizeDiff = -sizeDiff
@@ -69,7 +74,7 @@ func TestCopy(t *testing.T) {
testRunRestore(t, env2.gopts, restoredir, snapshotID.String())
foundMatch := false
for cmpdir := range origRestores {
diff := directoriesContentsDiff(restoredir, cmpdir)
diff := directoriesContentsDiff(t, restoredir, cmpdir)
if diff == "" {
delete(origRestores, cmpdir)
foundMatch = true
@@ -80,6 +85,41 @@ func TestCopy(t *testing.T) {
}
rtest.Assert(t, len(origRestores) == 0, "found not copied snapshots")
// check that snapshots were properly batched while copying
_, _, countBlobs := testPackAndBlobCounts(t, env.gopts)
countTreePacksDst, countDataPacksDst, countBlobsDst := testPackAndBlobCounts(t, env2.gopts)
rtest.Equals(t, countBlobs, countBlobsDst, "expected blob count in boths repos to be equal")
rtest.Equals(t, countTreePacksDst, 1, "expected 1 tree packfile")
rtest.Equals(t, countDataPacksDst, 1, "expected 1 data packfile")
}
func testPackAndBlobCounts(t testing.TB, gopts global.Options) (countTreePacks int, countDataPacks int, countBlobs int) {
rtest.OK(t, withTermStatus(t, gopts, func(ctx context.Context, gopts global.Options) error {
printer := ui.NewProgressPrinter(gopts.JSON, gopts.Verbosity, gopts.Term)
_, repo, unlock, err := openWithReadLock(ctx, gopts, false, printer)
rtest.OK(t, err)
defer unlock()
rtest.OK(t, repo.List(context.TODO(), restic.PackFile, func(id restic.ID, size int64) error {
blobs, _, err := repo.ListPack(context.TODO(), id, size)
rtest.OK(t, err)
rtest.Assert(t, len(blobs) > 0, "a packfile should contain at least one blob")
switch blobs[0].Type {
case restic.TreeBlob:
countTreePacks++
case restic.DataBlob:
countDataPacks++
}
countBlobs += len(blobs)
return nil
}))
return nil
}))
return countTreePacks, countDataPacks, countBlobs
}
func TestCopyIncremental(t *testing.T) {
@@ -142,7 +182,7 @@ func TestCopyToEmptyPassword(t *testing.T) {
defer cleanup()
env2, cleanup2 := withTestEnvironment(t)
defer cleanup2()
env2.gopts.password = ""
env2.gopts.Password = ""
env2.gopts.InsecureNoPassword = true
testSetupBackupData(t, env)

View File

@@ -1,5 +1,4 @@
//go:build debug
// +build debug
package main
@@ -18,27 +17,44 @@ import (
"github.com/klauspost/compress/zstd"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"golang.org/x/sync/errgroup"
"github.com/restic/restic/internal/crypto"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/repository"
"github.com/restic/restic/internal/repository/index"
"github.com/restic/restic/internal/repository/pack"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/ui"
"github.com/restic/restic/internal/ui/progress"
)
var cmdDebug = &cobra.Command{
Use: "debug",
Short: "Debug commands",
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
func registerDebugCommand(cmd *cobra.Command, globalOptions *global.Options) {
cmd.AddCommand(
newDebugCommand(globalOptions),
)
}
var cmdDebugDump = &cobra.Command{
Use: "dump [indexes|snapshots|all|packs]",
Short: "Dump data structures",
Long: `
func newDebugCommand(globalOptions *global.Options) *cobra.Command {
cmd := &cobra.Command{
Use: "debug",
Short: "Debug commands",
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
}
cmd.AddCommand(newDebugDumpCommand(globalOptions))
cmd.AddCommand(newDebugExamineCommand(globalOptions))
return cmd
}
func newDebugDumpCommand(globalOptions *global.Options) *cobra.Command {
cmd := &cobra.Command{
Use: "dump [indexes|snapshots|all|packs]",
Short: "Dump data structures",
Long: `
The "dump" command dumps data structures from the repository as JSON objects. It
is used for debugging purposes only.
@@ -51,10 +67,28 @@ Exit status is 10 if the repository does not exist.
Exit status is 11 if the repository is already locked.
Exit status is 12 if the password is incorrect.
`,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runDebugDump(cmd.Context(), globalOptions, args)
},
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runDebugDump(cmd.Context(), *globalOptions, args, globalOptions.Term)
},
}
return cmd
}
func newDebugExamineCommand(globalOptions *global.Options) *cobra.Command {
var opts DebugExamineOptions
cmd := &cobra.Command{
Use: "examine pack-ID...",
Short: "Examine a pack file",
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runDebugExamine(cmd.Context(), *globalOptions, opts, args, globalOptions.Term)
},
}
opts.AddFlags(cmd.Flags())
return cmd
}
type DebugExamineOptions struct {
@@ -64,16 +98,11 @@ type DebugExamineOptions struct {
ReuploadBlobs bool
}
var debugExamineOpts DebugExamineOptions
func init() {
cmdRoot.AddCommand(cmdDebug)
cmdDebug.AddCommand(cmdDebugDump)
cmdDebug.AddCommand(cmdDebugExamine)
cmdDebugExamine.Flags().BoolVar(&debugExamineOpts.ExtractPack, "extract-pack", false, "write blobs to the current directory")
cmdDebugExamine.Flags().BoolVar(&debugExamineOpts.ReuploadBlobs, "reupload-blobs", false, "reupload blobs to the repository")
cmdDebugExamine.Flags().BoolVar(&debugExamineOpts.TryRepair, "try-repair", false, "try to repair broken blobs with single bit flips")
cmdDebugExamine.Flags().BoolVar(&debugExamineOpts.RepairByte, "repair-byte", false, "try to repair broken blobs by trying bytes")
func (opts *DebugExamineOptions) AddFlags(f *pflag.FlagSet) {
f.BoolVar(&opts.ExtractPack, "extract-pack", false, "write blobs to the current directory")
f.BoolVar(&opts.ReuploadBlobs, "reupload-blobs", false, "reupload blobs to the repository")
f.BoolVar(&opts.TryRepair, "try-repair", false, "try to repair broken blobs with single bit flips")
f.BoolVar(&opts.RepairByte, "repair-byte", false, "try to repair broken blobs by trying bytes")
}
func prettyPrintJSON(wr io.Writer, item interface{}) error {
@@ -87,12 +116,14 @@ func prettyPrintJSON(wr io.Writer, item interface{}) error {
}
func debugPrintSnapshots(ctx context.Context, repo *repository.Repository, wr io.Writer) error {
return restic.ForAllSnapshots(ctx, repo, repo, nil, func(id restic.ID, snapshot *restic.Snapshot, err error) error {
return data.ForAllSnapshots(ctx, repo, repo, nil, func(id restic.ID, snapshot *data.Snapshot, err error) error {
if err != nil {
return err
}
fmt.Fprintf(wr, "snapshot_id: %v\n", id)
if _, err := fmt.Fprintf(wr, "snapshot_id: %v\n", id); err != nil {
return err
}
return prettyPrintJSON(wr, snapshot)
})
@@ -113,13 +144,13 @@ type Blob struct {
Offset uint `json:"offset"`
}
func printPacks(ctx context.Context, repo *repository.Repository, wr io.Writer) error {
func printPacks(ctx context.Context, repo *repository.Repository, wr io.Writer, printer progress.Printer) error {
var m sync.Mutex
return restic.ParallelList(ctx, repo, restic.PackFile, repo.Connections(), func(ctx context.Context, id restic.ID, size int64) error {
blobs, _, err := repo.ListPack(ctx, id, size)
if err != nil {
Warnf("error for pack %v: %v\n", id.Str(), err)
printer.E("error for pack %v: %v", id.Str(), err)
return nil
}
@@ -142,9 +173,9 @@ func printPacks(ctx context.Context, repo *repository.Repository, wr io.Writer)
})
}
func dumpIndexes(ctx context.Context, repo restic.ListerLoaderUnpacked, wr io.Writer) error {
return index.ForAllIndexes(ctx, repo, repo, func(id restic.ID, idx *index.Index, oldFormat bool, err error) error {
Printf("index_id: %v\n", id)
func dumpIndexes(ctx context.Context, repo restic.ListerLoaderUnpacked, wr io.Writer, printer progress.Printer) error {
return index.ForAllIndexes(ctx, repo, repo, func(id restic.ID, idx *index.Index, err error) error {
printer.S("index_id: %v", id)
if err != nil {
return err
}
@@ -153,12 +184,14 @@ func dumpIndexes(ctx context.Context, repo restic.ListerLoaderUnpacked, wr io.Wr
})
}
func runDebugDump(ctx context.Context, gopts GlobalOptions, args []string) error {
func runDebugDump(ctx context.Context, gopts global.Options, args []string, term ui.Terminal) error {
printer := ui.NewProgressPrinter(false, gopts.Verbosity, term)
if len(args) != 1 {
return errors.Fatal("type not specified")
}
ctx, repo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock)
ctx, repo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock, printer)
if err != nil {
return err
}
@@ -168,20 +201,20 @@ func runDebugDump(ctx context.Context, gopts GlobalOptions, args []string) error
switch tpe {
case "indexes":
return dumpIndexes(ctx, repo, globalOptions.stdout)
return dumpIndexes(ctx, repo, gopts.Term.OutputWriter(), printer)
case "snapshots":
return debugPrintSnapshots(ctx, repo, globalOptions.stdout)
return debugPrintSnapshots(ctx, repo, gopts.Term.OutputWriter())
case "packs":
return printPacks(ctx, repo, globalOptions.stdout)
return printPacks(ctx, repo, gopts.Term.OutputWriter(), printer)
case "all":
Printf("snapshots:\n")
err := debugPrintSnapshots(ctx, repo, globalOptions.stdout)
printer.S("snapshots:")
err := debugPrintSnapshots(ctx, repo, gopts.Term.OutputWriter())
if err != nil {
return err
}
Printf("\nindexes:\n")
err = dumpIndexes(ctx, repo, globalOptions.stdout)
printer.S("indexes:")
err = dumpIndexes(ctx, repo, gopts.Term.OutputWriter(), printer)
if err != nil {
return err
}
@@ -192,20 +225,11 @@ func runDebugDump(ctx context.Context, gopts GlobalOptions, args []string) error
}
}
var cmdDebugExamine = &cobra.Command{
Use: "examine pack-ID...",
Short: "Examine a pack file",
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runDebugExamine(cmd.Context(), globalOptions, debugExamineOpts, args)
},
}
func tryRepairWithBitflip(ctx context.Context, key *crypto.Key, input []byte, bytewise bool) []byte {
func tryRepairWithBitflip(key *crypto.Key, input []byte, bytewise bool, printer progress.Printer) []byte {
if bytewise {
Printf(" trying to repair blob by finding a broken byte\n")
printer.S(" trying to repair blob by finding a broken byte")
} else {
Printf(" trying to repair blob with single bit flip\n")
printer.S(" trying to repair blob with single bit flip")
}
ch := make(chan int)
@@ -215,7 +239,7 @@ func tryRepairWithBitflip(ctx context.Context, key *crypto.Key, input []byte, by
var found bool
workers := runtime.GOMAXPROCS(0)
Printf(" spinning up %d worker functions\n", runtime.GOMAXPROCS(0))
printer.S(" spinning up %d worker functions", runtime.GOMAXPROCS(0))
for i := 0; i < workers; i++ {
wg.Go(func() error {
// make a local copy of the buffer
@@ -229,9 +253,9 @@ func tryRepairWithBitflip(ctx context.Context, key *crypto.Key, input []byte, by
nonce, plaintext := buf[:key.NonceSize()], buf[key.NonceSize():]
plaintext, err := key.Open(plaintext[:0], nonce, plaintext, nil)
if err == nil {
Printf("\n")
Printf(" blob could be repaired by XORing byte %v with 0x%02x\n", idx, pattern)
Printf(" hash is %v\n", restic.Hash(plaintext))
printer.S("")
printer.S(" blob could be repaired by XORing byte %v with 0x%02x", idx, pattern)
printer.S(" hash is %v", restic.Hash(plaintext))
close(done)
found = true
fixed = plaintext
@@ -272,7 +296,7 @@ func tryRepairWithBitflip(ctx context.Context, key *crypto.Key, input []byte, by
select {
case ch <- i:
case <-done:
Printf(" done after %v\n", time.Since(start))
printer.S(" done after %v", time.Since(start))
return nil
}
@@ -282,7 +306,7 @@ func tryRepairWithBitflip(ctx context.Context, key *crypto.Key, input []byte, by
remaining := len(input) - i
eta := time.Duration(float64(remaining)/gps) * time.Second
Printf("\r%d byte of %d done (%.2f%%), %.0f byte per second, ETA %v",
printer.S("\r%d byte of %d done (%.2f%%), %.0f byte per second, ETA %v",
i, len(input), float32(i)/float32(len(input))*100, gps, eta)
info = time.Now()
}
@@ -295,12 +319,12 @@ func tryRepairWithBitflip(ctx context.Context, key *crypto.Key, input []byte, by
}
if !found {
Printf("\n blob could not be repaired\n")
printer.S("\n blob could not be repaired")
}
return fixed
}
func decryptUnsigned(ctx context.Context, k *crypto.Key, buf []byte) []byte {
func decryptUnsigned(k *crypto.Key, buf []byte) []byte {
// strip signature at the end
l := len(buf)
nonce, ct := buf[:16], buf[16:l-16]
@@ -316,7 +340,7 @@ func decryptUnsigned(ctx context.Context, k *crypto.Key, buf []byte) []byte {
return out
}
func loadBlobs(ctx context.Context, opts DebugExamineOptions, repo restic.Repository, packID restic.ID, list []restic.Blob) error {
func loadBlobs(ctx context.Context, opts DebugExamineOptions, repo restic.Repository, packID restic.ID, list []restic.Blob, printer progress.Printer) error {
dec, err := zstd.NewReader(nil)
if err != nil {
panic(err)
@@ -328,17 +352,11 @@ func loadBlobs(ctx context.Context, opts DebugExamineOptions, repo restic.Reposi
return err
}
wg, ctx := errgroup.WithContext(ctx)
if opts.ReuploadBlobs {
repo.StartPackUploader(ctx, wg)
}
wg.Go(func() error {
err = repo.WithBlobUploader(ctx, func(ctx context.Context, uploader restic.BlobSaverWithAsync) error {
for _, blob := range list {
Printf(" loading blob %v at %v (length %v)\n", blob.ID, blob.Offset, blob.Length)
printer.S(" loading blob %v at %v (length %v)", blob.ID, blob.Offset, blob.Length)
if int(blob.Offset+blob.Length) > len(pack) {
Warnf("skipping truncated blob\n")
printer.E("skipping truncated blob")
continue
}
buf := pack[blob.Offset : blob.Offset+blob.Length]
@@ -349,16 +367,16 @@ func loadBlobs(ctx context.Context, opts DebugExamineOptions, repo restic.Reposi
outputPrefix := ""
filePrefix := ""
if err != nil {
Warnf("error decrypting blob: %v\n", err)
printer.E("error decrypting blob: %v", err)
if opts.TryRepair || opts.RepairByte {
plaintext = tryRepairWithBitflip(ctx, key, buf, opts.RepairByte)
plaintext = tryRepairWithBitflip(key, buf, opts.RepairByte, printer)
}
if plaintext != nil {
outputPrefix = "repaired "
filePrefix = "repaired-"
} else {
plaintext = decryptUnsigned(ctx, key, buf)
err = storePlainBlob(blob.ID, "damaged-", plaintext)
plaintext = decryptUnsigned(key, buf)
err = storePlainBlob(blob.ID, "damaged-", plaintext, printer)
if err != nil {
return err
}
@@ -369,7 +387,7 @@ func loadBlobs(ctx context.Context, opts DebugExamineOptions, repo restic.Reposi
if blob.IsCompressed() {
decompressed, err := dec.DecodeAll(plaintext, nil)
if err != nil {
Printf(" failed to decompress blob %v\n", blob.ID)
printer.S(" failed to decompress blob %v", blob.ID)
}
if decompressed != nil {
plaintext = decompressed
@@ -379,37 +397,32 @@ func loadBlobs(ctx context.Context, opts DebugExamineOptions, repo restic.Reposi
id := restic.Hash(plaintext)
var prefix string
if !id.Equal(blob.ID) {
Printf(" successfully %vdecrypted blob (length %v), hash is %v, ID does not match, wanted %v\n", outputPrefix, len(plaintext), id, blob.ID)
printer.S(" successfully %vdecrypted blob (length %v), hash is %v, ID does not match, wanted %v", outputPrefix, len(plaintext), id, blob.ID)
prefix = "wrong-hash-"
} else {
Printf(" successfully %vdecrypted blob (length %v), hash is %v, ID matches\n", outputPrefix, len(plaintext), id)
printer.S(" successfully %vdecrypted blob (length %v), hash is %v, ID matches", outputPrefix, len(plaintext), id)
prefix = "correct-"
}
if opts.ExtractPack {
err = storePlainBlob(id, filePrefix+prefix, plaintext)
err = storePlainBlob(id, filePrefix+prefix, plaintext, printer)
if err != nil {
return err
}
}
if opts.ReuploadBlobs {
_, _, _, err := repo.SaveBlob(ctx, blob.Type, plaintext, id, true)
_, _, _, err := uploader.SaveBlob(ctx, blob.Type, plaintext, id, true)
if err != nil {
return err
}
Printf(" uploaded %v %v\n", blob.Type, id)
printer.S(" uploaded %v %v", blob.Type, id)
}
}
if opts.ReuploadBlobs {
return repo.Flush(ctx)
}
return nil
})
return wg.Wait()
return err
}
func storePlainBlob(id restic.ID, prefix string, plain []byte) error {
func storePlainBlob(id restic.ID, prefix string, plain []byte, printer progress.Printer) error {
filename := fmt.Sprintf("%s%s.bin", prefix, id)
f, err := os.Create(filename)
if err != nil {
@@ -427,16 +440,18 @@ func storePlainBlob(id restic.ID, prefix string, plain []byte) error {
return err
}
Printf("decrypt of blob %v stored at %v\n", id, filename)
printer.S("decrypt of blob %v stored at %v", id, filename)
return nil
}
func runDebugExamine(ctx context.Context, gopts GlobalOptions, opts DebugExamineOptions, args []string) error {
func runDebugExamine(ctx context.Context, gopts global.Options, opts DebugExamineOptions, args []string, term ui.Terminal) error {
printer := ui.NewProgressPrinter(false, gopts.Verbosity, term)
if opts.ExtractPack && gopts.NoLock {
return fmt.Errorf("--extract-pack and --no-lock are mutually exclusive")
}
ctx, repo, unlock, err := openWithAppendLock(ctx, gopts, gopts.NoLock)
ctx, repo, unlock, err := openWithAppendLock(ctx, gopts, gopts.NoLock, printer)
if err != nil {
return err
}
@@ -448,7 +463,7 @@ func runDebugExamine(ctx context.Context, gopts GlobalOptions, opts DebugExamine
if err != nil {
id, err = restic.Find(ctx, repo, restic.PackFile, name)
if err != nil {
Warnf("error: %v\n", err)
printer.E("error: %v", err)
continue
}
}
@@ -459,16 +474,15 @@ func runDebugExamine(ctx context.Context, gopts GlobalOptions, opts DebugExamine
return errors.Fatal("no pack files to examine")
}
bar := newIndexProgress(gopts.Quiet, gopts.JSON)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
for _, id := range ids {
err := examinePack(ctx, opts, repo, id)
err := examinePack(ctx, opts, repo, id, printer)
if err != nil {
Warnf("error: %v\n", err)
printer.E("error: %v", err)
}
if err == context.Canceled {
break
@@ -477,24 +491,24 @@ func runDebugExamine(ctx context.Context, gopts GlobalOptions, opts DebugExamine
return nil
}
func examinePack(ctx context.Context, opts DebugExamineOptions, repo restic.Repository, id restic.ID) error {
Printf("examine %v\n", id)
func examinePack(ctx context.Context, opts DebugExamineOptions, repo restic.Repository, id restic.ID, printer progress.Printer) error {
printer.S("examine %v", id)
buf, err := repo.LoadRaw(ctx, restic.PackFile, id)
// also process damaged pack files
if buf == nil {
return err
}
Printf(" file size is %v\n", len(buf))
printer.S(" file size is %v", len(buf))
gotID := restic.Hash(buf)
if !id.Equal(gotID) {
Printf(" wanted hash %v, got %v\n", id, gotID)
printer.S(" wanted hash %v, got %v", id, gotID)
} else {
Printf(" hash for file content matches\n")
printer.S(" hash for file content matches")
}
Printf(" ========================================\n")
Printf(" looking for info in the indexes\n")
printer.S(" ========================================")
printer.S(" looking for info in the indexes")
blobsLoaded := false
// examine all data the indexes have for the pack file
@@ -504,32 +518,32 @@ func examinePack(ctx context.Context, opts DebugExamineOptions, repo restic.Repo
continue
}
checkPackSize(blobs, len(buf))
checkPackSize(blobs, len(buf), printer)
err = loadBlobs(ctx, opts, repo, id, blobs)
err = loadBlobs(ctx, opts, repo, id, blobs, printer)
if err != nil {
Warnf("error: %v\n", err)
printer.E("error: %v", err)
} else {
blobsLoaded = true
}
}
Printf(" ========================================\n")
Printf(" inspect the pack itself\n")
printer.S(" ========================================")
printer.S(" inspect the pack itself")
blobs, _, err := repo.ListPack(ctx, id, int64(len(buf)))
if err != nil {
return fmt.Errorf("pack %v: %v", id.Str(), err)
}
checkPackSize(blobs, len(buf))
checkPackSize(blobs, len(buf), printer)
if !blobsLoaded {
return loadBlobs(ctx, opts, repo, id, blobs)
return loadBlobs(ctx, opts, repo, id, blobs, printer)
}
return nil
}
func checkPackSize(blobs []restic.Blob, fileSize int) {
func checkPackSize(blobs []restic.Blob, fileSize int, printer progress.Printer) {
// track current size and offset
var size, offset uint64
@@ -538,9 +552,9 @@ func checkPackSize(blobs []restic.Blob, fileSize int) {
})
for _, pb := range blobs {
Printf(" %v blob %v, offset %-6d, raw length %-6d\n", pb.Type, pb.ID, pb.Offset, pb.Length)
printer.S(" %v blob %v, offset %-6d, raw length %-6d", pb.Type, pb.ID, pb.Offset, pb.Length)
if offset != uint64(pb.Offset) {
Printf(" hole in file, want offset %v, got %v\n", offset, pb.Offset)
printer.S(" hole in file, want offset %v, got %v", offset, pb.Offset)
}
offset = uint64(pb.Offset + pb.Length)
size += uint64(pb.Length)
@@ -548,8 +562,8 @@ func checkPackSize(blobs []restic.Blob, fileSize int) {
size += uint64(pack.CalculateHeaderSize(blobs))
if uint64(fileSize) != size {
Printf(" file sizes do not match: computed %v, file size is %v\n", size, fileSize)
printer.S(" file sizes do not match: computed %v, file size is %v", size, fileSize)
} else {
Printf(" file sizes match\n")
printer.S(" file sizes match")
}
}

View File

@@ -0,0 +1,12 @@
//go:build !debug
package main
import (
"github.com/restic/restic/internal/global"
"github.com/spf13/cobra"
)
func registerDebugCommand(_ *cobra.Command, _ *global.Options) {
// No commands to register in non-debug mode
}

View File

@@ -5,19 +5,24 @@ import (
"encoding/json"
"path"
"reflect"
"sort"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/ui"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
var cmdDiff = &cobra.Command{
Use: "diff [flags] snapshotID snapshotID",
Short: "Show differences between two snapshots",
Long: `
func newDiffCommand(globalOptions *global.Options) *cobra.Command {
var opts DiffOptions
cmd := &cobra.Command{
Use: "diff [flags] snapshotID snapshotID",
Short: "Show differences between two snapshots",
Long: `
The "diff" command shows differences from the first to the second snapshot. The
first characters in each line display what has happened to a particular file or
directory:
@@ -45,11 +50,15 @@ Exit status is 10 if the repository does not exist.
Exit status is 11 if the repository is already locked.
Exit status is 12 if the password is incorrect.
`,
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runDiff(cmd.Context(), diffOptions, globalOptions, args)
},
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runDiff(cmd.Context(), opts, *globalOptions, args, globalOptions.Term)
},
}
opts.AddFlags(cmd.Flags())
return cmd
}
// DiffOptions collects all options for the diff command.
@@ -57,19 +66,14 @@ type DiffOptions struct {
ShowMetadata bool
}
var diffOptions DiffOptions
func init() {
cmdRoot.AddCommand(cmdDiff)
f := cmdDiff.Flags()
f.BoolVar(&diffOptions.ShowMetadata, "metadata", false, "print changes in metadata")
func (opts *DiffOptions) AddFlags(f *pflag.FlagSet) {
f.BoolVar(&opts.ShowMetadata, "metadata", false, "print changes in metadata")
}
func loadSnapshot(ctx context.Context, be restic.Lister, repo restic.LoaderUnpacked, desc string) (*restic.Snapshot, string, error) {
sn, subfolder, err := restic.FindSnapshot(ctx, be, repo, desc)
func loadSnapshot(ctx context.Context, be restic.Lister, repo restic.LoaderUnpacked, desc string) (*data.Snapshot, string, error) {
sn, subfolder, err := data.FindSnapshot(ctx, be, repo, desc)
if err != nil {
return nil, "", errors.Fatal(err.Error())
return nil, "", errors.Fatalf("%s", err)
}
return sn, subfolder, err
}
@@ -79,6 +83,7 @@ type Comparer struct {
repo restic.BlobLoader
opts DiffOptions
printChange func(change *Change)
printError func(string, ...interface{})
}
type Change struct {
@@ -102,15 +107,15 @@ type DiffStat struct {
}
// Add adds stats information for node to s.
func (s *DiffStat) Add(node *restic.Node) {
func (s *DiffStat) Add(node *data.Node) {
if node == nil {
return
}
switch node.Type {
case "file":
case data.NodeTypeFile:
s.Files++
case "dir":
case data.NodeTypeDir:
s.Dirs++
default:
s.Others++
@@ -118,13 +123,13 @@ func (s *DiffStat) Add(node *restic.Node) {
}
// addBlobs adds the blobs of node to s.
func addBlobs(bs restic.BlobSet, node *restic.Node) {
func addBlobs(bs restic.AssociatedBlobSet, node *data.Node) {
if node == nil {
return
}
switch node.Type {
case "file":
case data.NodeTypeFile:
for _, blob := range node.Content {
h := restic.BlobHandle{
ID: blob,
@@ -132,7 +137,7 @@ func addBlobs(bs restic.BlobSet, node *restic.Node) {
}
bs.Insert(h)
}
case "dir":
case data.NodeTypeDir:
h := restic.BlobHandle{
ID: *node.Subtree,
Type: restic.TreeBlob,
@@ -142,18 +147,18 @@ func addBlobs(bs restic.BlobSet, node *restic.Node) {
}
type DiffStatsContainer struct {
MessageType string `json:"message_type"` // "statistics"
SourceSnapshot string `json:"source_snapshot"`
TargetSnapshot string `json:"target_snapshot"`
ChangedFiles int `json:"changed_files"`
Added DiffStat `json:"added"`
Removed DiffStat `json:"removed"`
BlobsBefore, BlobsAfter, BlobsCommon restic.BlobSet `json:"-"`
MessageType string `json:"message_type"` // "statistics"
SourceSnapshot string `json:"source_snapshot"`
TargetSnapshot string `json:"target_snapshot"`
ChangedFiles int `json:"changed_files"`
Added DiffStat `json:"added"`
Removed DiffStat `json:"removed"`
BlobsBefore, BlobsAfter, BlobsCommon restic.AssociatedBlobSet `json:"-"`
}
// updateBlobs updates the blob counters in the stats struct.
func updateBlobs(repo restic.Loader, blobs restic.BlobSet, stats *DiffStat) {
for h := range blobs {
func updateBlobs(repo restic.Loader, blobs restic.AssociatedBlobSet, stats *DiffStat, printError func(string, ...interface{})) {
for h := range blobs.Keys() {
switch h.Type {
case restic.DataBlob:
stats.DataBlobs++
@@ -163,7 +168,7 @@ func updateBlobs(repo restic.Loader, blobs restic.BlobSet, stats *DiffStat) {
size, found := repo.LookupBlobSize(h.Type, h.ID)
if !found {
Warnf("unable to find blob size for %v\n", h)
printError("unable to find blob size for %v", h)
continue
}
@@ -171,30 +176,33 @@ func updateBlobs(repo restic.Loader, blobs restic.BlobSet, stats *DiffStat) {
}
}
func (c *Comparer) printDir(ctx context.Context, mode string, stats *DiffStat, blobs restic.BlobSet, prefix string, id restic.ID) error {
func (c *Comparer) printDir(ctx context.Context, mode string, stats *DiffStat, blobs restic.AssociatedBlobSet, prefix string, id restic.ID) error {
debug.Log("print %v tree %v", mode, id)
tree, err := restic.LoadTree(ctx, c.repo, id)
tree, err := data.LoadTree(ctx, c.repo, id)
if err != nil {
return err
}
for _, node := range tree.Nodes {
for item := range tree {
if item.Error != nil {
return item.Error
}
if ctx.Err() != nil {
return ctx.Err()
}
node := item.Node
name := path.Join(prefix, node.Name)
if node.Type == "dir" {
if node.Type == data.NodeTypeDir {
name += "/"
}
c.printChange(NewChange(name, mode))
stats.Add(node)
addBlobs(blobs, node)
if node.Type == "dir" {
if node.Type == data.NodeTypeDir {
err := c.printDir(ctx, mode, stats, blobs, name, *node.Subtree)
if err != nil && err != context.Canceled {
Warnf("error: %v\n", err)
c.printError("error: %v", err)
}
}
}
@@ -202,24 +210,28 @@ func (c *Comparer) printDir(ctx context.Context, mode string, stats *DiffStat, b
return ctx.Err()
}
func (c *Comparer) collectDir(ctx context.Context, blobs restic.BlobSet, id restic.ID) error {
func (c *Comparer) collectDir(ctx context.Context, blobs restic.AssociatedBlobSet, id restic.ID) error {
debug.Log("print tree %v", id)
tree, err := restic.LoadTree(ctx, c.repo, id)
tree, err := data.LoadTree(ctx, c.repo, id)
if err != nil {
return err
}
for _, node := range tree.Nodes {
for item := range tree {
if item.Error != nil {
return item.Error
}
if ctx.Err() != nil {
return ctx.Err()
}
node := item.Node
addBlobs(blobs, node)
if node.Type == "dir" {
if node.Type == data.NodeTypeDir {
err := c.collectDir(ctx, blobs, *node.Subtree)
if err != nil && err != context.Canceled {
Warnf("error: %v\n", err)
c.printError("error: %v", err)
}
}
}
@@ -227,56 +239,41 @@ func (c *Comparer) collectDir(ctx context.Context, blobs restic.BlobSet, id rest
return ctx.Err()
}
func uniqueNodeNames(tree1, tree2 *restic.Tree) (tree1Nodes, tree2Nodes map[string]*restic.Node, uniqueNames []string) {
names := make(map[string]struct{})
tree1Nodes = make(map[string]*restic.Node)
for _, node := range tree1.Nodes {
tree1Nodes[node.Name] = node
names[node.Name] = struct{}{}
}
tree2Nodes = make(map[string]*restic.Node)
for _, node := range tree2.Nodes {
tree2Nodes[node.Name] = node
names[node.Name] = struct{}{}
}
uniqueNames = make([]string, 0, len(names))
for name := range names {
uniqueNames = append(uniqueNames, name)
}
sort.Strings(uniqueNames)
return tree1Nodes, tree2Nodes, uniqueNames
}
func (c *Comparer) diffTree(ctx context.Context, stats *DiffStatsContainer, prefix string, id1, id2 restic.ID) error {
debug.Log("diffing %v to %v", id1, id2)
tree1, err := restic.LoadTree(ctx, c.repo, id1)
tree1, err := data.LoadTree(ctx, c.repo, id1)
if err != nil {
return err
}
tree2, err := restic.LoadTree(ctx, c.repo, id2)
tree2, err := data.LoadTree(ctx, c.repo, id2)
if err != nil {
return err
}
tree1Nodes, tree2Nodes, names := uniqueNodeNames(tree1, tree2)
for _, name := range names {
for dt := range data.DualTreeIterator(tree1, tree2) {
if dt.Error != nil {
return dt.Error
}
if ctx.Err() != nil {
return ctx.Err()
}
node1, t1 := tree1Nodes[name]
node2, t2 := tree2Nodes[name]
node1 := dt.Tree1
node2 := dt.Tree2
var name string
if node1 != nil {
name = node1.Name
} else {
name = node2.Name
}
addBlobs(stats.BlobsBefore, node1)
addBlobs(stats.BlobsAfter, node2)
switch {
case t1 && t2:
case node1 != nil && node2 != nil:
name := path.Join(prefix, name)
mod := ""
@@ -284,12 +281,12 @@ func (c *Comparer) diffTree(ctx context.Context, stats *DiffStatsContainer, pref
mod += "T"
}
if node2.Type == "dir" {
if node2.Type == data.NodeTypeDir {
name += "/"
}
if node1.Type == "file" &&
node2.Type == "file" &&
if node1.Type == data.NodeTypeFile &&
node2.Type == data.NodeTypeFile &&
!reflect.DeepEqual(node1.Content, node2.Content) {
mod += "M"
stats.ChangedFiles++
@@ -311,7 +308,7 @@ func (c *Comparer) diffTree(ctx context.Context, stats *DiffStatsContainer, pref
c.printChange(NewChange(name, mod))
}
if node1.Type == "dir" && node2.Type == "dir" {
if node1.Type == data.NodeTypeDir && node2.Type == data.NodeTypeDir {
var err error
if (*node1.Subtree).Equal(*node2.Subtree) {
err = c.collectDir(ctx, stats.BlobsCommon, *node1.Subtree)
@@ -319,35 +316,35 @@ func (c *Comparer) diffTree(ctx context.Context, stats *DiffStatsContainer, pref
err = c.diffTree(ctx, stats, name, *node1.Subtree, *node2.Subtree)
}
if err != nil && err != context.Canceled {
Warnf("error: %v\n", err)
c.printError("error: %v", err)
}
}
case t1 && !t2:
case node1 != nil && node2 == nil:
prefix := path.Join(prefix, name)
if node1.Type == "dir" {
if node1.Type == data.NodeTypeDir {
prefix += "/"
}
c.printChange(NewChange(prefix, "-"))
stats.Removed.Add(node1)
if node1.Type == "dir" {
if node1.Type == data.NodeTypeDir {
err := c.printDir(ctx, "-", &stats.Removed, stats.BlobsBefore, prefix, *node1.Subtree)
if err != nil && err != context.Canceled {
Warnf("error: %v\n", err)
c.printError("error: %v", err)
}
}
case !t1 && t2:
case node1 == nil && node2 != nil:
prefix := path.Join(prefix, name)
if node2.Type == "dir" {
if node2.Type == data.NodeTypeDir {
prefix += "/"
}
c.printChange(NewChange(prefix, "+"))
stats.Added.Add(node2)
if node2.Type == "dir" {
if node2.Type == data.NodeTypeDir {
err := c.printDir(ctx, "+", &stats.Added, stats.BlobsAfter, prefix, *node2.Subtree)
if err != nil && err != context.Canceled {
Warnf("error: %v\n", err)
c.printError("error: %v", err)
}
}
}
@@ -356,12 +353,14 @@ func (c *Comparer) diffTree(ctx context.Context, stats *DiffStatsContainer, pref
return ctx.Err()
}
func runDiff(ctx context.Context, opts DiffOptions, gopts GlobalOptions, args []string) error {
func runDiff(ctx context.Context, opts DiffOptions, gopts global.Options, args []string, term ui.Terminal) error {
if len(args) != 2 {
return errors.Fatalf("specify two snapshot IDs")
}
ctx, repo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock)
printer := ui.NewProgressPrinter(gopts.JSON, gopts.Verbosity, term)
ctx, repo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock, printer)
if err != nil {
return err
}
@@ -383,10 +382,9 @@ func runDiff(ctx context.Context, opts DiffOptions, gopts GlobalOptions, args []
}
if !gopts.JSON {
Verbosef("comparing snapshot %v to %v:\n\n", sn1.ID().Str(), sn2.ID().Str())
printer.P("comparing snapshot %v to %v:\n\n", sn1.ID().Str(), sn2.ID().Str())
}
bar := newIndexProgress(gopts.Quiet, gopts.JSON)
if err = repo.LoadIndex(ctx, bar); err != nil {
if err = repo.LoadIndex(ctx, printer); err != nil {
return err
}
@@ -398,30 +396,31 @@ func runDiff(ctx context.Context, opts DiffOptions, gopts GlobalOptions, args []
return errors.Errorf("snapshot %v has nil tree", sn2.ID().Str())
}
sn1.Tree, err = restic.FindTreeDirectory(ctx, repo, sn1.Tree, subfolder1)
sn1.Tree, err = data.FindTreeDirectory(ctx, repo, sn1.Tree, subfolder1)
if err != nil {
return err
}
sn2.Tree, err = restic.FindTreeDirectory(ctx, repo, sn2.Tree, subfolder2)
sn2.Tree, err = data.FindTreeDirectory(ctx, repo, sn2.Tree, subfolder2)
if err != nil {
return err
}
c := &Comparer{
repo: repo,
opts: opts,
repo: repo,
opts: opts,
printError: printer.E,
printChange: func(change *Change) {
Printf("%-5s%v\n", change.Modifier, change.Path)
printer.S("%-5s%v", change.Modifier, change.Path)
},
}
if gopts.JSON {
enc := json.NewEncoder(globalOptions.stdout)
enc := json.NewEncoder(gopts.Term.OutputWriter())
c.printChange = func(change *Change) {
err := enc.Encode(change)
if err != nil {
Warnf("JSON encode failed: %v\n", err)
printer.E("JSON encode failed: %v", err)
}
}
}
@@ -434,9 +433,9 @@ func runDiff(ctx context.Context, opts DiffOptions, gopts GlobalOptions, args []
MessageType: "statistics",
SourceSnapshot: args[0],
TargetSnapshot: args[1],
BlobsBefore: restic.NewBlobSet(),
BlobsAfter: restic.NewBlobSet(),
BlobsCommon: restic.NewBlobSet(),
BlobsBefore: repo.NewAssociatedBlobSet(),
BlobsAfter: repo.NewAssociatedBlobSet(),
BlobsCommon: repo.NewAssociatedBlobSet(),
}
stats.BlobsBefore.Insert(restic.BlobHandle{Type: restic.TreeBlob, ID: *sn1.Tree})
stats.BlobsAfter.Insert(restic.BlobHandle{Type: restic.TreeBlob, ID: *sn2.Tree})
@@ -447,23 +446,23 @@ func runDiff(ctx context.Context, opts DiffOptions, gopts GlobalOptions, args []
}
both := stats.BlobsBefore.Intersect(stats.BlobsAfter)
updateBlobs(repo, stats.BlobsBefore.Sub(both).Sub(stats.BlobsCommon), &stats.Removed)
updateBlobs(repo, stats.BlobsAfter.Sub(both).Sub(stats.BlobsCommon), &stats.Added)
updateBlobs(repo, stats.BlobsBefore.Sub(both).Sub(stats.BlobsCommon), &stats.Removed, printer.E)
updateBlobs(repo, stats.BlobsAfter.Sub(both).Sub(stats.BlobsCommon), &stats.Added, printer.E)
if gopts.JSON {
err := json.NewEncoder(globalOptions.stdout).Encode(stats)
err := json.NewEncoder(gopts.Term.OutputWriter()).Encode(stats)
if err != nil {
Warnf("JSON encode failed: %v\n", err)
printer.E("JSON encode failed: %v", err)
}
} else {
Printf("\n")
Printf("Files: %5d new, %5d removed, %5d changed\n", stats.Added.Files, stats.Removed.Files, stats.ChangedFiles)
Printf("Dirs: %5d new, %5d removed\n", stats.Added.Dirs, stats.Removed.Dirs)
Printf("Others: %5d new, %5d removed\n", stats.Added.Others, stats.Removed.Others)
Printf("Data Blobs: %5d new, %5d removed\n", stats.Added.DataBlobs, stats.Removed.DataBlobs)
Printf("Tree Blobs: %5d new, %5d removed\n", stats.Added.TreeBlobs, stats.Removed.TreeBlobs)
Printf(" Added: %-5s\n", ui.FormatBytes(uint64(stats.Added.Bytes)))
Printf(" Removed: %-5s\n", ui.FormatBytes(uint64(stats.Removed.Bytes)))
printer.S("")
printer.S("Files: %5d new, %5d removed, %5d changed", stats.Added.Files, stats.Removed.Files, stats.ChangedFiles)
printer.S("Dirs: %5d new, %5d removed", stats.Added.Dirs, stats.Removed.Dirs)
printer.S("Others: %5d new, %5d removed", stats.Added.Others, stats.Removed.Others)
printer.S("Data Blobs: %5d new, %5d removed", stats.Added.DataBlobs, stats.Removed.DataBlobs)
printer.S("Tree Blobs: %5d new, %5d removed", stats.Added.TreeBlobs, stats.Removed.TreeBlobs)
printer.S(" Added: %-5s", ui.FormatBytes(stats.Added.Bytes))
printer.S(" Removed: %-5s", ui.FormatBytes(stats.Removed.Bytes))
}
return nil

View File

@@ -11,15 +11,16 @@ import (
"strings"
"testing"
"github.com/restic/restic/internal/global"
rtest "github.com/restic/restic/internal/test"
)
func testRunDiffOutput(gopts GlobalOptions, firstSnapshotID string, secondSnapshotID string) (string, error) {
buf, err := withCaptureStdout(func() error {
func testRunDiffOutput(t testing.TB, gopts global.Options, firstSnapshotID string, secondSnapshotID string) (string, error) {
buf, err := withCaptureStdout(t, gopts, func(ctx context.Context, gopts global.Options) error {
opts := DiffOptions{
ShowMetadata: false,
}
return runDiff(context.TODO(), opts, gopts, []string{firstSnapshotID, secondSnapshotID})
return runDiff(ctx, opts, gopts, []string{firstSnapshotID, secondSnapshotID}, gopts.Term)
})
return buf.String(), err
}
@@ -123,10 +124,10 @@ func TestDiff(t *testing.T) {
// quiet suppresses the diff output except for the summary
env.gopts.Quiet = false
_, err := testRunDiffOutput(env.gopts, "", secondSnapshotID)
_, err := testRunDiffOutput(t, env.gopts, "", secondSnapshotID)
rtest.Assert(t, err != nil, "expected error on invalid snapshot id")
out, err := testRunDiffOutput(env.gopts, firstSnapshotID, secondSnapshotID)
out, err := testRunDiffOutput(t, env.gopts, firstSnapshotID, secondSnapshotID)
rtest.OK(t, err)
for _, pattern := range diffOutputRegexPatterns {
@@ -137,7 +138,7 @@ func TestDiff(t *testing.T) {
// check quiet output
env.gopts.Quiet = true
outQuiet, err := testRunDiffOutput(env.gopts, firstSnapshotID, secondSnapshotID)
outQuiet, err := testRunDiffOutput(t, env.gopts, firstSnapshotID, secondSnapshotID)
rtest.OK(t, err)
rtest.Assert(t, len(outQuiet) < len(out), "expected shorter output on quiet mode %v vs. %v", len(outQuiet), len(out))
@@ -154,7 +155,7 @@ func TestDiffJSON(t *testing.T) {
// quiet suppresses the diff output except for the summary
env.gopts.Quiet = false
env.gopts.JSON = true
out, err := testRunDiffOutput(env.gopts, firstSnapshotID, secondSnapshotID)
out, err := testRunDiffOutput(t, env.gopts, firstSnapshotID, secondSnapshotID)
rtest.OK(t, err)
var stat DiffStatsContainer
@@ -181,7 +182,7 @@ func TestDiffJSON(t *testing.T) {
// check quiet output
env.gopts.Quiet = true
outQuiet, err := testRunDiffOutput(env.gopts, firstSnapshotID, secondSnapshotID)
outQuiet, err := testRunDiffOutput(t, env.gopts, firstSnapshotID, secondSnapshotID)
rtest.OK(t, err)
stat = DiffStatsContainer{}

View File

@@ -7,18 +7,24 @@ import (
"path"
"path/filepath"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/dump"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/ui"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
var cmdDump = &cobra.Command{
Use: "dump [flags] snapshotID file",
Short: "Print a backed-up file to stdout",
Long: `
func newDumpCommand(globalOptions *global.Options) *cobra.Command {
var opts DumpOptions
cmd := &cobra.Command{
Use: "dump [flags] snapshotID file",
Short: "Print a backed-up file to stdout",
Long: `
The "dump" command extracts files from a snapshot from the repository. If a
single file is selected, it prints its contents to stdout. Folders are output
as a tar (default) or zip file containing the contents of the specified folder.
@@ -40,29 +46,29 @@ Exit status is 10 if the repository does not exist.
Exit status is 11 if the repository is already locked.
Exit status is 12 if the password is incorrect.
`,
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runDump(cmd.Context(), dumpOptions, globalOptions, args)
},
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
finalizeSnapshotFilter(&opts.SnapshotFilter)
return runDump(cmd.Context(), opts, *globalOptions, args, globalOptions.Term)
},
}
opts.AddFlags(cmd.Flags())
return cmd
}
// DumpOptions collects all options for the dump command.
type DumpOptions struct {
restic.SnapshotFilter
data.SnapshotFilter
Archive string
Target string
}
var dumpOptions DumpOptions
func init() {
cmdRoot.AddCommand(cmdDump)
flags := cmdDump.Flags()
initSingleSnapshotFilter(flags, &dumpOptions.SnapshotFilter)
flags.StringVarP(&dumpOptions.Archive, "archive", "a", "tar", "set archive `format` as \"tar\" or \"zip\"")
flags.StringVarP(&dumpOptions.Target, "target", "t", "", "write the output to target `path`")
func (opts *DumpOptions) AddFlags(f *pflag.FlagSet) {
initSingleSnapshotFilter(f, &opts.SnapshotFilter)
f.StringVarP(&opts.Archive, "archive", "a", "tar", "set archive `format` as \"tar\" or \"zip\"")
f.StringVarP(&opts.Target, "target", "t", "", "write the output to target `path`")
}
func splitPath(p string) []string {
@@ -74,7 +80,7 @@ func splitPath(p string) []string {
return append(s, f)
}
func printFromTree(ctx context.Context, tree *restic.Tree, repo restic.BlobLoader, prefix string, pathComponents []string, d *dump.Dumper, canWriteArchiveFunc func() error) error {
func printFromTree(ctx context.Context, tree data.TreeNodeIterator, repo restic.BlobLoader, prefix string, pathComponents []string, d *dump.Dumper, canWriteArchiveFunc func() error) error {
// If we print / we need to assume that there are multiple nodes at that
// level in the tree.
if pathComponents[0] == "" {
@@ -86,35 +92,38 @@ func printFromTree(ctx context.Context, tree *restic.Tree, repo restic.BlobLoade
item := filepath.Join(prefix, pathComponents[0])
l := len(pathComponents)
for _, node := range tree.Nodes {
for it := range tree {
if it.Error != nil {
return it.Error
}
if ctx.Err() != nil {
return ctx.Err()
}
node := it.Node
// If dumping something in the highest level it will just take the
// first item it finds and dump that according to the switch case below.
if node.Name == pathComponents[0] {
switch {
case l == 1 && dump.IsFile(node):
case l == 1 && node.Type == data.NodeTypeFile:
return d.WriteNode(ctx, node)
case l > 1 && dump.IsDir(node):
subtree, err := restic.LoadTree(ctx, repo, *node.Subtree)
case l > 1 && node.Type == data.NodeTypeDir:
subtree, err := data.LoadTree(ctx, repo, *node.Subtree)
if err != nil {
return errors.Wrapf(err, "cannot load subtree for %q", item)
}
return printFromTree(ctx, subtree, repo, item, pathComponents[1:], d, canWriteArchiveFunc)
case dump.IsDir(node):
case node.Type == data.NodeTypeDir:
if err := canWriteArchiveFunc(); err != nil {
return err
}
subtree, err := restic.LoadTree(ctx, repo, *node.Subtree)
subtree, err := data.LoadTree(ctx, repo, *node.Subtree)
if err != nil {
return err
}
return d.DumpTree(ctx, subtree, item)
case l > 1:
return fmt.Errorf("%q should be a dir, but is a %q", item, node.Type)
case !dump.IsFile(node):
case node.Type != data.NodeTypeFile:
return fmt.Errorf("%q should be a file, but is a %q", item, node.Type)
}
}
@@ -122,11 +131,13 @@ func printFromTree(ctx context.Context, tree *restic.Tree, repo restic.BlobLoade
return fmt.Errorf("path %q not found in snapshot", item)
}
func runDump(ctx context.Context, opts DumpOptions, gopts GlobalOptions, args []string) error {
func runDump(ctx context.Context, opts DumpOptions, gopts global.Options, args []string, term ui.Terminal) error {
if len(args) != 2 {
return errors.Fatal("no file and no snapshot ID specified")
}
printer := ui.NewProgressPrinter(gopts.JSON, gopts.Verbosity, term)
switch opts.Archive {
case "tar", "zip":
default:
@@ -140,39 +151,34 @@ func runDump(ctx context.Context, opts DumpOptions, gopts GlobalOptions, args []
splittedPath := splitPath(path.Clean(pathToPrint))
ctx, repo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock)
ctx, repo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock, printer)
if err != nil {
return err
}
defer unlock()
sn, subfolder, err := (&restic.SnapshotFilter{
Hosts: opts.Hosts,
Paths: opts.Paths,
Tags: opts.Tags,
}).FindLatest(ctx, repo, repo, snapshotIDString)
sn, subfolder, err := opts.SnapshotFilter.FindLatest(ctx, repo, repo, snapshotIDString)
if err != nil {
return errors.Fatalf("failed to find snapshot: %v", err)
}
bar := newIndexProgress(gopts.Quiet, gopts.JSON)
err = repo.LoadIndex(ctx, bar)
err = repo.LoadIndex(ctx, printer)
if err != nil {
return err
}
sn.Tree, err = restic.FindTreeDirectory(ctx, repo, sn.Tree, subfolder)
sn.Tree, err = data.FindTreeDirectory(ctx, repo, sn.Tree, subfolder)
if err != nil {
return err
}
tree, err := restic.LoadTree(ctx, repo, *sn.Tree)
tree, err := data.LoadTree(ctx, repo, *sn.Tree)
if err != nil {
return errors.Fatalf("loading tree for snapshot %q failed: %v", snapshotIDString, err)
}
outputFileWriter := os.Stdout
canWriteArchiveFunc := checkStdoutArchive
outputFileWriter := term.OutputRaw()
canWriteArchiveFunc := checkStdoutArchive(term)
if opts.Target != "" {
file, err := os.Create(opts.Target)
@@ -196,9 +202,9 @@ func runDump(ctx context.Context, opts DumpOptions, gopts GlobalOptions, args []
return nil
}
func checkStdoutArchive() error {
if stdoutIsTerminal() {
return fmt.Errorf("stdout is the terminal, please redirect output")
func checkStdoutArchive(term ui.Terminal) func() error {
if term.OutputIsTerminal() {
return func() error { return fmt.Errorf("stdout is the terminal, please redirect output") }
}
return nil
return func() error { return nil }
}

View File

@@ -1,19 +1,19 @@
package main
import (
"fmt"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/feature"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/ui/table"
"github.com/spf13/cobra"
)
var featuresCmd = &cobra.Command{
Use: "features",
Short: "Print list of feature flags",
Long: `
func newFeaturesCommand(globalOptions *global.Options) *cobra.Command {
cmd := &cobra.Command{
Use: "features",
Short: "Print list of feature flags",
Long: `
The "features" command prints a list of supported feature flags.
To pass feature flags to restic, set the RESTIC_FEATURES environment variable
@@ -31,29 +31,28 @@ EXIT STATUS
Exit status is 0 if the command was successful.
Exit status is 1 if there was any error.
`,
GroupID: cmdGroupAdvanced,
DisableAutoGenTag: true,
RunE: func(_ *cobra.Command, args []string) error {
if len(args) != 0 {
return errors.Fatal("the feature command expects no arguments")
}
GroupID: cmdGroupAdvanced,
DisableAutoGenTag: true,
RunE: func(_ *cobra.Command, args []string) error {
if len(args) != 0 {
return errors.Fatal("the feature command expects no arguments")
}
fmt.Printf("All Feature Flags:\n")
flags := feature.Flag.List()
globalOptions.Term.Print("All Feature Flags:\n")
flags := feature.Flag.List()
tab := table.New()
tab.AddColumn("Name", "{{ .Name }}")
tab.AddColumn("Type", "{{ .Type }}")
tab.AddColumn("Default", "{{ .Default }}")
tab.AddColumn("Description", "{{ .Description }}")
tab := table.New()
tab.AddColumn("Name", "{{ .Name }}")
tab.AddColumn("Type", "{{ .Type }}")
tab.AddColumn("Default", "{{ .Default }}")
tab.AddColumn("Description", "{{ .Description }}")
for _, flag := range flags {
tab.AddRow(flag)
}
return tab.Write(globalOptions.stdout)
},
}
func init() {
cmdRoot.AddCommand(featuresCmd)
for _, flag := range flags {
tab.AddRow(flag)
}
return tab.Write(globalOptions.Term.OutputWriter())
},
}
return cmd
}

View File

@@ -3,27 +3,38 @@ package main
import (
"context"
"encoding/json"
"fmt"
"io"
"sort"
"strings"
"time"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/filter"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/ui"
"github.com/restic/restic/internal/walker"
)
var cmdFind = &cobra.Command{
Use: "find [flags] PATTERN...",
Short: "Find a file, a directory or restic IDs",
Long: `
func newFindCommand(globalOptions *global.Options) *cobra.Command {
var opts FindOptions
cmd := &cobra.Command{
Use: "find [flags] PATTERN...",
Short: "Find a file, a directory or restic IDs",
Long: `
The "find" command searches for files or directories in snapshots stored in the
repo.
It can also be used to search for restic blobs or trees for troubleshooting.`,
Example: `restic find config.json
It can also be used to search for restic blobs or trees for troubleshooting.
The default sort option for the snapshots is youngest to oldest. To sort the
output from oldest to youngest specify --reverse.`,
Example: `restic find config.json
restic find --json "*.yml" "*.json"
restic find --json --blob 420f620f b46ebe8a ddd38656
restic find --show-pack-id --blob 420f620f
@@ -39,11 +50,16 @@ Exit status is 10 if the repository does not exist.
Exit status is 11 if the repository is already locked.
Exit status is 12 if the password is incorrect.
`,
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runFind(cmd.Context(), findOptions, globalOptions, args)
},
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
finalizeSnapshotFilter(&opts.SnapshotFilter)
return runFind(cmd.Context(), opts, *globalOptions, args, globalOptions.Term)
},
}
opts.AddFlags(cmd.Flags())
return cmd
}
// FindOptions bundles all options for the find command.
@@ -56,27 +72,24 @@ type FindOptions struct {
CaseInsensitive bool
ListLong bool
HumanReadable bool
restic.SnapshotFilter
Reverse bool
data.SnapshotFilter
}
var findOptions FindOptions
func (opts *FindOptions) AddFlags(f *pflag.FlagSet) {
f.StringVarP(&opts.Oldest, "oldest", "O", "", "oldest modification date/time")
f.StringVarP(&opts.Newest, "newest", "N", "", "newest modification date/time")
f.StringArrayVarP(&opts.Snapshots, "snapshot", "s", nil, "snapshot `id` to search in (can be given multiple times)")
f.BoolVar(&opts.BlobID, "blob", false, "pattern is a blob-ID")
f.BoolVar(&opts.TreeID, "tree", false, "pattern is a tree-ID")
f.BoolVar(&opts.PackID, "pack", false, "pattern is a pack-ID")
f.BoolVar(&opts.ShowPackID, "show-pack-id", false, "display the pack-ID the blobs belong to (with --blob or --tree)")
f.BoolVarP(&opts.CaseInsensitive, "ignore-case", "i", false, "ignore case for pattern")
f.BoolVarP(&opts.Reverse, "reverse", "R", false, "reverse sort order oldest to newest")
f.BoolVarP(&opts.ListLong, "long", "l", false, "use a long listing format showing size and mode")
f.BoolVar(&opts.HumanReadable, "human-readable", false, "print sizes in human readable format")
func init() {
cmdRoot.AddCommand(cmdFind)
f := cmdFind.Flags()
f.StringVarP(&findOptions.Oldest, "oldest", "O", "", "oldest modification date/time")
f.StringVarP(&findOptions.Newest, "newest", "N", "", "newest modification date/time")
f.StringArrayVarP(&findOptions.Snapshots, "snapshot", "s", nil, "snapshot `id` to search in (can be given multiple times)")
f.BoolVar(&findOptions.BlobID, "blob", false, "pattern is a blob-ID")
f.BoolVar(&findOptions.TreeID, "tree", false, "pattern is a tree-ID")
f.BoolVar(&findOptions.PackID, "pack", false, "pattern is a pack-ID")
f.BoolVar(&findOptions.ShowPackID, "show-pack-id", false, "display the pack-ID the blobs belong to (with --blob or --tree)")
f.BoolVarP(&findOptions.CaseInsensitive, "ignore-case", "i", false, "ignore case for pattern")
f.BoolVarP(&findOptions.ListLong, "long", "l", false, "use a long listing format showing size and mode")
f.BoolVar(&findOptions.HumanReadable, "human-readable", false, "print sizes in human readable format")
initMultiSnapshotFilter(f, &findOptions.SnapshotFilter, true)
initMultiSnapshotFilter(f, &opts.SnapshotFilter, true)
}
type findPattern struct {
@@ -114,13 +127,19 @@ type statefulOutput struct {
HumanReadable bool
JSON bool
inuse bool
newsn *restic.Snapshot
oldsn *restic.Snapshot
newsn *data.Snapshot
oldsn *data.Snapshot
hits int
printer interface {
S(string, ...interface{})
P(string, ...interface{})
E(string, ...interface{})
}
stdout io.Writer
}
func (s *statefulOutput) PrintPatternJSON(path string, node *restic.Node) {
type findNode restic.Node
func (s *statefulOutput) PrintPatternJSON(path string, node *data.Node) {
type findNode data.Node
b, err := json.Marshal(struct {
// Add these attributes
Path string `json:"path,omitempty"`
@@ -141,40 +160,40 @@ func (s *statefulOutput) PrintPatternJSON(path string, node *restic.Node) {
findNode: (*findNode)(node),
})
if err != nil {
Warnf("Marshall failed: %v\n", err)
s.printer.E("Marshall failed: %v", err)
return
}
if !s.inuse {
Printf("[")
_, _ = s.stdout.Write([]byte("["))
s.inuse = true
}
if s.newsn != s.oldsn {
if s.oldsn != nil {
Printf("],\"hits\":%d,\"snapshot\":%q},", s.hits, s.oldsn.ID())
_, _ = fmt.Fprintf(s.stdout, "],\"hits\":%d,\"snapshot\":%q},", s.hits, s.oldsn.ID())
}
Printf(`{"matches":[`)
_, _ = s.stdout.Write([]byte(`{"matches":[`))
s.oldsn = s.newsn
s.hits = 0
}
if s.hits > 0 {
Printf(",")
_, _ = s.stdout.Write([]byte(","))
}
Print(string(b))
_, _ = s.stdout.Write(b)
s.hits++
}
func (s *statefulOutput) PrintPatternNormal(path string, node *restic.Node) {
func (s *statefulOutput) PrintPatternNormal(path string, node *data.Node) {
if s.newsn != s.oldsn {
if s.oldsn != nil {
Verbosef("\n")
s.printer.P("")
}
s.oldsn = s.newsn
Verbosef("Found matching entries in snapshot %s from %s\n", s.oldsn.ID().Str(), s.oldsn.Time.Local().Format(TimeFormat))
s.printer.P("Found matching entries in snapshot %s from %s", s.oldsn.ID().Str(), s.oldsn.Time.Local().Format(global.TimeFormat))
}
Println(formatNode(path, node, s.ListLong, s.HumanReadable))
s.printer.S(formatNode(path, node, s.ListLong, s.HumanReadable))
}
func (s *statefulOutput) PrintPattern(path string, node *restic.Node) {
func (s *statefulOutput) PrintPattern(path string, node *data.Node) {
if s.JSON {
s.PrintPatternJSON(path, node)
} else {
@@ -182,7 +201,7 @@ func (s *statefulOutput) PrintPattern(path string, node *restic.Node) {
}
}
func (s *statefulOutput) PrintObjectJSON(kind, id, nodepath, treeID string, sn *restic.Snapshot) {
func (s *statefulOutput) PrintObjectJSON(kind, id, nodepath, treeID string, sn *data.Snapshot) {
b, err := json.Marshal(struct {
// Add these attributes
ObjectType string `json:"object_type"`
@@ -200,32 +219,32 @@ func (s *statefulOutput) PrintObjectJSON(kind, id, nodepath, treeID string, sn *
Time: sn.Time,
})
if err != nil {
Warnf("Marshall failed: %v\n", err)
s.printer.E("Marshall failed: %v", err)
return
}
if !s.inuse {
Printf("[")
_, _ = s.stdout.Write([]byte("["))
s.inuse = true
}
if s.hits > 0 {
Printf(",")
_, _ = s.stdout.Write([]byte(","))
}
Print(string(b))
_, _ = s.stdout.Write(b)
s.hits++
}
func (s *statefulOutput) PrintObjectNormal(kind, id, nodepath, treeID string, sn *restic.Snapshot) {
Printf("Found %s %s\n", kind, id)
func (s *statefulOutput) PrintObjectNormal(kind, id, nodepath, treeID string, sn *data.Snapshot) {
s.printer.S("Found %s %s", kind, id)
if kind == "blob" {
Printf(" ... in file %s\n", nodepath)
Printf(" (tree %s)\n", treeID)
s.printer.S(" ... in file %s", nodepath)
s.printer.S(" (tree %s)", treeID)
} else {
Printf(" ... path %s\n", nodepath)
s.printer.S(" ... path %s", nodepath)
}
Printf(" ... in snapshot %s (%s)\n", sn.ID().Str(), sn.Time.Local().Format(TimeFormat))
s.printer.S(" ... in snapshot %s (%s)", sn.ID().Str(), sn.Time.Local().Format(global.TimeFormat))
}
func (s *statefulOutput) PrintObject(kind, id, nodepath, treeID string, sn *restic.Snapshot) {
func (s *statefulOutput) PrintObject(kind, id, nodepath, treeID string, sn *data.Snapshot) {
if s.JSON {
s.PrintObjectJSON(kind, id, nodepath, treeID, sn)
} else {
@@ -237,12 +256,12 @@ func (s *statefulOutput) Finish() {
if s.JSON {
// do some finishing up
if s.oldsn != nil {
Printf("],\"hits\":%d,\"snapshot\":%q}", s.hits, s.oldsn.ID())
_, _ = fmt.Fprintf(s.stdout, "],\"hits\":%d,\"snapshot\":%q}", s.hits, s.oldsn.ID())
}
if s.inuse {
Printf("]\n")
_, _ = s.stdout.Write([]byte("]\n"))
} else {
Printf("[]\n")
_, _ = s.stdout.Write([]byte("[]\n"))
}
return
}
@@ -256,9 +275,14 @@ type Finder struct {
blobIDs map[string]struct{}
treeIDs map[string]struct{}
itemsFound int
printer interface {
S(string, ...interface{})
P(string, ...interface{})
E(string, ...interface{})
}
}
func (f *Finder) findInSnapshot(ctx context.Context, sn *restic.Snapshot) error {
func (f *Finder) findInSnapshot(ctx context.Context, sn *data.Snapshot) error {
debug.Log("searching in snapshot %s\n for entries within [%s %s]", sn.ID(), f.pat.oldest, f.pat.newest)
if sn.Tree == nil {
@@ -266,11 +290,12 @@ func (f *Finder) findInSnapshot(ctx context.Context, sn *restic.Snapshot) error
}
f.out.newsn = sn
return walker.Walk(ctx, f.repo, *sn.Tree, walker.WalkVisitor{ProcessNode: func(parentTreeID restic.ID, nodepath string, node *restic.Node, err error) error {
return walker.Walk(ctx, f.repo, *sn.Tree, walker.WalkVisitor{ProcessNode: func(parentTreeID restic.ID, nodepath string, node *data.Node, err error) error {
if err != nil {
debug.Log("Error loading tree %v: %v", parentTreeID, err)
Printf("Unable to load tree %s\n ... which belongs to snapshot %s\n", parentTreeID, sn.ID())
f.printer.S("Unable to load tree %s", parentTreeID)
f.printer.S(" ... which belongs to snapshot %s", sn.ID())
return walker.ErrSkipNode
}
@@ -298,7 +323,7 @@ func (f *Finder) findInSnapshot(ctx context.Context, sn *restic.Snapshot) error
}
var errIfNoMatch error
if node.Type == "dir" {
if node.Type == data.NodeTypeDir {
var childMayMatch bool
for _, pat := range f.pat.pattern {
mayMatch, err := filter.ChildMatch(pat, normalizedNodepath)
@@ -336,7 +361,27 @@ func (f *Finder) findInSnapshot(ctx context.Context, sn *restic.Snapshot) error
}})
}
func (f *Finder) findIDs(ctx context.Context, sn *restic.Snapshot) error {
func (f *Finder) findTree(treeID restic.ID, nodepath string) error {
found := false
if _, ok := f.treeIDs[treeID.String()]; ok {
found = true
} else if _, ok := f.treeIDs[treeID.Str()]; ok {
found = true
}
if found {
f.out.PrintObject("tree", treeID.String(), nodepath, "", f.out.newsn)
f.itemsFound++
// Terminate if we have found all trees (and we are not
// looking for blobs)
if f.itemsFound >= len(f.treeIDs) && f.blobIDs == nil {
// Return an error to terminate the Walk
return errors.New("OK")
}
}
return nil
}
func (f *Finder) findIDs(ctx context.Context, sn *data.Snapshot) error {
debug.Log("searching IDs in snapshot %s", sn.ID())
if sn.Tree == nil {
@@ -344,40 +389,32 @@ func (f *Finder) findIDs(ctx context.Context, sn *restic.Snapshot) error {
}
f.out.newsn = sn
return walker.Walk(ctx, f.repo, *sn.Tree, walker.WalkVisitor{ProcessNode: func(parentTreeID restic.ID, nodepath string, node *restic.Node, err error) error {
return walker.Walk(ctx, f.repo, *sn.Tree, walker.WalkVisitor{ProcessNode: func(parentTreeID restic.ID, nodepath string, node *data.Node, err error) error {
if err != nil {
debug.Log("Error loading tree %v: %v", parentTreeID, err)
Printf("Unable to load tree %s\n ... which belongs to snapshot %s\n", parentTreeID, sn.ID())
f.printer.S("Unable to load tree %s", parentTreeID)
f.printer.S(" ... which belongs to snapshot %s", sn.ID())
return walker.ErrSkipNode
}
if node == nil {
if nodepath == "/" {
if err := f.findTree(parentTreeID, "/"); err != nil {
return err
}
}
return nil
}
if node.Type == "dir" && f.treeIDs != nil {
treeID := node.Subtree
found := false
if _, ok := f.treeIDs[treeID.Str()]; ok {
found = true
} else if _, ok := f.treeIDs[treeID.String()]; ok {
found = true
}
if found {
f.out.PrintObject("tree", treeID.String(), nodepath, "", sn)
f.itemsFound++
// Terminate if we have found all trees (and we are not
// looking for blobs)
if f.itemsFound >= len(f.treeIDs) && f.blobIDs == nil {
// Return an error to terminate the Walk
return errors.New("OK")
}
if err := f.findTree(*node.Subtree, nodepath); err != nil {
return err
}
}
if node.Type == "file" && f.blobIDs != nil {
if node.Type == data.NodeTypeFile && f.blobIDs != nil {
for _, id := range node.Content {
if ctx.Err() != nil {
return ctx.Err()
@@ -506,7 +543,7 @@ func (f *Finder) indexPacksToBlobs(ctx context.Context, packIDs map[string]struc
for h := range indexPackIDs {
list = append(list, h)
}
Warnf("some pack files are missing from the repository, getting their blobs from the repository index: %v\n\n", list)
f.printer.E("some pack files are missing from the repository, getting their blobs from the repository index: %v\n\n", list)
}
return packIDs, nil
}
@@ -514,19 +551,20 @@ func (f *Finder) indexPacksToBlobs(ctx context.Context, packIDs map[string]struc
func (f *Finder) findObjectPack(id string, t restic.BlobType) {
rid, err := restic.ParseID(id)
if err != nil {
Printf("Note: cannot find pack for object '%s', unable to parse ID: %v\n", id, err)
f.printer.S("Note: cannot find pack for object '%s', unable to parse ID: %v", id, err)
return
}
blobs := f.repo.LookupBlob(t, rid)
if len(blobs) == 0 {
Printf("Object %s not found in the index\n", rid.Str())
f.printer.S("Object %s not found in the index", rid.Str())
return
}
for _, b := range blobs {
if b.ID.Equal(rid) {
Printf("Object belongs to pack %s\n ... Pack %s: %s\n", b.PackID, b.PackID.Str(), b.String())
f.printer.S("Object belongs to pack %s", b.PackID)
f.printer.S(" ... Pack %s: %s", b.PackID.Str(), b.String())
break
}
}
@@ -542,11 +580,13 @@ func (f *Finder) findObjectsPacks() {
}
}
func runFind(ctx context.Context, opts FindOptions, gopts GlobalOptions, args []string) error {
func runFind(ctx context.Context, opts FindOptions, gopts global.Options, args []string, term ui.Terminal) error {
if len(args) == 0 {
return errors.Fatal("wrong number of arguments")
}
printer := ui.NewProgressPrinter(gopts.JSON, gopts.Verbosity, term)
var err error
pat := findPattern{pattern: args}
if opts.CaseInsensitive {
@@ -568,6 +608,10 @@ func runFind(ctx context.Context, opts FindOptions, gopts GlobalOptions, args []
}
}
if !pat.newest.IsZero() && !pat.oldest.IsZero() && pat.oldest.After(pat.newest) {
return errors.Fatal("--oldest must specify a time before --newest")
}
// Check at most only one kind of IDs is provided: currently we
// can't mix types
if (opts.BlobID && opts.TreeID) ||
@@ -576,7 +620,7 @@ func runFind(ctx context.Context, opts FindOptions, gopts GlobalOptions, args []
return errors.Fatal("cannot have several ID types")
}
ctx, repo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock)
ctx, repo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock, printer)
if err != nil {
return err
}
@@ -586,15 +630,15 @@ func runFind(ctx context.Context, opts FindOptions, gopts GlobalOptions, args []
if err != nil {
return err
}
bar := newIndexProgress(gopts.Quiet, gopts.JSON)
if err = repo.LoadIndex(ctx, bar); err != nil {
if err = repo.LoadIndex(ctx, printer); err != nil {
return err
}
f := &Finder{
repo: repo,
pat: pat,
out: statefulOutput{ListLong: opts.ListLong, HumanReadable: opts.HumanReadable, JSON: gopts.JSON},
repo: repo,
pat: pat,
out: statefulOutput{ListLong: opts.ListLong, HumanReadable: opts.HumanReadable, JSON: gopts.JSON, printer: printer, stdout: term.OutputRaw()},
printer: printer,
}
if opts.BlobID {
@@ -617,8 +661,8 @@ func runFind(ctx context.Context, opts FindOptions, gopts GlobalOptions, args []
}
}
var filteredSnapshots []*restic.Snapshot
for sn := range FindFilteredSnapshots(ctx, snapshotLister, repo, &opts.SnapshotFilter, opts.Snapshots) {
var filteredSnapshots []*data.Snapshot
for sn := range FindFilteredSnapshots(ctx, snapshotLister, repo, &opts.SnapshotFilter, opts.Snapshots, printer) {
filteredSnapshots = append(filteredSnapshots, sn)
}
if ctx.Err() != nil {
@@ -626,7 +670,10 @@ func runFind(ctx context.Context, opts FindOptions, gopts GlobalOptions, args []
}
sort.Slice(filteredSnapshots, func(i, j int) bool {
return filteredSnapshots[i].Time.Before(filteredSnapshots[j].Time)
if opts.Reverse {
return filteredSnapshots[i].Time.Before(filteredSnapshots[j].Time)
}
return filteredSnapshots[i].Time.After(filteredSnapshots[j].Time)
})
for _, sn := range filteredSnapshots {

View File

@@ -7,15 +7,15 @@ import (
"testing"
"time"
"github.com/restic/restic/internal/global"
rtest "github.com/restic/restic/internal/test"
)
func testRunFind(t testing.TB, wantJSON bool, gopts GlobalOptions, pattern string) []byte {
buf, err := withCaptureStdout(func() error {
func testRunFind(t testing.TB, wantJSON bool, opts FindOptions, gopts global.Options, pattern string) []byte {
buf, err := withCaptureStdout(t, gopts, func(ctx context.Context, gopts global.Options) error {
gopts.JSON = wantJSON
opts := FindOptions{}
return runFind(context.TODO(), opts, gopts, []string{pattern})
return runFind(ctx, opts, gopts, []string{pattern}, gopts.Term)
})
rtest.OK(t, err)
return buf.Bytes()
@@ -29,16 +29,15 @@ func TestFind(t *testing.T) {
opts := BackupOptions{}
testRunBackup(t, "", []string{env.testdata}, opts, env.gopts)
testRunCheck(t, env.gopts)
results := testRunFind(t, false, env.gopts, "unexistingfile")
results := testRunFind(t, false, FindOptions{}, env.gopts, "unexistingfile")
rtest.Assert(t, len(results) == 0, "unexisting file found in repo (%v)", datafile)
results = testRunFind(t, false, env.gopts, "testfile")
results = testRunFind(t, false, FindOptions{}, env.gopts, "testfile")
lines := strings.Split(string(results), "\n")
rtest.Assert(t, len(lines) == 2, "expected one file found in repo (%v)", datafile)
results = testRunFind(t, false, env.gopts, "testfile*")
results = testRunFind(t, false, FindOptions{}, env.gopts, "testfile*")
lines = strings.Split(string(results), "\n")
rtest.Assert(t, len(lines) == 4, "expected three files found in repo (%v)", datafile)
}
@@ -67,21 +66,78 @@ func TestFindJSON(t *testing.T) {
testRunBackup(t, "", []string{env.testdata}, opts, env.gopts)
testRunCheck(t, env.gopts)
snapshot, _ := testRunSnapshots(t, env.gopts)
results := testRunFind(t, true, env.gopts, "unexistingfile")
results := testRunFind(t, true, FindOptions{}, env.gopts, "unexistingfile")
matches := []testMatches{}
rtest.OK(t, json.Unmarshal(results, &matches))
rtest.Assert(t, len(matches) == 0, "expected no match in repo (%v)", datafile)
results = testRunFind(t, true, env.gopts, "testfile")
results = testRunFind(t, true, FindOptions{}, env.gopts, "testfile")
rtest.OK(t, json.Unmarshal(results, &matches))
rtest.Assert(t, len(matches) == 1, "expected a single snapshot in repo (%v)", datafile)
rtest.Assert(t, len(matches[0].Matches) == 1, "expected a single file to match (%v)", datafile)
rtest.Assert(t, matches[0].Hits == 1, "expected hits to show 1 match (%v)", datafile)
results = testRunFind(t, true, env.gopts, "testfile*")
results = testRunFind(t, true, FindOptions{}, env.gopts, "testfile*")
rtest.OK(t, json.Unmarshal(results, &matches))
rtest.Assert(t, len(matches) == 1, "expected a single snapshot in repo (%v)", datafile)
rtest.Assert(t, len(matches[0].Matches) == 3, "expected 3 files to match (%v)", datafile)
rtest.Assert(t, matches[0].Hits == 3, "expected hits to show 3 matches (%v)", datafile)
results = testRunFind(t, true, FindOptions{TreeID: true}, env.gopts, snapshot.Tree.String())
rtest.OK(t, json.Unmarshal(results, &matches))
rtest.Assert(t, len(matches) == 1, "expected a single snapshot in repo (%v)", matches)
rtest.Assert(t, len(matches[0].Matches) == 3, "expected 3 files to match (%v)", matches[0].Matches)
rtest.Assert(t, matches[0].Hits == 3, "expected hits to show 3 matches (%v)", datafile)
}
func TestFindSorting(t *testing.T) {
env, cleanup := withTestEnvironment(t)
defer cleanup()
testSetupBackupData(t, env)
opts := BackupOptions{}
// first backup
testRunBackup(t, "", []string{env.testdata}, opts, env.gopts)
sn1 := testListSnapshots(t, env.gopts, 1)[0]
// second backup
testRunBackup(t, "", []string{env.testdata}, opts, env.gopts)
snapshots := testListSnapshots(t, env.gopts, 2)
// get id of new snapshot without depending on file order returned by filesystem
sn2 := snapshots[0]
if sn1.Equal(sn2) {
sn2 = snapshots[1]
}
// first restic find - with default FindOptions{}
results := testRunFind(t, true, FindOptions{}, env.gopts, "testfile")
lines := strings.Split(string(results), "\n")
rtest.Assert(t, len(lines) == 2, "expected two lines of output, found %d", len(lines))
matches := []testMatches{}
rtest.OK(t, json.Unmarshal(results, &matches))
// run second restic find with --reverse, sort oldest to newest
resultsReverse := testRunFind(t, true, FindOptions{Reverse: true}, env.gopts, "testfile")
lines = strings.Split(string(resultsReverse), "\n")
rtest.Assert(t, len(lines) == 2, "expected two lines of output, found %d", len(lines))
matchesReverse := []testMatches{}
rtest.OK(t, json.Unmarshal(resultsReverse, &matchesReverse))
// compare result sets
rtest.Assert(t, sn1.String() == matchesReverse[0].SnapshotID, "snapshot[0] must match old snapshot")
rtest.Assert(t, sn2.String() == matchesReverse[1].SnapshotID, "snapshot[1] must match new snapshot")
rtest.Assert(t, matches[0].SnapshotID == matchesReverse[1].SnapshotID, "matches should be sorted 1")
rtest.Assert(t, matches[1].SnapshotID == matchesReverse[0].SnapshotID, "matches should be sorted 2")
}
func TestFindInvalidTimeRange(t *testing.T) {
env, cleanup := withTestEnvironment(t)
defer cleanup()
err := runFind(context.TODO(), FindOptions{Oldest: "2026-01-01", Newest: "2020-01-01"}, env.gopts, []string{"quack"}, env.gopts.Term)
rtest.Assert(t, err != nil && err.Error() == "Fatal: --oldest must specify a time before --newest",
"unexpected error message: %v", err)
}

View File

@@ -7,17 +7,23 @@ import (
"io"
"strconv"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/feature"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/ui/termstatus"
"github.com/restic/restic/internal/ui"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
var cmdForget = &cobra.Command{
Use: "forget [flags] [snapshot ID] [...]",
Short: "Remove snapshots from the repository",
Long: `
func newForgetCommand(globalOptions *global.Options) *cobra.Command {
var opts ForgetOptions
var pruneOpts PruneOptions
cmd := &cobra.Command{
Use: "forget [flags] [snapshot ID] [...]",
Short: "Remove snapshots from the repository",
Long: `
The "forget" command removes snapshots according to a policy. All snapshots are
first divided into groups according to "--group-by", and after that the policy
specified by the "--keep-*" options is applied to each group individually.
@@ -37,22 +43,28 @@ EXIT STATUS
Exit status is 0 if the command was successful.
Exit status is 1 if there was any error.
Exit status is 3 if there was an error removing one or more snapshots.
Exit status is 10 if the repository does not exist.
Exit status is 11 if the repository is already locked.
Exit status is 12 if the password is incorrect.
`,
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
term, cancel := setupTermstatus()
defer cancel()
return runForget(cmd.Context(), forgetOptions, forgetPruneOptions, globalOptions, term, args)
},
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
finalizeSnapshotFilter(&opts.SnapshotFilter)
return runForget(cmd.Context(), opts, pruneOpts, *globalOptions, globalOptions.Term, args)
},
}
opts.AddFlags(cmd.Flags())
pruneOpts.AddLimitedFlags(cmd.Flags())
return cmd
}
type ForgetPolicyCount int
var ErrNegativePolicyCount = errors.New("negative values not allowed, use 'unlimited' instead")
var ErrFailedToRemoveOneOrMoreSnapshots = errors.New("failed to remove one or more snapshots")
func (c *ForgetPolicyCount) Set(s string) error {
switch s {
@@ -93,63 +105,57 @@ type ForgetOptions struct {
Weekly ForgetPolicyCount
Monthly ForgetPolicyCount
Yearly ForgetPolicyCount
Within restic.Duration
WithinHourly restic.Duration
WithinDaily restic.Duration
WithinWeekly restic.Duration
WithinMonthly restic.Duration
WithinYearly restic.Duration
KeepTags restic.TagLists
Within data.Duration
WithinHourly data.Duration
WithinDaily data.Duration
WithinWeekly data.Duration
WithinMonthly data.Duration
WithinYearly data.Duration
KeepTags data.TagLists
UnsafeAllowRemoveAll bool
restic.SnapshotFilter
data.SnapshotFilter
Compact bool
// Grouping
GroupBy restic.SnapshotGroupByOptions
GroupBy data.SnapshotGroupByOptions
DryRun bool
Prune bool
}
var forgetOptions ForgetOptions
var forgetPruneOptions PruneOptions
func (opts *ForgetOptions) AddFlags(f *pflag.FlagSet) {
f.VarP(&opts.Last, "keep-last", "l", "keep the last `n` snapshots (use 'unlimited' to keep all snapshots)")
f.VarP(&opts.Hourly, "keep-hourly", "H", "keep the last `n` hourly snapshots (use 'unlimited' to keep all hourly snapshots)")
f.VarP(&opts.Daily, "keep-daily", "d", "keep the last `n` daily snapshots (use 'unlimited' to keep all daily snapshots)")
f.VarP(&opts.Weekly, "keep-weekly", "w", "keep the last `n` weekly snapshots (use 'unlimited' to keep all weekly snapshots)")
f.VarP(&opts.Monthly, "keep-monthly", "m", "keep the last `n` monthly snapshots (use 'unlimited' to keep all monthly snapshots)")
f.VarP(&opts.Yearly, "keep-yearly", "y", "keep the last `n` yearly snapshots (use 'unlimited' to keep all yearly snapshots)")
f.VarP(&opts.Within, "keep-within", "", "keep snapshots that are newer than `duration` (eg. 1y5m7d2h) relative to the latest snapshot")
f.VarP(&opts.WithinHourly, "keep-within-hourly", "", "keep hourly snapshots that are newer than `duration` (eg. 1y5m7d2h) relative to the latest snapshot")
f.VarP(&opts.WithinDaily, "keep-within-daily", "", "keep daily snapshots that are newer than `duration` (eg. 1y5m7d2h) relative to the latest snapshot")
f.VarP(&opts.WithinWeekly, "keep-within-weekly", "", "keep weekly snapshots that are newer than `duration` (eg. 1y5m7d2h) relative to the latest snapshot")
f.VarP(&opts.WithinMonthly, "keep-within-monthly", "", "keep monthly snapshots that are newer than `duration` (eg. 1y5m7d2h) relative to the latest snapshot")
f.VarP(&opts.WithinYearly, "keep-within-yearly", "", "keep yearly snapshots that are newer than `duration` (eg. 1y5m7d2h) relative to the latest snapshot")
f.Var(&opts.KeepTags, "keep-tag", "keep snapshots with this `taglist` (can be specified multiple times)")
f.BoolVar(&opts.UnsafeAllowRemoveAll, "unsafe-allow-remove-all", false, "allow deleting all snapshots of a snapshot group")
func init() {
cmdRoot.AddCommand(cmdForget)
f := cmdForget.Flags()
f.VarP(&forgetOptions.Last, "keep-last", "l", "keep the last `n` snapshots (use 'unlimited' to keep all snapshots)")
f.VarP(&forgetOptions.Hourly, "keep-hourly", "H", "keep the last `n` hourly snapshots (use 'unlimited' to keep all hourly snapshots)")
f.VarP(&forgetOptions.Daily, "keep-daily", "d", "keep the last `n` daily snapshots (use 'unlimited' to keep all daily snapshots)")
f.VarP(&forgetOptions.Weekly, "keep-weekly", "w", "keep the last `n` weekly snapshots (use 'unlimited' to keep all weekly snapshots)")
f.VarP(&forgetOptions.Monthly, "keep-monthly", "m", "keep the last `n` monthly snapshots (use 'unlimited' to keep all monthly snapshots)")
f.VarP(&forgetOptions.Yearly, "keep-yearly", "y", "keep the last `n` yearly snapshots (use 'unlimited' to keep all yearly snapshots)")
f.VarP(&forgetOptions.Within, "keep-within", "", "keep snapshots that are newer than `duration` (eg. 1y5m7d2h) relative to the latest snapshot")
f.VarP(&forgetOptions.WithinHourly, "keep-within-hourly", "", "keep hourly snapshots that are newer than `duration` (eg. 1y5m7d2h) relative to the latest snapshot")
f.VarP(&forgetOptions.WithinDaily, "keep-within-daily", "", "keep daily snapshots that are newer than `duration` (eg. 1y5m7d2h) relative to the latest snapshot")
f.VarP(&forgetOptions.WithinWeekly, "keep-within-weekly", "", "keep weekly snapshots that are newer than `duration` (eg. 1y5m7d2h) relative to the latest snapshot")
f.VarP(&forgetOptions.WithinMonthly, "keep-within-monthly", "", "keep monthly snapshots that are newer than `duration` (eg. 1y5m7d2h) relative to the latest snapshot")
f.VarP(&forgetOptions.WithinYearly, "keep-within-yearly", "", "keep yearly snapshots that are newer than `duration` (eg. 1y5m7d2h) relative to the latest snapshot")
f.Var(&forgetOptions.KeepTags, "keep-tag", "keep snapshots with this `taglist` (can be specified multiple times)")
f.BoolVar(&forgetOptions.UnsafeAllowRemoveAll, "unsafe-allow-remove-all", false, "allow deleting all snapshots of a snapshot group")
initMultiSnapshotFilter(f, &forgetOptions.SnapshotFilter, false)
f.StringArrayVar(&forgetOptions.Hosts, "hostname", nil, "only consider snapshots with the given `hostname` (can be specified multiple times)")
f.StringArrayVar(&opts.Hosts, "hostname", nil, "only consider snapshots with the given `hostname` (can be specified multiple times)")
err := f.MarkDeprecated("hostname", "use --host")
if err != nil {
// MarkDeprecated only returns an error when the flag is not found
panic(err)
}
// must be defined after `--hostname` to not override the default value from the environment
initMultiSnapshotFilter(f, &opts.SnapshotFilter, false)
f.BoolVarP(&forgetOptions.Compact, "compact", "c", false, "use compact output format")
forgetOptions.GroupBy = restic.SnapshotGroupByOptions{Host: true, Path: true}
f.VarP(&forgetOptions.GroupBy, "group-by", "g", "`group` snapshots by host, paths and/or tags, separated by comma (disable grouping with '')")
f.BoolVarP(&forgetOptions.DryRun, "dry-run", "n", false, "do not delete anything, just print what would be done")
f.BoolVar(&forgetOptions.Prune, "prune", false, "automatically run the 'prune' command if snapshots have been removed")
f.BoolVarP(&opts.Compact, "compact", "c", false, "use compact output format")
opts.GroupBy = data.SnapshotGroupByOptions{Host: true, Path: true}
f.VarP(&opts.GroupBy, "group-by", "g", "`group` snapshots by host, paths and/or tags, separated by comma (disable grouping with '')")
f.BoolVarP(&opts.DryRun, "dry-run", "n", false, "do not delete anything, just print what would be done")
f.BoolVar(&opts.Prune, "prune", false, "automatically run the 'prune' command if snapshots have been removed")
f.SortFlags = false
addPruneOptions(cmdForget, &forgetPruneOptions)
}
func verifyForgetOptions(opts *ForgetOptions) error {
@@ -158,7 +164,7 @@ func verifyForgetOptions(opts *ForgetOptions) error {
return errors.Fatal("negative values other than -1 are not allowed for --keep-*")
}
for _, d := range []restic.Duration{opts.Within, opts.WithinHourly, opts.WithinDaily,
for _, d := range []data.Duration{opts.Within, opts.WithinHourly, opts.WithinDaily,
opts.WithinMonthly, opts.WithinWeekly, opts.WithinYearly} {
if d.Hours < 0 || d.Days < 0 || d.Months < 0 || d.Years < 0 {
return errors.Fatal("durations containing negative values are not allowed for --keep-within*")
@@ -168,7 +174,7 @@ func verifyForgetOptions(opts *ForgetOptions) error {
return nil
}
func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOptions, gopts GlobalOptions, term *termstatus.Terminal, args []string) error {
func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOptions, gopts global.Options, term ui.Terminal, args []string) error {
err := verifyForgetOptions(&opts)
if err != nil {
return err
@@ -183,22 +189,17 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
return errors.Fatal("--no-lock is only applicable in combination with --dry-run for forget command")
}
ctx, repo, unlock, err := openWithExclusiveLock(ctx, gopts, opts.DryRun && gopts.NoLock)
printer := ui.NewProgressPrinter(gopts.JSON, gopts.Verbosity, term)
ctx, repo, unlock, err := openWithExclusiveLock(ctx, gopts, opts.DryRun && gopts.NoLock, printer)
if err != nil {
return err
}
defer unlock()
verbosity := gopts.verbosity
if gopts.JSON {
verbosity = 0
}
printer := newTerminalProgressPrinter(verbosity, term)
var snapshots restic.Snapshots
var snapshots data.Snapshots
removeSnIDs := restic.NewIDSet()
for sn := range FindFilteredSnapshots(ctx, repo, repo, &opts.SnapshotFilter, args) {
for sn := range FindFilteredSnapshots(ctx, repo, repo, &opts.SnapshotFilter, args, printer) {
snapshots = append(snapshots, sn)
}
if ctx.Err() != nil {
@@ -213,12 +214,12 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
removeSnIDs.Insert(*sn.ID())
}
} else {
snapshotGroups, _, err := restic.GroupSnapshots(snapshots, opts.GroupBy)
snapshotGroups, _, err := data.GroupSnapshots(snapshots, opts.GroupBy)
if err != nil {
return err
}
policy := restic.ExpirePolicy{
policy := data.ExpirePolicy{
Last: int(opts.Last),
Hourly: int(opts.Hourly),
Daily: int(opts.Daily),
@@ -253,13 +254,13 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
}
if gopts.Verbose >= 1 && !gopts.JSON {
err = PrintSnapshotGroupHeader(globalOptions.stdout, k)
err = PrintSnapshotGroupHeader(gopts.Term.OutputWriter(), k)
if err != nil {
return err
}
}
var key restic.SnapshotGroupKey
var key data.SnapshotGroupKey
if json.Unmarshal([]byte(k), &key) != nil {
return err
}
@@ -269,21 +270,25 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
fg.Host = key.Hostname
fg.Paths = key.Paths
keep, remove, reasons := restic.ApplyPolicy(snapshotGroup, policy)
keep, remove, reasons := data.ApplyPolicy(snapshotGroup, policy)
if feature.Flag.Enabled(feature.SafeForgetKeepTags) && !policy.Empty() && len(keep) == 0 {
if !policy.Empty() && len(keep) == 0 {
return fmt.Errorf("refusing to delete last snapshot of snapshot group \"%v\"", key.String())
}
if len(keep) != 0 && !gopts.Quiet && !gopts.JSON {
printer.P("keep %d snapshots:\n", len(keep))
PrintSnapshots(globalOptions.stdout, keep, reasons, opts.Compact)
if err := PrintSnapshots(gopts.Term.OutputWriter(), keep, reasons, opts.Compact); err != nil {
return err
}
printer.P("\n")
}
fg.Keep = asJSONSnapshots(keep)
if len(remove) != 0 && !gopts.Quiet && !gopts.JSON {
printer.P("remove %d snapshots:\n", len(remove))
PrintSnapshots(globalOptions.stdout, remove, nil, opts.Compact)
if err := PrintSnapshots(gopts.Term.OutputWriter(), remove, nil, opts.Compact); err != nil {
return err
}
printer.P("\n")
}
fg.Remove = asJSONSnapshots(remove)
@@ -302,12 +307,15 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
return ctx.Err()
}
// these are the snapshots that failed to be removed
failedSnIDs := restic.NewIDSet()
if len(removeSnIDs) > 0 {
if !opts.DryRun {
bar := printer.NewCounter("files deleted")
err := restic.ParallelRemove(ctx, repo, removeSnIDs, restic.SnapshotFile, func(id restic.ID, err error) error {
err := restic.ParallelRemove(ctx, repo, removeSnIDs, restic.WriteableSnapshotFile, func(id restic.ID, err error) error {
if err != nil {
printer.E("unable to remove %v/%v from the repository\n", restic.SnapshotFile, id)
failedSnIDs.Insert(id)
} else {
printer.VV("removed %v/%v\n", restic.SnapshotFile, id)
}
@@ -323,12 +331,16 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
}
if gopts.JSON && len(jsonGroups) > 0 {
err = printJSONForget(globalOptions.stdout, jsonGroups)
err = printJSONForget(gopts.Term.OutputWriter(), jsonGroups)
if err != nil {
return err
}
}
if len(failedSnIDs) > 0 {
return ErrFailedToRemoveOneOrMoreSnapshots
}
if len(removeSnIDs) > 0 && opts.Prune {
if opts.DryRun {
printer.P("%d snapshots would be removed, running prune dry run\n", len(removeSnIDs))
@@ -336,7 +348,7 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
printer.P("%d snapshots have been removed, running prune\n", len(removeSnIDs))
}
pruneOptions.DryRun = opts.DryRun
return runPruneWithRepo(ctx, pruneOptions, gopts, repo, removeSnIDs, term)
return runPruneWithRepo(ctx, pruneOptions, repo, removeSnIDs, printer)
}
return nil
@@ -352,7 +364,7 @@ type ForgetGroup struct {
Reasons []KeepReason `json:"reasons"`
}
func asJSONSnapshots(list restic.Snapshots) []Snapshot {
func asJSONSnapshots(list data.Snapshots) []Snapshot {
var resultList []Snapshot
for _, sn := range list {
k := Snapshot{
@@ -371,7 +383,7 @@ type KeepReason struct {
Matches []string `json:"matches"`
}
func asJSONKeeps(list []restic.KeepReason) []KeepReason {
func asJSONKeeps(list []data.KeepReason) []KeepReason {
var resultList []KeepReason
for _, keep := range list {
k := KeepReason{

Some files were not shown because too many files have changed in this diff Show More