Compare commits

..
Author SHA1 Message Date
dependabot[bot] 3baba6519e build(deps): bump re-actors/alls-green from 1.2.2 to 1.3.0
Bumps [re-actors/alls-green](https://github.com/re-actors/alls-green) from 1.2.2 to 1.3.0.
- [Release notes](https://github.com/re-actors/alls-green/releases)
- [Commits](https://github.com/re-actors/alls-green/compare/05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe...b5b5b37504aa4183270bd3d855c52a67f212be35)

---
updated-dependencies:
- dependency-name: re-actors/alls-green
  dependency-version: 1.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-01 01:43:57 +00:00
Etienne D ba802d42b7 fix(swift): store APIKey as SecretString to prevent debug log leak (#22007) 2026-08-29 20:11:48 +00:00
CAOShurong 46ea365629 docs: fix two dead links (PGP key URL, MinIO docs URL) (#22028) 2026-08-29 19:07:37 +00:00
CAOShurong fb5e9df357 docs: fix contradiction about which files are encrypted (#22029) 2026-08-29 19:07:11 +00:00
Michael Eischer b593ba305b Apply go fix ./... (#22037) 2026-08-29 21:02:05 +02:00
Buggfix42 28d802df8c [Documentation] A few minor improvements (#21998) 2026-08-29 17:47:29 +00:00
GuitarBilly 0946f45de6 Update 110_talks.rst (#21989) 2026-08-29 19:44:43 +02:00
dependabot[bot] 5895e6d059 build(deps): bump cloud.google.com/go/storage from 1.63.0 to 1.64.0 (#21996)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-29 19:43:41 +02:00
Michael Eischer e982b6e7b5 CI: add size labels to PRs (#22036) 2026-08-29 19:39:04 +02:00
Jörn Bethune 479cf1fb3d documentation: Fix incorrect snapshot ID (#22017) 2026-08-29 17:33:20 +00:00
Ricardo Mendonça Ferreira dbaa8cf124 Update documentation for environment variable syntax (#22026) 2026-08-29 17:30:52 +00:00
dependabot[bot] a80be1478a build(deps): bump google.golang.org/api from 0.285.0 to 0.291.0 (#21995)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 22:24:27 +02:00
dependabot[bot] 7bfa32a90a build(deps): bump github.com/pkg/sftp from 1.13.10 to 1.13.11 (#21994)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 22:23:52 +02:00
dependabot[bot] 63b583c4ea build(deps): bump github.com/minio/minio-go/v7 from 7.1.0 to 7.2.1 (#21993)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 22:22:40 +02:00
dependabot[bot] 85bf4430b8 build(deps): bump actions/setup-go from 6 to 7 (#21992)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 22:21:34 +02:00
dependabot[bot] e2b43a5f1f build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob from 1.7.0 to 1.8.0 (#21991)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 22:21:07 +02:00
dependabot[bot] 607aba3809 build(deps): bump docker/login-action from 4.2.0 to 4.6.0 (#21990)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 22:20:40 +02:00
Michael Eischer c6074f82fb Merge pull request #21978 from MichaelEischer/go-fix2
Run `go fix ./...`
2026-08-01 22:17:53 +02:00
Arpit Jain 8baffc4027 repository: reject key and config files that are too short (#21977)
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
2026-07-22 20:38:07 +00:00
Michael Eischer f215365af9 Apply go fix -waitgroup ./... 2026-07-22 22:27:21 +02:00
Michael Eischer 14e523a1d9 Apply go fix -testingcontext ./... 2026-07-22 22:27:15 +02:00
Michael Eischer 58f92708c2 Apply go fix -stringsseq ./... 2026-07-22 22:27:07 +02:00
Michael Eischer 31e96f4ec9 Apply go fix -stringsbuilder ./... 2026-07-22 22:26:50 +02:00
Michael Eischer a2cb015591 Apply go fix -slicescontains ./... 2026-07-22 22:26:33 +02:00
Michael Eischer e2495b72bb Apply go fix -reflecttypefor ./... 2026-07-22 22:26:27 +02:00
Michael Eischer 2c169edad4 Apply go fix -rangeint ./... 2026-07-22 22:26:19 +02:00
Michael Eischer fb36a7f59b Apply go fix -omitzero ./... 2026-07-22 22:26:07 +02:00
Michael Eischer 8ed263c6dd Apply go fix -minmax ./... 2026-07-22 22:25:56 +02:00
Michael Eischer 0e4f288e83 Apply go fix -mapsloop ./... 2026-07-22 22:25:47 +02:00
Michael Eischer da4d8f5851 Apply go fix -fmtappendf ./... 2026-07-22 22:25:26 +02:00
Michael Eischer 32e9869cc8 Apply go fix -any ./... 2026-07-22 22:25:18 +02:00
Junker der Provinz d4088aa09b doc: describe the cadence of JSON status messages (#21954) 2026-07-15 20:38:38 +00:00
schrumpelnase 35dcda418c docs(README.md): fixed label of the link to the mastodon profile (#21958) 2026-07-15 20:32:26 +00:00
Michael Eischer af4f50223e ls: only keep fields required for sorting in memory (#21949) 2026-07-15 22:22:55 +02:00
Michael Eischer 9e007fa3cc Merge pull request #21937 from brainexe/reduce-index-memory-packindex-uint32
Reduce in-memory index entry size by storing packIndex as uint32
2026-07-15 22:16:40 +02:00
dependabot[bot] a4d85ce299 build(deps): bump the golang-x-deps group across 1 directory with 6 updates (#21923)
Signed-off-by: dependabot[bot] <support@github.com>
2026-07-15 21:32:37 +02:00
dependabot[bot] 9b0ee37697 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azidentity from 1.13.1 to 1.14.0 (#21925)
Signed-off-by: dependabot[bot] <support@github.com>
2026-07-15 21:31:44 +02:00
Matthias Dötsch 905ca56ee8 Address review feedback on #21937:
- addToPacks now returns uint32 directly and the value is passed through
  store() to indexMap.add unchanged, instead of casting between int and
  uint32.
- merge() appends idx2.packs to idx.packs without going through
  addToPacks, so it now checks the pack count against the uint32 limit
  itself + error if exceeded.
- optimize changelog message
2026-07-13 07:25:08 +02:00
dependabot[bot] 987caba408 build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azcore from 1.21.1 to 1.22.0 (#21926)
Signed-off-by: dependabot[bot] <support@github.com>
2026-07-10 22:46:11 +02:00
dependabot[bot] bfca18c1b0 build(deps): bump actions/checkout from 6 to 7 (#21922)
Signed-off-by: dependabot[bot] <support@github.com>
2026-07-10 22:20:22 +02:00
dependabot[bot] dba493cb6c build(deps): bump github.com/klauspost/compress from 1.18.6 to 1.18.7 (#21924)
Signed-off-by: dependabot[bot] <support@github.com>
2026-07-10 22:17:43 +02:00
dependabot[bot] 512d0577d6 build(deps): bump cloud.google.com/go/storage from 1.62.2 to 1.63.0 (#21927)
Signed-off-by: dependabot[bot] <support@github.com>
2026-07-10 22:16:48 +02:00
Matthias Dötsch e428de5f84 Reduce in-memory index entry size by storing packIndex as uint32
Each blob in a repository requires one index entry in memory, which is one
of the largest contributors to restic's memory usage. The indexEntry.packIndex
field, an index into the per-Index packs slice, was stored as a machine-word
int (8 bytes on amd64) although the value is always a small array index.

Store it as a uint32 instead. This shrinks indexEntry from 64 to 56 bytes on
64-bit platforms (56 % 8 == 0, so no padding is added), reducing index memory
by roughly 12% -- about 100 MB for a repository with ~13 million blobs, as
confirmed by profiling. uint32 allows 4.29 billion packs (>30 billion blobs at
the assumed 8 blobs/pack), far beyond any real repository; addToPacks guards
against overflow defensively. The on-disk repository format is unaffected.
2026-07-08 06:01:15 +00:00
Michael Eischer d8ef26afa4 Merge branch 'patch-release' 2026-07-05 16:27:43 +02:00
Alexander Neumann 6335213501 Set development version for 0.19.1 2026-07-05 09:52:54 +02:00
Alexander Neumann 6aa3a516ce Add version for 0.19.1 2026-07-05 09:52:50 +02:00
Alexander Neumann b1da29738c Generate CHANGELOG.md for 0.19.1 2026-07-05 09:52:30 +02:00
Alexander Neumann 09a1eb6714 Prepare changelog for 0.19.1 2026-07-05 09:52:30 +02:00
astro-stan cc93a94e15 feat: Add support for setting --ignore-ctime and --ignore-inode via environment variables (#5730) 2026-06-28 15:36:58 +02:00
Winfried PlappertandMichael Eischer 62991338ea replace FindFilteredSnapshots() with (*data.SnapshotFilter).FindAll() (#21912)
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-06-28 13:31:06 +00:00
Winfried PlappertandMichael Eischer 75de8b54e6 restic check and restic repair packs: treat missing packfiles the same as damaged and truncated packfiles (#21845)
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-06-28 12:09:42 +02:00
Michael Eischer e4056e70a8 Merge pull request #21888 from MichaelEischer/chunker-factory
Move chunker construction to repository and switch to BaseChunker
2026-06-27 22:56:07 +02:00
Michael Eischer 8cc69782b5 repository: expose ZeroChunk via chunker factory 2026-06-27 22:23:59 +02:00
Michael Eischer ccb828e87b repository: add ChunkerFactory and decouple archiver from chunker
Introduce restic.Chunker and ChunkerFactory interfaces with a
repository-backed implementation. The archiver obtains chunkers via
ChunkerFactory() from the repository.
2026-06-27 22:13:41 +02:00
Michael Eischer 70a45791b2 archiver: switch file saver from Chunker to BaseChunker
Update the chunker dependency. Move the chunk memory handling into the
fileSaver. This minimizes the logic required in a chunker
implementation.

readNextChunk is a direct derivative of Chunker.Next.
2026-06-27 22:13:41 +02:00
Winfried PlappertandMichael Eischer 9e1a526611 Fix broken snapshots via restic repair snapshots --forget (#21907)
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-06-27 22:09:10 +02:00
Michael Eischer aa94be2dbd Merge pull request #21883 from MichaelEischer/fix-find-pack
find: improve blob resolution for broken pack files
2026-06-26 22:33:38 +02:00
Michael Eischer 804ff4bc95 find: add test for listing blobs from corrupt pack files 2026-06-26 22:16:55 +02:00
Michael Eischer 9670cd7459 find: fix fallback to index if pack cannot be listed
`find` would only look up completely missing pack files in the index. A
still existing but broken pack file would result in an error.
2026-06-26 22:16:55 +02:00
Michael Eischer 634e9b2411 find: check blobIDs/treeIDs presence by length
Depending on the code path, the map could be initialized but stay empty.
2026-06-26 21:46:30 +02:00
Gilbert Gilb's db03aed816 feat(backends/s3): add warmup support for check command (#5248) 2026-06-25 20:46:55 +02:00
Michael Eischer 4e8eea7ab4 Merge pull request #21902 from restic/speedup-test
Cut local test suite execution time in half
2026-06-24 21:34:55 +02:00
Michael Eischer c2b4d6a959 Patch release cherry-pick (#21914) 2026-06-24 20:06:20 +02:00
Michael Eischer 981adc47ac snapshots: improve wording for timezone information (#21913) 2026-06-24 19:49:07 +02:00
Michael Eischer 437945bf90 Merge pull request #21911 from restic/patch-release-polish-changelogs
Polish changelogs
2026-06-24 19:48:35 +02:00
Michael Eischerandrawtaz fc422d4145 Apply suggestions from code review
Co-authored-by: rawtaz <rawtaz@users.noreply.github.com>
2026-06-24 19:30:11 +02:00
Michael Eischer f058670219 polish changelogs 2026-06-23 19:55:12 +02:00
Michael Eischer df8454770b Merge pull request #21910 from restic/patch-release-picks
Cherry pick changes for patch release
2026-06-23 19:54:25 +02:00
Michael Eischer c9185dd19c repository/index: ensure progress bar cancelation on early index load failure (#21881) 2026-06-23 19:40:50 +02:00
Ricardo Sawir 32be2e559b fuse: reset treeCache on snapshot reload to fix stale latest symlink (#21873)
The treeCache in SnapshotsDir was never cleared when snapshots were
reloaded. This caused the "latest" symlink to keep pointing to the
previous snapshot even after new snapshots were added.

Add a generation counter to SnapshotsDirStructure that is incremented
whenever the directory structure is rebuilt (in makeDirs). The
treeCache checks this generation on each lookup and resets itself
when the generation changes, ensuring cached nodes (including symlinks)
are refreshed after a snapshot reload.
2026-06-23 19:26:29 +02:00
Eyüp Can Akman add4fa1efb backup: skip source paths that cannot be accessed (#21852) 2026-06-23 19:26:13 +02:00
Michael Eischer c7c3414641 archiver: ignore duplicate but excluded directory entry (#21900) 2026-06-23 19:26:10 +02:00
Michael Eischer 8ef295e2f5 snapshots: revert default --lastest behavior to pre-0.19.0
the changed behavior now only applies when using `--group-by`.
2026-06-23 19:15:14 +02:00
Michael Eischer bc714d1864 snapshots: cleanup handling of deprecated --last option 2026-06-23 19:15:14 +02:00
Michael Eischer debf95f58d backend/sftp: fix removing files on windows sftp 2026-06-23 19:14:54 +02:00
Michael Eischer 27c44c11aa backend/sftp: fix error reporting of Save method 2026-06-23 19:14:54 +02:00
Michael Eischer 93f695a803 backend/rest: fix flaky test cleanup (#21901) 2026-06-23 19:14:54 +02:00
Michael Eischer 3e21d1fea6 fs: print missing error if xattr cannot be read (#21896) 2026-06-23 19:13:39 +02:00
Michael Eischer 8ee674da55 repository: show correct error if zstd decoder cannot be initialized 2026-06-23 19:13:39 +02:00
Michael Eischer c21f0fabc6 selfupdate: improve error handling 2026-06-23 19:13:39 +02:00
Michael Eischer 6aaa2eace4 prune/repair pack: document ignored errors 2026-06-23 19:13:39 +02:00
Michael Eischer f2d614db56 backend/util: fix errorhandling in DefaultDelete test helper 2026-06-23 19:13:39 +02:00
Michael Eischer ed655b476a backend/sftp: fix file handle leak if chmod for a file fails 2026-06-23 19:13:39 +02:00
Michael Eischer 80f694b32e backend/rest: correctly close body on out of bounds read 2026-06-23 19:13:39 +02:00
Michael Eischer eaa835becd backend/b2: correctly close file if too short 2026-06-23 19:13:39 +02:00
Michael Eischer 7aa82d68b4 forget: fix error handling if snapshot key cannot be marshaled 2026-06-23 19:13:39 +02:00
Michael Eischer a3fa3eb182 ensure reliable cleanup of test repository (#21880) 2026-06-23 19:12:08 +02:00
Michael Eischer cb24c4f566 snapshots: show location name instead of current timezone (#21877) 2026-06-23 19:11:19 +02:00
Michael Eischer d6fd4ae26f mount: fix crash in mountpoint validation (#21879) 2026-06-23 19:09:57 +02:00
Michael Eischer 4134bdfac2 stats: hide progress bar for json output (#21871) 2026-06-23 19:08:36 +02:00
Michael Eischer c08e7fd956 mount: unify mountpoint validation error messages 2026-06-23 19:08:36 +02:00
Michael Eischer d07bcd50da mount: factor out mountpoint validation into helper 2026-06-23 19:08:36 +02:00
Srigovind Nayak e6b9118f51 doc: note that mountpoint must not overlap the repository
Document the new restriction added so users encountering the error
message have a reference, and so the constraint is visible before they
hit it.
2026-06-23 19:08:12 +02:00
Srigovind Nayak 82a665384b chore: update changelog for issue 5234 2026-06-23 19:08:12 +02:00
Srigovind Nayak 1e249b0da1 mount: refuse mountpoints that overlap the local repository
Mounting a local repository onto its own directory caused the FUSE
  server to read its own backend files through the mount it had just
  created, deadlocking the kernel. `umount` then reported "Device or
  resource busy" and recovery required a reboot that took several
  minutes. The same shape occurs when the mountpoint is nested inside
  the repository directory, or when the repository directory is nested
  inside the mountpoint.

  The mount command now resolves both paths via filepath.Abs and
  filepath.EvalSymlinks and refuses with a fatal error if either path
  equals or contains the other. The check runs before the repository
  lock is acquired so an overlap fails fast. Only the local backend is
  checked; remote backends cannot shadow the mountpoint directory.
2026-06-23 19:08:12 +02:00
Michael Eischer 5967f9a894 upgrade compress library 2026-06-23 19:07:56 +02:00
Michael Eischer 1733dd56b9 repository: fix zero-sized blobs in v2 repos 2026-06-23 19:07:56 +02:00
Michael Eischer ed39b60e7d fix version set by helper after release (#21865) 2026-06-23 19:06:55 +02:00
Michael Eischer 7134577c56 use constants from cobra for shell completion helper names (#21905) 2026-06-22 22:58:26 +02:00
Ricardo Sawir 55e335ec6c fuse: reset treeCache on snapshot reload to fix stale latest symlink (#21873)
The treeCache in SnapshotsDir was never cleared when snapshots were
reloaded. This caused the "latest" symlink to keep pointing to the
previous snapshot even after new snapshots were added.

Add a generation counter to SnapshotsDirStructure that is incremented
whenever the directory structure is rebuilt (in makeDirs). The
treeCache checks this generation on each lookup and resets itself
when the generation changes, ensuring cached nodes (including symlinks)
are refreshed after a snapshot reload.
2026-06-22 18:31:51 +00:00
Winfried Plappert d30d6b6281 backup - show excluded files and directories in verbose mode - text/JSON (#21887) 2026-06-21 16:11:42 +00:00
Eyüp Can Akman 8d7679c831 backup: skip source paths that cannot be accessed (#21852) 2026-06-21 17:16:16 +02:00
Michael Eischer d9dd1b7534 archiver: ignore duplicate but excluded directory entry (#21900) 2026-06-21 15:49:08 +02:00
Michael Eischer 1151d70655 Merge pull request #21875 from MichaelEischer/fix-snapshots-latest-group-by
Fix default grouping of `snapshots --latest <n>`
2026-06-21 15:46:49 +02:00
Michael Eischer 369da8a770 snapshots: revert default --lastest behavior to pre-0.19.0
the changed behavior now only applies when using `--group-by`.
2026-06-21 15:28:22 +02:00
Michael Eischer 9f84c80056 snapshots: cleanup handling of deprecated --last option 2026-06-21 15:28:22 +02:00
Michael Eischer 6070462465 backup: move options finalization to BackupOptions.Finalize 2026-06-21 15:28:22 +02:00
Michael Eischer 1029fe6dd0 list packs snapshot: include actual error in error message (#21903) 2026-06-21 15:27:19 +02:00
Michael Eischer 8f00b335b4 rclone/fs: parallelize tests 2026-06-20 22:43:03 +02:00
Michael Eischer c6a064b68b mount: disable debug log for test
I don't recall any recent problems with that test.
2026-06-20 22:04:07 +02:00
Michael Eischer 8d191c19a5 archiver: decrease sleeps for TestFileChanged test
Modern filesystems provide microsecond granularity or better. The old
special case for macOS is removed as Go 1.25 (minimum for restic)
requires at least macOS 12, which uses APFS instead of the old HFS+.
2026-06-20 21:55:46 +02:00
Michael Eischer d5267f03e0 use fastest compression in integration tests 2026-06-20 20:00:17 +02:00
Michael Eischer 5683224a3c layout: skip creation of pack subdirectories in integration tests
Each time a local backend is created, the local backend also creates all
shard subdirectories. For the integration tests this has the downside
that this results in ~120 (number of test) * 256 (number of directories)
= 30k directories that are created unnecessarily. This significantly
slows down test execution and cleanup.
2026-06-20 20:00:17 +02:00
Michael Eischer 71064fac10 mount: decrease sleep to speed up test 2026-06-20 20:00:17 +02:00
Michael Eischer 52cde35aea try deleting a directory before resetting the readonly status in tests 2026-06-20 20:00:17 +02:00
Michael Eischer f394723aa2 inject crypto keys for integration tests 2026-06-20 20:00:17 +02:00
Michael Eischer 072305c5b3 repository: run version sub-tests of TestAllVersions in parallel
TestRepositoryIncrementalIndex no longer modified index.Full as this
modified global state and also had no effect on the test result.
2026-06-20 19:59:37 +02:00
Michael Eischer a1420ea6c7 repository: use separate rand instance per test
Use separate instances to prevent data races when executing tests in
parallel.
2026-06-20 19:50:10 +02:00
Michael Eischer a3be3bd9e1 backend/test: gradually increase timeout for TestListCancel to speed up fast backends 2026-06-20 19:46:22 +02:00
Michael Eischer b24d05bcb4 skip key decryption in tests 2026-06-20 19:46:22 +02:00
Michael Eischer c021b8cde0 decrease test data sizes 2026-06-20 19:46:22 +02:00
Michael Eischer 18e5c446e0 data/fs: faster comparison in tests 2026-06-20 19:46:22 +02:00
Michael Eischer f91afb2fa8 repository: run TestPruneSmall in parallel to other tests 2026-06-20 19:46:22 +02:00
Michael Eischer 2148508050 repository/checker: speed up test repo creation
data.TestCreateSnapshot is much faster than archiver.TestSnapshot
2026-06-20 19:46:22 +02:00
Michael Eischer 37e8f50aeb repository: decrease test data size for streamPack 2026-06-20 19:46:22 +02:00
Michael Eischer 7e5eaf1ead crypto: decrease parameters for calibrate test 2026-06-20 19:46:22 +02:00
Michael Eischer aae0985673 index: decrease depth of test repos 2026-06-20 19:46:22 +02:00
Michael Eischer f9d953d4cd index: test ForAllIndex with generated repo 2026-06-20 19:46:22 +02:00
Michael Eischer 69a3ba5b33 index: speed up oversized test data generation 2026-06-20 19:46:22 +02:00
Michael Eischer c183fe2035 restore: speed up test data generation in newTestRepo 2026-06-20 19:46:22 +02:00
Michael Eischer 1174e97b30 restic: speed up repository config initialization in tests
Avoid redundant polynomial generation, which takes a millisecond or so.
2026-06-20 19:46:22 +02:00
Michael Eischer 440d925467 repository: default to fastest compression in tests 2026-06-20 19:46:22 +02:00
Michael Eischer 28521d27c1 Merge pull request #21897 from MichaelEischer/sftp-fix-chmod
backend/sftp: fix removing files on windows sftp
2026-06-20 19:29:49 +02:00
Michael Eischer af64caf5d9 Merge pull request #21885 from MichaelEischer/separate-backend-restic-filetype
Separate backend.FileType from restic.FileType
2026-06-20 19:24:51 +02:00
Michael Eischer 9ab5fc59c2 restic: split FileType for backend.FileType
Equality of constants is enforced via internal/repository/filetype.go
using compile time checks.
2026-06-20 19:15:40 +02:00
Michael Eischer 6c509f7ac1 Correctly pair backend/restic.FileType with APIs
Use backend.FileType to interact with the backend. And restic.FileType
to interact with the repository.
2026-06-20 19:15:40 +02:00
Michael Eischer ea699bb0ba backend/rest: fix flaky test cleanup (#21901) 2026-06-20 19:14:54 +02:00
Michael Eischer 532f36a5a8 archiver: pass ItemAction to progress reporter instead of data.Node (#21886) 2026-06-20 19:06:45 +02:00
Michael Eischer 57ac5d107c Merge pull request #21882 from MichaelEischer/untangle-imports
Untangle imports of repository, restorer, fs
2026-06-20 18:24:50 +02:00
Michael Eischer 2f31cde517 internal/restorer: invert dependency direction to ui/restorer
The restorer imported ui/restorer which leaks ui logic into the restorer
core. Swap the direction by letting the restorer use a ProgressReporter
interface + associated constants.
2026-06-20 17:49:20 +02:00
Michael Eischer 5cd39d01c1 internal/data: extract HardlinkIndex from restorer
The HardlinkIndex is also used by `cmd_stats`, thus place it in a shared
package.
2026-06-20 17:49:20 +02:00
Michael Eischer 61708772a2 mount: use existing HasPathPrefix helper
replaces the custom isInside helper to check path nesting
2026-06-20 17:49:20 +02:00
Michael Eischer d9d54a505e restic: move Printer interface from internal/ui/progress
Move Printer and NewNoopPrinter to internal/restic so repository does
not have to import the ui packages.
2026-06-20 17:49:20 +02:00
Michael Eischer 0f4236cb39 repository: return unlock func from LockRepo
Drop the Unlocker interface and return the unlock callback directly
from LockRepo, simplifying callers that only need to defer unlock().
2026-06-20 17:48:35 +02:00
Michael Eischer 4d1b9cef63 internal/fileio: extract low-level file I/O from internal/fs
Move TempFile and PreallocateFile into internal/fileio. internal/fs
primarily focuses on converting between data.Node and the actual
filesystem state. Extract the two methods to not pull in unnecessary
dependencies.
2026-06-20 17:48:35 +02:00
Winfried PlappertandMichael Eischer 284daaf0b4 restic list pack snapshotID - create lists of packfiles for a given snapshot as text (#5396)
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-06-20 15:46:44 +00:00
Michael Eischer 980f194360 fs: print missing error if xattr cannot be read (#21896) 2026-06-20 17:11:16 +02:00
Michael Eischer d795988fa8 Misc error handling fixes (#21884)
* forget: fix error handling if snapshot key cannot be marshaled

* backend/b2: correctly close file if too short

* backend/rest: correctly close body on out of bounds read

* backend/sftp: fix file handle leak if chmod for a file fails

* backend/util: fix errorhandling in DefaultDelete test helper

* prune/repair pack: document ignored errors

* selfupdate: improve error handling

* repository: show correct error if zstd decoder cannot be initialized
2026-06-20 17:09:02 +02:00
Michael Eischer 203e595ccb backend/sftp: fix removing files on windows sftp 2026-06-19 23:23:01 +02:00
Michael Eischer 6c67a095dc backend/sftp: fix error reporting of Save method 2026-06-19 23:09:59 +02:00
Michael Eischer 1a9decf03e repository: show correct error if zstd decoder cannot be initialized 2026-06-14 16:52:40 +02:00
Michael Eischer 718f09e02d selfupdate: improve error handling 2026-06-14 16:51:56 +02:00
Michael Eischer 82708ff7f7 prune/repair pack: document ignored errors 2026-06-14 16:51:56 +02:00
Michael Eischer 18c47c5bf9 backend/util: fix errorhandling in DefaultDelete test helper 2026-06-14 16:40:09 +02:00
Michael Eischer faea0d677a backend/sftp: fix file handle leak if chmod for a file fails 2026-06-14 16:39:42 +02:00
Michael Eischer ae8fdb08fa backend/rest: correctly close body on out of bounds read 2026-06-14 16:38:54 +02:00
Michael Eischer 5c8c048c1a backend/b2: correctly close file if too short 2026-06-14 16:38:21 +02:00
Michael Eischer 6b88b072e0 forget: fix error handling if snapshot key cannot be marshaled 2026-06-14 16:37:58 +02:00
Michael Eischer 7d36449ea8 repository: change LoadBlob, LookupBlob and LookupBlobSize to BlobHandles (#21857) 2026-06-14 15:30:00 +02:00
Michael Eischer 71f38d266c ensure reliable cleanup of test repository (#21880) 2026-06-14 14:25:00 +02:00
Michael Eischer 0536e15bbf snapshots: show location name instead of current timezone (#21877) 2026-06-14 14:02:20 +02:00
Michael Eischer 650f658244 repository/index: ensure progress bar cancelation on early index load failure (#21881) 2026-06-14 13:56:24 +02:00
Michael Eischer ae96b2a0f8 mount: fix crash in mountpoint validation (#21879) 2026-06-14 13:55:26 +02:00
Michael Eischer ce9b6ceea1 Merge pull request #21862 from MichaelEischer/lock-cleanup
Move Lock type to repository package and clean it up a bit
2026-06-13 21:46:26 +02:00
Michael Eischer 406dec29a7 repository: remove redundant mutex in checkForOtherLocks
forAllLocks already serializes the callback calls. Still has to create a
copy of checkedIDs to prevent a data race between forAllLocks and the
callback.
2026-06-13 21:37:24 +02:00
Michael Eischer 6fe10a72eb repository: drop mutex from lockHandle 2026-06-13 21:37:06 +02:00
Michael Eischer 1a6d43286a repository: comment cleanups 2026-06-13 21:36:36 +02:00
Michael Eischer 151903d4d4 repository: fix goroutine leak due to delayedCancelContext in tests 2026-06-13 21:35:51 +02:00
Michael Eischer b86568b790 repository: merge Unlocker and lockContext 2026-06-13 21:35:41 +02:00
Michael Eischer a5f3256626 repository: partially deduplicate refresh and refreshStaleLock 2026-06-13 21:33:58 +02:00
Michael Eischer 5989671f87 repository: deduplicate error handling in checkForOtherLocks 2026-06-13 21:33:43 +02:00
Michael Eischer b7f3a1367a repository: add SIGHUP handler only on Unix systems 2026-06-13 21:33:27 +02:00
Michael Eischer 4838b0ae3e repository: cleanup naming of lockCtx 2026-06-13 21:33:19 +02:00
Michael Eischer c87da70af9 repository: separate Lock in-repository from lock handle
Reduce Lock to a pure data transfer object and move the logic to
lockHandle.
2026-06-13 21:33:03 +02:00
Michael Eischer 81b6414c55 repository: hide Lock methods
Unexport lock file methods except String. Lock file operations are only
used within the repository package.
2026-06-13 21:32:13 +02:00
Michael Eischer 637c1cfb66 repository: unexport internal lock file helpers
Unexport UnlockCancelDelay, IsInvalidLock, ErrRemovedLock, NewLock,
StaleLockTimeout and ForAllLocks
2026-06-13 21:31:27 +02:00
Michael Eischer b892b1a150 repository: move lock file handling from restic package 2026-06-13 21:31:23 +02:00
Michael Eischer 7015da44ad restic: extract UidGidInt into separate files
Extract UidGidInt to simplify moving the locking code to the repository.
2026-06-13 21:24:38 +02:00
Michael Eischer 3ee465d363 repository: rename Lock function to LockRepo
Rename `Lock()` to `LockRepo()` to make room for the `Lock` struct.
2026-06-13 21:24:37 +02:00
Michael Eischer 8e11f5747d restic: introduce Counter interface to decouple from ui/progress (#21861)
decouple restic and ui/progress packages
2026-06-13 21:08:18 +02:00
Michael Eischer 22a304af7e Merge pull request #21849 from restic/internal-crypto-package
repository: move crypto package to internal/repository/crypto
2026-06-13 20:33:24 +02:00
Michael Eischer c8a0bc2c5e repository: move crypto package to internal/repository/crypto 2026-06-13 20:05:06 +02:00
Michael Eischer 35e60dc2c7 restic: remove Key() from repository interface
All callers use the concrete Repository type
2026-06-13 20:05:06 +02:00
Michael Eischer 8e93172bf8 cache: remove dependency on crypto package for truncation checks
The cache backend + repository can by now properly recover from damaged
files stored in the cache. Thus, remove the legacy sanity check.
2026-06-13 20:05:05 +02:00
Michael Eischer b94ef4831d repository: add PackBlob.UncompressedCiphertextLength() 2026-06-13 20:05:05 +02:00
Michael Eischer 952b310d62 Merge pull request #21851 from MichaelEischer/misc-cleanups2
Unexport lots of methods and structs
2026-06-13 20:03:18 +02:00
Michael Eischer 3eb5f83db3 fs: more vss related unexports 2026-06-13 19:54:32 +02:00
Michael Eischer d3ef21f870 archiver: unexport BackupTarget type 2026-06-13 19:54:12 +02:00
Michael Eischer 31df7508c4 archiver: unexport Options.ApplyDefaults 2026-06-13 19:53:51 +02:00
Michael Eischer 87c9ed4573 archiver: unexport toNoder 2026-06-13 19:53:31 +02:00
Michael Eischer eedba12968 bloblru: unexport add and get 2026-06-13 19:53:13 +02:00
Michael Eischer 264cfbcff2 data: remove unused Nodes type 2026-06-13 19:52:49 +02:00
Michael Eischer 7f3c9eb749 data: unexport fixTime 2026-06-13 19:52:27 +02:00
Michael Eischer 347cac780d data: unexport osType 2026-06-13 19:52:07 +02:00
Michael Eischer 23d6946fc9 fs: unexport CommandReader type 2026-06-13 19:51:49 +02:00
Michael Eischer 2db654533b fs: unexport Reader type 2026-06-13 19:51:33 +02:00
Michael Eischer f5843a7d97 fs: unexport more vss types 2026-06-13 19:51:14 +02:00
Michael Eischer e1e7fc8fb2 fs: unexport Local and expose via NewLocal 2026-06-13 19:50:49 +02:00
Michael Eischer 1acc19dac5 repository: unexport SearchKey 2026-06-13 19:49:03 +02:00
Michael Eischer 79e92b3bc6 repository: change Unlocker to interface 2026-06-13 19:48:47 +02:00
Michael Eischer 766d9f9f1e repository: unexport openKey 2026-06-13 19:48:31 +02:00
Michael Eischer 131abbb4f0 repository: unexport WarmupJob 2026-06-13 19:48:15 +02:00
Michael Eischer d62e42e620 repository: unexport NewChecker 2026-06-13 19:48:02 +02:00
Michael Eischer 35caceace4 restore: unexport HardlinkIndex.Index and hardlinkKey 2026-06-13 19:12:05 +02:00
Michael Eischer f2ff05f840 Merge pull request #21848 from restic/shrink-repository-interface
move restic.{Blob,Blobs,PackedBlob} types to `./internal/repository/pack` package
2026-06-13 19:11:33 +02:00
Michael Eischer c062a78dcd repository: move Blob, Blobs and PackedBlob to pack package
This removes them from the public interface. The latter now only
provides the PackBlob interface, without being bound to the type used
internally by the pack package.
2026-06-13 18:58:37 +02:00
Michael Eischer 35af104749 restic: change LookupBlob to return []PackBlob 2026-06-13 17:54:58 +02:00
Michael Eischer ccb5ae1592 restic: change ListBlobs to return PackBlob
PackBlob is a limited interface that only exposes a part of the
information provided by PackedBlob. Most of the changes are switches
from direct value lookups to the interface methods, with a few larger
changes to let the tests still work.
2026-06-13 17:54:38 +02:00
Michael Eischer 97f1e99ed9 restic: add PackBlob interface and implement it on PackedBlob
The PackBlob interface will allow hiding details from the public
interface, in particular, the offset of a blob within a pack file.
2026-06-13 17:54:18 +02:00
Michael Eischer c060c317d3 repository: unexport listPacksFromIndex
`ListPacksFromIndex` only has repository-internal callers left (besides
test code).
2026-06-13 17:54:03 +02:00
Michael Eischer a9e0b46358 restic: list pack header via ListPackHandles
Replace ListPack with ListPackHandles so callers only receive blob
handles from pack headers, not layout fields.
2026-06-13 17:50:21 +02:00
Michael Eischer 8169814b38 restic: switch LoadBlobsFromPack to BlobHandles
LoadBlobsFromPack now resolves the handles to Blobs. Repository internal
code can still use the Blob-based method.

The loader used in the filerestorer test now has to implement sorting
the blobs by offset itself as it no longer has access to the repository-internal
dataypes.
2026-06-13 17:50:21 +02:00
Michael Eischer f186e1e458 repository: require *Repository for CopyBlobs
Prepare `CopyBlobs` to allow access to unexported methods of the
Repository struct. This requires changing the test to inject the number
of backend connections via a wrapped backend instead of a wrapped
repository.
2026-06-13 17:50:21 +02:00
Winfried PlappertandMichael Eischer 0938f52f38 tests - more test cases for internal/repository/check.go (#21830)
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-06-13 15:35:48 +00:00
Michael Eischer 9f9a3472aa Merge pull request #21850 from MichaelEischer/misc-cleanups
Cleanup `ui/*` package and minor cleanups in `test` and `walker`
2026-06-13 17:12:14 +02:00
Michael Eischer 14f86a462a stats: refactor ui progress printer into ui/stats 2026-06-13 17:00:11 +02:00
Michael Eischer 825d67ba4b backup,restore: move CalculateProgressInterval call to their ui package 2026-06-13 16:53:57 +02:00
Michael Eischer 3b8b77e54d test: remove unused exports 2026-06-13 16:53:57 +02:00
Michael Eischer 0bbfb072af ui/progress: unexport NoopPrinter and add New* function 2026-06-13 16:53:57 +02:00
Michael Eischer e8ed2434cd ui: move NewProgressPrinter to ui/progress.NewTerminalPrinter 2026-06-13 16:53:54 +02:00
Michael Eischer c04f3e9d6c ui: unexport json and text progress 2026-06-13 16:53:30 +02:00
Michael Eischer 37fdbe5779 ui: inline Message into progressPrinter 2026-06-13 16:53:30 +02:00
Michael Eischer 47328afb2e ui/progress: remove unused test helper 2026-06-13 16:53:30 +02:00
Michael Eischer e6d054d896 walker: remove empty testing.go 2026-06-13 16:53:30 +02:00
Michael Eischer fc81a0b6ad ui/terminal: unexport Terminal type 2026-06-13 16:53:30 +02:00
Michael Eischer dee28f5b0e ui/terminal: unexport New function 2026-06-13 16:53:30 +02:00
Michael Eischer 2d02a1ad39 doc: clarify forget --prune --json output (#21878) 2026-06-13 16:47:15 +02:00
Michael Eischer bae49d00ee stats: hide progress bar for json output (#21871) 2026-06-13 15:13:26 +02:00
e5dba15367 Json prune (#5239)
Co-authored-by: Alexander Weiss <alex@weissfam.de>
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-06-13 10:38:57 +00:00
Michael Eischer bf56d71b09 Merge pull request #21876 from MichaelEischer/cleanup-mount-validation
mount: refactor mountpoint validation
2026-06-12 23:34:44 +02:00
Michael Eischer e94ec65efb mount: unify mountpoint validation error messages 2026-06-12 22:30:53 +02:00
Michael Eischer 49f9e67520 mount: factor out mountpoint validation into helper 2026-06-12 22:29:45 +02:00
Michael Eischer 3a4b0e3b8c Merge pull request #5348 from zmanda/fix-gh-5234-prevent-mount-command-over-repository
mount: prevent mounting over repository
2026-06-12 22:27:50 +02:00
Michael Eischer abfc9bbdff Merge pull request #21868 from MichaelEischer/fix-zero-sized-blobs
repository: fix zero-sized blobs in v2 repos
2026-06-11 20:43:38 +02:00
Michael Eischer 784812361e Merge pull request #21858 from MichaelEischer/unexport-backends
Unexport several backend types
2026-06-10 22:51:32 +02:00
Michael Eischer c745f810b3 backend/cache: use backend types not restic types (#21860) 2026-06-10 22:45:39 +02:00
Michael Eischer 721411e04c backend/azure/gs/s3: remove unused Path() method 2026-06-10 22:37:07 +02:00
Michael Eischer b07ff6cd34 backends: remove unused SetListMax method
It was never used. Remove the dead code.
2026-06-10 22:37:07 +02:00
Michael Eischer 8b3bbb527c backend/s3: unexport 2026-06-10 22:37:07 +02:00
Michael Eischer 4a2d8e04aa backend/rclone: unexport 2026-06-10 22:37:07 +02:00
Michael Eischer a36488b706 backend/gs: unexport 2026-06-10 22:37:07 +02:00
Michael Eischer cfb506a77a backend/cache: unexport 2026-06-10 22:37:07 +02:00
Michael Eischer a15b1579ff Merge pull request #21846 from restic/repository-cleanups
Cleanup repository package
2026-06-10 22:36:04 +02:00
Michael Eischer ff95080f36 restic: move test helpers and drop unused JSONUnpackedLoader 2026-06-10 22:20:28 +02:00
Michael Eischer 119bb9d9a8 repository: require *Repository for ExaminePack
The function wouldn't work with a different Repository implementation
anyways.
2026-06-10 22:20:28 +02:00
Michael Eischer 8c6ee42d17 debug: move DumpPacks into repository package
Processing pack file internals belongs into the repository package.
2026-06-10 22:20:28 +02:00
Michael Eischer ccddc1914d repository: rename PackError to ErrPackMetadata 2026-06-10 22:20:28 +02:00
Michael Eischer 4bc5eca7ea repository: merge check.go into checker.go 2026-06-10 22:20:28 +02:00
Michael Eischer 17ff3aa5f9 Merge pull request #21841 from MichaelEischer/isolate-repository
prevent imports of repository internals
2026-06-10 22:19:24 +02:00
Michael Eischer 5683180a3b upgrade compress library 2026-06-10 22:03:56 +02:00
Michael Eischer 0fc7444e32 repository: fix zero-sized blobs in v2 repos 2026-06-10 22:03:40 +02:00
Michael Eischer 81571775d5 fix version set by helper after release (#21865) 2026-06-09 22:43:18 +02:00
Alexander Neumann 16b8b8cda0 Set development version for 0.19.0 2026-06-09 18:49:09 +02:00
Alexander Neumann 12875cc48e Add version for 0.19.0 2026-06-09 18:49:04 +02:00
Alexander Neumann 8c37a3983a Update manpages and auto-completion 2026-06-09 18:49:04 +02:00
Alexander Neumann d718c4cf20 Generate CHANGELOG.md for 0.19.0 2026-06-09 18:48:35 +02:00
Alexander Neumann 60448342b3 Prepare changelog for 0.19.0 2026-06-09 18:48:35 +02:00
Alexander Neumann 4f59ed8806 Merge pull request #21863 from MichaelEischer/downgrade-compress
Downgrade compress library due to regression with zero-sized blobs
2026-06-09 18:40:30 +02:00
Michael Eischer 522efd1175 downgrade compress library due to regression with zero-sized blobs
while this should only affect test cases better be safe than sorry.
2026-06-08 22:51:47 +02:00
rawtaz f01359ff92 doc: Polish changelogs (#21847) 2026-06-05 22:30:46 +02:00
rawtaz 0b3c0fc222 Merge pull request #21842 from restic/polish-changelogs
Polish changelogs
2026-06-05 00:33:38 +02:00
Winfried Plappert ed571c8d12 Docs - Diving into a Repository - create html links across the chapter (#21839) 2026-06-02 22:42:43 +02:00
Michael Eischer 0ddd98e03b stats: stop progress bar before printing stats (#21843) 2026-06-02 22:37:46 +02:00
Michael Eischer cebc5c8957 polish changelogs 2026-06-01 22:10:27 +02:00
dependabot[bot] 724b7dc231 build(deps): bump google.golang.org/api from 0.279.0 to 0.282.0 (#21836)
Signed-off-by: dependabot[bot] <support@github.com>
2026-06-01 19:39:49 +00:00
Michael Eischer 2141fd83a9 checker: increase timeout for blob type confusion test (#21831) 2026-06-01 21:29:52 +02:00
dependabot[bot] 6693611497 build(deps): bump github.com/minio/minio-go/v7 from 7.1.0 to 7.2.0 (#21838)
Signed-off-by: dependabot[bot] <support@github.com>
2026-06-01 21:26:05 +02:00
dependabot[bot] 0e9446277d build(deps): bump cloud.google.com/go/storage from 1.62.1 to 1.62.2 (#21837)
Signed-off-by: dependabot[bot] <support@github.com>
2026-06-01 21:25:14 +02:00
dependabot[bot] b6bfa13f5f build(deps): bump github.com/Azure/azure-sdk-for-go/sdk/storage/azblob from 1.6.4 to 1.7.0 (#21835)
Signed-off-by: dependabot[bot] <support@github.com>
2026-06-01 21:24:40 +02:00
dependabot[bot] 88aa8132ae build(deps): bump actions/checkout from 4 to 6 (#21834)
Signed-off-by: dependabot[bot] <support@github.com>
2026-06-01 21:23:28 +02:00
dependabot[bot] bff8acb2d9 build(deps): bump docker/login-action from 4.0.0 to 4.2.0 (#21833)
Signed-off-by: dependabot[bot] <support@github.com>
2026-06-01 21:22:35 +02:00
dependabot[bot] 4ae2e26021 build(deps): bump the golang-x-deps group with 3 updates (#21832)
Signed-off-by: dependabot[bot] <support@github.com>
2026-06-01 21:22:25 +02:00
Michael Eischer 7d25ca9d67 repository: omit unused headerSize from ListPack() 2026-05-31 22:53:00 +02:00
Michael Eischer cc546b71e3 debug: move code requring internal access to repository package 2026-05-31 22:48:38 +02:00
Michael Eischer 3cb49556f5 repair index: replace full index handling integration test with unit test 2026-05-31 22:39:16 +02:00
Michael Eischer f625190393 check: simplify index damage test 2026-05-31 22:19:15 +02:00
Michael Eischer 620f5986f8 list index: use helper in repository package 2026-05-31 22:14:01 +02:00
Michael Eischer 49c7364e79 add golangci-lint rule to prevent imports of repository internals 2026-05-31 18:20:37 +02:00
MetalSporkandMichael Eischer 042feb2b7f docs: expand restic cat documentation (#5679)
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-05-31 15:46:45 +00:00
Michael Eischer 474c094cac Merge pull request #21817 from eyupcanakman/fix/sftp-dir-permissions
sftp: Use mode 0700 for repository directories
2026-05-31 16:40:17 +02:00
Winfried PlappertandMichael Eischer 7566069bf3 docs: amend restic find documentation (#21818)
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-05-31 16:31:44 +02:00
Michael Eischer 53de77ea1a Merge pull request #21828 from MichaelEischer/fix-split-pack-index
repository: repair index: correctly handle split index entries
2026-05-31 16:30:49 +02:00
Michael Eischer a54ac48f60 restic: test that sorting nil blobs slices works 2026-05-31 16:22:58 +02:00
Michael Eischer 91a6e74fd5 repository: test split index handling in index rewrite 2026-05-31 16:22:58 +02:00
Michael Eischer e666980cec add changelog for split pack index handling 2026-05-31 16:22:58 +02:00
Michael Eischer 78b3411076 check: consider split pack index entries as repository damage 2026-05-31 15:58:33 +02:00
Michael Eischer 5b39ad861e repository: repair index: correctly handle split index entries
In restic <0.10.0, it was possible that the blobs of a pack file were
split across multiple indexes. `MasterIndex.Rewrite` however assumed
that each an index always contains the full description of a pack file.
Therefore, further index entries for a pack were filtered out as
duplicates. Now, the code also checks the blobs contained in the index
entry while filtering out duplicates.
2026-05-31 15:58:29 +02:00
Michael Eischer f86307d223 Merge pull request #21827 from MichaelEischer/fix-pack-repair
repair packs: correctly handle packs with missing/incomplete index entry
2026-05-31 15:57:50 +02:00
Michael Eischer 77a6bf3bb7 Merge pull request #21797 from MichaelEischer/always-include-explicit-targets
backup: prevent exclude of backup targets
2026-05-31 15:42:26 +02:00
Michael Eischer c95ef18afb repository: fix error handling in repair pack if blob upload fails 2026-05-31 15:40:15 +02:00
Michael Eischer 4c23c5946f add repair packs changelog 2026-05-31 15:40:15 +02:00
Michael Eischer 640b2489f6 repository: repair pack: test handling of not indexed packs 2026-05-31 15:40:15 +02:00
Michael Eischer 6a3f447327 repository: repair pack: correctly handle incomplete index 2026-05-31 15:40:15 +02:00
Michael Eischer ce24640d75 backup: prevent hang using --stdin-from-command if upload fails (#21829) 2026-05-31 15:27:05 +02:00
Michael Eischer 7e8f9a9221 document excludes for explicit backup sources 2026-05-31 15:24:43 +02:00
Eyüp Can Akman 62cf574fd8 sftp: Use mode 0700 for repository directories
The SFTP backend created repository directories with pkg/sftp's Mkdir
and MkdirAll, which take no mode argument, so the directories inherited
the SFTP server's umask instead of the 0700 used for local
repositories. Set the mode of each directory the backend creates.
2026-05-31 12:40:26 +03:00
Michael Eischer 32bcd92f60 archiver: test that explicit backup paths ignore excludes 2026-05-30 22:30:30 +02:00
Michael Eischer 02cf8e5f23 backup: prevent exclude of backup targets
Track backup targets explicitly specified by the user and prevent
excluding them. This for example ensures that `restic backup
--exclude-if-present .git /home/user/data` backs up the `data` folder
even if there is a `.git` folder in `/home/user`.

Note that this does not suffice for commands like `restic backup --exclude data /home/user/data`
as the exclude pattern will still match every single file within `data`.
2026-05-30 22:30:30 +02:00
Yaroslav HalchenkoandClaude Code 2.1.142 / Claude Opus 4.7 451cc6c048 Add codespell support with configuration and fixes (#21807)
Co-authored-by: Claude Code 2.1.142 / Claude Opus 4.7 <noreply@anthropic.com>
2026-05-30 20:15:13 +00:00
Michael Eischer c221cd06ad repository: forget id of unreadable packs on index rebuild (#21826) 2026-05-30 22:09:33 +02:00
Michael Eischer e7d3a4ae51 repository: repair pack: move pack reupload to helper 2026-05-30 10:15:16 +02:00
Michael Eischer 2a95591b48 index: replace custom EachByPackResult datatype 2026-05-30 10:11:18 +02:00
Michael Eischer c669cc7a7d introduce restic.Blobs type with sort method 2026-05-30 10:10:39 +02:00
Michael Eischer 2802bec8b9 Polish changelogs (#21805) 2026-05-29 21:06:29 +02:00
Michael Eischer f000da3b35 Return helpful error if subfolder syntax fails on Windows (#21813) 2026-05-20 22:55:01 +02:00
Michael Eischer dd4f1f06a1 Merge pull request #21810 from MichaelEischer/cmd-doc-typos
Fix command doc typos and update help for check/rewrite
2026-05-20 22:54:40 +02:00
Michael Eischer 77f6795b32 doc: update embedded help output 2026-05-20 22:46:11 +02:00
Michael Eischer 850ab61cdf key: include full command name in subcommand descriptions 2026-05-20 22:46:11 +02:00
Michael Eischer df03e8a0ec self update: remove not possible exit codes 2026-05-20 22:46:11 +02:00
Michael Eischer 9299c45818 fix typos in cmd descriptions 2026-05-20 22:46:11 +02:00
Michael Eischer 2b72f3eb42 find: fix placement of exit status section 2026-05-20 22:46:11 +02:00
Michael Eischer 496ea804a6 check/dump/mount/repair/rewrite: update command description 2026-05-20 22:45:52 +02:00
Michael Eischer ccfb31b5fa filter: correctly stop pattern validation on first invalid part (#21812) 2026-05-20 22:42:26 +02:00
Michael Eischer a639b8d711 Merge pull request #21811 from MichaelEischer/misc-fixes
Address various code smells, outdated comments and nits
2026-05-20 22:38:36 +02:00
Michael Eischer de55280003 Merge pull request #21809 from MichaelEischer/doc-typos
doc: fix typos, unify section heading style and minor additions
2026-05-20 22:32:59 +02:00
Winfried PlappertandMichael Eischer 990329013e prune more aggresively (#21803)
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-05-16 15:49:08 +00:00
Michael Eischer 10645ccd2a fix comment and variable name typos 2026-05-16 17:05:33 +02:00
Michael Eischer fa1a318780 fs: drop outdated comment regarding UNC paths on Windows 2026-05-16 17:05:33 +02:00
Michael Eischer 8b6eff5a47 filter: fix comment for validatePatterns 2026-05-16 17:05:33 +02:00
Michael Eischer 770ec1e25a doc: clarify ** usage 2026-05-16 17:01:52 +02:00
Michael Eischer febdb8b564 find: use proper sentinel error to terminate search 2026-05-16 15:35:48 +02:00
Michael Eischer 91c2aefbe1 Document openWithReadLock usage of read-only backend mode 2026-05-16 15:35:48 +02:00
Michael Eischer 3cc592463f Don't lower case case-insensitive patterns in place 2026-05-16 15:35:42 +02:00
Michael Eischer c04a1d857d backend/retry: debug log correct error on failed file removal 2026-05-16 15:35:42 +02:00
Michael Eischer bd945df2ea archiver: note that fileSaver.Save expects non-blocking callbacks 2026-05-16 15:35:42 +02:00
Michael Eischer 5105015f5d check: filter packs while holding blobRefs lock
Not an actual problem with the current usage. But for consistency always
take the lock when interacting with blobRefs.
2026-05-16 15:35:42 +02:00
Michael Eischer d4397926cc restorer: drop redundant nil check 2026-05-16 15:35:42 +02:00
Michael Eischer 5caa33e7b9 repository/pack: prevent packer usage after error
In-depth hardening to prevent packer reuse after an error.
2026-05-16 15:35:42 +02:00
Michael Eischer ef750c4c5d archiver: reuse buffer if reading from file failed 2026-05-16 15:35:42 +02:00
Srigovind Nayak e1e36ed848 doc: note that mountpoint must not overlap the repository
Document the new restriction added so users encountering the error
message have a reference, and so the constraint is visible before they
hit it.
2026-05-16 18:07:42 +05:30
Srigovind Nayak a37010a825 chore: update changelog for issue 5234 2026-05-16 18:06:14 +05:30
Srigovind Nayak a0d7745e8b mount: refuse mountpoints that overlap the local repository
Mounting a local repository onto its own directory caused the FUSE
  server to read its own backend files through the mount it had just
  created, deadlocking the kernel. `umount` then reported "Device or
  resource busy" and recovery required a reboot that took several
  minutes. The same shape occurs when the mountpoint is nested inside
  the repository directory, or when the repository directory is nested
  inside the mountpoint.

  The mount command now resolves both paths via filepath.Abs and
  filepath.EvalSymlinks and refuses with a fatal error if either path
  equals or contains the other. The check runs before the repository
  lock is acquired so an overlap fails fast. Only the local backend is
  checked; remote backends cannot shadow the mountpoint directory.
2026-05-16 18:03:49 +05:30
Michael Eischer 3148494a92 archiver: check chunker error before updating the node
This is actually just a cosmetic issue as chunk.Length is 0 if the
chunker returned an error.
2026-05-16 12:03:43 +02:00
Michael Eischer e212076f71 doc: correctly use RST backticks
RST uses double backticks for inline code unlike the single backticks in
Markdown.
2026-05-15 23:37:54 +02:00
Michael Eischer b16f0bf410 doc: use sentence case for section headings 2026-05-15 23:37:54 +02:00
Michael Eischer 75f92f22d9 doc: unify section headings to gerund phrases
Use -ing headings for sections across the user manual.
2026-05-15 23:37:54 +02:00
Michael Eischer 4c9a07e9c8 doc: stick to second-persion "you" in user docs
Replace usages of `we`, `one` and "it is possible" with the mainly used `you`.
2026-05-15 23:13:29 +02:00
Michael Eischer 5bc7398e5e doc: sync S3 path in tutorial with S3 path in reference
Regional endpoints should be preferred. Omitting `https://` defaults to
https.
2026-05-15 22:55:22 +02:00
Michael Eischer 07bb05deaa doc: add RESTIC_FROM_* environment variables to scripting section 2026-05-15 22:45:08 +02:00
Michael Eischer 4b52ef9a97 doc: correct description of forget --tag 2026-05-15 22:44:27 +02:00
Michael Eischer bd7f3483ac doc: clarify repository setup for copy 2026-05-15 22:43:09 +02:00
Michael Eischer f6c8751575 doc: consistency fixes 2026-05-15 22:42:29 +02:00
Michael Eischer 2419c03177 doc: fix several typos 2026-05-15 22:25:51 +02:00
Michael Eischer b7d8c98214 docs: clarify backup step in troubleshooting guide (#21802) 2026-05-15 21:23:48 +02:00
Michael Eischer 265d070255 ui: Fix data race and minor API cleanup (#21801) 2026-05-15 21:23:24 +02:00
Paulo SaraivaandPaulo Saraiva 6de6cc6c75 Show progress for restic stats (#5705)
Co-authored-by: Paulo Saraiva <paulo.saraiva@cern.ch>
2026-05-15 20:31:20 +02:00
Michael Eischer 8abbc3703d doc: update embedded help output and misc typos (#21804) 2026-05-15 20:21:04 +02:00
7acab7b1a9 add example for "Pulling a Backup with HTTP over a ssh tunnel" (#5504)
Co-authored-by: Leo R. Lundgren <leo@finalresort.org>
Co-authored-by: Michael Eischer <michael.eischer@fau.de>
2026-05-14 12:52:33 +00:00
Michael Eischer 5d70bf9f10 Merge pull request #5643 from kjetilho/doc-restore
Improve documentation for restore
2026-05-14 14:51:45 +02:00
Michael Eischer 6c63c1c244 partially modernize restore command output 2026-05-14 13:43:54 +02:00
Michael Eischer acc95531a4 docs/restore: clarify --path option example, subfolder syntax and --delete option 2026-05-14 13:42:33 +02:00
Michael Eischer bf14a94600 Merge pull request #21784 from jtru/fuse-mount-hardlink-count
mount: Ensure a hard link count > 0 for all files
2026-05-14 11:25:20 +02:00
Michael Eischer 4547fd7b18 fuse: tweak comment 2026-05-14 11:18:16 +02:00
Michael Eischer 65d90641bb add changelog for windows hardlink count fix 2026-05-14 11:18:16 +02:00
Michael Eischer 7878485eec Merge pull request #5648 from dgkmd/feature/statusbar
ui: don't rewrite unchanged lines in status bar
2026-05-14 10:50:01 +02:00
Michael Eischer d494e37dc1 ui/termstatus: reorder findUnchangedLines function 2026-05-14 10:42:13 +02:00
Michael Eischer 59697213f9 ui/termstatus: cleanup test code 2026-05-14 10:42:13 +02:00
Michael Eischer df2d65bb88 ui/termstatus: test skipping of unchanged lines 2026-05-14 10:42:13 +02:00
Michael Eischer bd8aad3b9b ui/termstatus: deduplicate error handling 2026-05-14 10:42:13 +02:00
Michael Eischer cf34130a05 ui/termstatus: simplify status tracking 2026-05-14 10:42:13 +02:00
Donggyu Kim e33bcede2f terminal: Do not write unchanged status lines
Check if each line of status is changed, and write
the line to the terminal only if it has changed
2026-05-14 10:42:13 +02:00
Michael Eischer 4f781b69f9 add hardlink test 2026-05-13 22:29:34 +02:00
dependabot[bot] ff575a978d build(deps): bump google.golang.org/api from 0.278.0 to 0.279.0 (#5734)
Signed-off-by: dependabot[bot] <support@github.com>
2026-05-13 20:27:31 +00:00
Adrian Mastronardi 9a0432a5d7 docs: clarify double-asterisk wildcard behavior in exclude patterns (#5726) 2026-05-13 20:25:36 +00:00
Michael Eischer f3854cf299 Merge pull request #21796 from restic/go-1.25
Bump minimum go version to 1.25 & update dependencies
2026-05-12 18:56:09 +02:00
Michael Eischer f3ca1a5c13 Merge pull request #21798 from MichaelEischer/fix-windows-test-flake
windows: try to fix flaky tests
2026-05-12 18:53:31 +02:00
Michael Eischer a213daef29 windows: improve randomness of temp file name
Creating two temporary files at nearly the same time could result in a
filename collision.
2026-05-11 22:50:48 +02:00
Michael Eischer e3f065ad54 windows: ignore temporary access denied error on temp file creation 2026-05-11 22:42:51 +02:00
Michael Eischer 7ee77133fc Merge pull request #21781 from mattxtaz2/master 2026-05-10 22:20:24 +02:00
Michael Eischer 1cdb0a9c96 add changelog for key passwd fix 2026-05-10 22:13:16 +02:00
Michael Eischer f8afd4ed04 key passwd: test that user and host flags are handled 2026-05-10 22:13:16 +02:00
Michael Eischer 4a63f7fd13 Merge pull request #5701 from jylenhof/master 2026-05-10 21:31:15 +02:00
Michael Eischer 10475c9841 update all direct dependencies 2026-05-10 18:07:18 +02:00
Michael Eischer 5608e86cdb Merge pull request #5699 from MichaelEischer/dump-with-relative-paths 2026-05-10 17:54:08 +02:00
Michael Eischer bdb2196378 Bump golangci version 2026-05-10 17:53:29 +02:00
Michael Eischer 4c94678d7d fix linter and compilation issues 2026-05-10 17:53:29 +02:00
Michael Eischer a241652787 windows: fix hang while reading from directory 2026-05-10 17:53:29 +02:00
Michael Eischer a1c870c675 Simplify smoke test debugging 2026-05-10 17:53:08 +02:00
Michael Eischer 6080c784e4 Bump minimum go version to 1.25 2026-05-10 17:53:08 +02:00
Michael Eischer ed418d8d60 document that switching between relative and absolute paths prevents change detection 2026-05-10 17:40:55 +02:00
Michael Eischer 93357440da doc: describe effects of relative paths on snapshot structure 2026-05-10 17:34:42 +02:00
Michael Eischer 5b7df8135e Merge pull request #5713 from MichaelEischer/index-optimization 2026-05-10 01:09:06 +02:00
Michael Eischer adce279d04 add changelog 2026-05-10 00:38:01 +02:00
Michael Eischer 5c935e71fa index: also preallocate hashed array tree 2026-05-10 00:35:17 +02:00
Michael Eischer 934c615e51 index: support index preallocation 2026-05-10 00:35:17 +02:00
Michael Eischer ba638b6602 indexmap: use bloom filter to drastically speed up check for unknown blobs
Only in use on 64-bit systems. Use the upper 28bits of the id of an
index entry as bloom filter. This allows skipping the index entry
traversal most of the time if an id is not stored in the hashmap.

The bloom filter embedded in the index entry id is check each time
before following a reference to an index entry. This further reduces
the risk of false positives. The bloom filter itself is basically for
free on modern CPUs.

The main performance cost of checking for unknown blobs in the index are
the essentially random RAM accesses for the initial bucket lookup as
well as following the next pointer in the index entries. With the bloom
filter most of the time only the initial bucket lookup is necessary.

This speeds up checking for unknown blobs by a factor 5 (!), while
having no effect on the lookup of known blobs:

$ benchstat no-bloom with-bloom
name                old time/op  new time/op  delta
IndexHasUnknown-16  49.0ms ± 2%   9.9ms ± 7%  -79.70%  (p=0.000 n=10+10)
IndexHasKnown-16    48.0ms ± 3%  47.9ms ± 3%     ~     (p=0.968 n=10+9)

This bloom filter parameters m=28 k=1 were derived empirically, while
also leaving sufficient room for very large repositories. Before this
commit, the final merge index step took roughly 1 second per million
index entries. With the chosen bloom filter parameters, it would
currently take 19 hours to just merge such an index. It is safe to
assume that such large repositories don't exist.

Comparison with other parameter sets:

$ m=28 k=1 versus m=32 k=1
name                old time/op  new time/op  delta
IndexHasUnknown-16  49.0ms ± 2%   9.7ms ±16%  -80.17%  (p=0.000 n=10+10)
IndexHasKnown-16    48.0ms ± 3%  48.4ms ± 3%     ~     (p=0.436 n=10+10)

$ m=28 k=1 versus m=24 k=1
name                old time/op  new time/op  delta
IndexHasUnknown-16  49.0ms ± 2%  10.8ms ±13%  -77.90%  (p=0.000 n=10+10)
IndexHasKnown-16    48.0ms ± 3%  47.9ms ± 3%     ~     (p=0.684 n=10+10)

$ m=28 k=1 versus m=28 k=2
name                old time/op  new time/op  delta
IndexHasUnknown-16  49.0ms ± 2%  24.9ms ± 5%  -49.27%  (p=0.000 n=10+10)
IndexHasKnown-16    48.0ms ± 3%  48.0ms ± 4%     ~     (p=1.000 n=10+10)

`k=2` outright wrecks the performance. This is most likely the case as
it performs worse on longer index entry chains, which also happen to be
the expensive ones to process.

`m=32` yields diminishing returns, while getting within an order of
magnitude of the largest known restic repositories.

Design alternatives:

In principle it would be possible to add a single large bloom filter
instead of embedding them in the index entry ids. However, this bloom
filter would necessarily incur additional random memory accesses and
thus slow things down overall.
2026-05-10 00:35:17 +02:00
Michael Eischer 320f709fbc index: modernize masterindex tests
`b.Loop()` drastically shortens benchmark execution times for tests with
an expensive initialization phase as it only has to happen once now.
2026-05-10 00:35:17 +02:00
Michael Eischer e33ed5d0c1 index: make tests more representative 2026-05-10 00:35:17 +02:00
Michael Eischer 39084a912e Merge pull request #5700 from MichaelEischer/err-invalid-env 2026-05-10 00:18:40 +02:00
jylenhof 24c3b73f7c doc(installation): add mise alternative installation method
Signed-off-by: jylenhof <jygithub@lenhof.eu.org>
2026-05-08 12:20:18 +02:00
Michael Eischer f5ab39b33d mount: avoid duplicate index loading (#5720) 2026-05-07 22:59:55 +02:00
Michael Eischer ca555897f2 Add incremental index loading changelog 2026-05-07 22:52:23 +02:00
Michael Eischer 4c0dc9e202 index: support incremental index loading
Do not require a full index reload if only a few additional index files
have been added. This can drastically speed up loading the index in the
mount command.
2026-05-07 22:52:03 +02:00
Michael Eischer b24d210b45 mount: load mount root before reporting readiness 2026-05-07 22:42:03 +02:00
dependabot[bot] 3dcd60d979 build(deps): bump docker/metadata-action from 5 to 6 (#21764)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-07 22:31:56 +02:00
dependabot[bot] fbf6fad74f build(deps): bump github.com/klauspost/compress from 1.18.3 to 1.18.4 (#5733)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-07 22:31:34 +02:00
dependabot[bot] 302e713c5d build(deps): bump github.com/elithrar/simple-scrypt from 1.4.0 to 1.4.1 (#5736)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-07 22:29:50 +02:00
dependabot[bot] 2ef86a8410 build(deps): bump docker/setup-buildx-action from 3 to 4 (#21763)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-07 22:16:29 +02:00
dependabot[bot] 760610a29a build(deps): bump docker/build-push-action from 6 to 7 (#21765)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-07 22:16:22 +02:00
dependabot[bot] 48d7f232c2 build(deps): bump docker/setup-qemu-action from 3 to 4 (#21766)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-07 22:15:32 +02:00
dependabot[bot] 25e72d3259 build(deps): bump docker/login-action from 3.7.0 to 4.0.0 (#21768)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-07 22:15:23 +02:00
Rohan Santhosh KumarandCodex 90ce78dbaa docs: fix Nix installation typo (#21772)
Co-authored-by: Codex <codex@openai.com>
2026-05-07 22:13:20 +02:00
Johannes Truschnigg 461bddb0e8 mount: Ensure a hard link count > 0 for all files
When using `restic mount` to serve a repository via a POSIX host's file
system, all files backed up from Windows systems will show up on the
mounting host with a (hard)link count of 0.

While this is not a problem in general and most programs do not even
register this strange value, some others (such as Samba's smbd(8)) will
go the extra mile and check a file's stat() results for various
properties (such as a positive non-zero link count), and refuse to
operate if any of the reported values appear off.

Since other inode properties absent from non-POSIX backup sources are
also "faked up" (e.g., the inode number) during mount and work fine in
general, the chances of this change to be in any way harmful are
probably rather slim.
2026-04-19 13:44:18 +02:00
Matt 0f8c28aee4 Add opts.Username, opts.Hostname to AddKey in the "key passwd" command
so that --user and --host flags work
2026-04-16 19:15:44 +01:00
rawtaz 1807d269cd Merge pull request #21769 from Rohan5commit/fix-participating-doc-typo-20260401
Fix a typo in the contributing docs
2026-04-01 12:19:59 +02:00
Codex b1e9811ffc Fix a typo in the contributing docs 2026-04-01 10:32:50 +08:00
Winfried Plappert 54347eb6fa Enhancement: restic find - more integration tests (#5672) 2026-02-26 21:52:26 +01:00
Michael Eischer 271d622823 Merge pull request #5725 from AdrianMastronardi/fix/4258-document-backup-progress-bar 2026-02-26 21:29:29 +01:00
Michael Eischer 541eb5cfd8 clarify changelog expectations (#5721) 2026-02-25 20:36:07 +00:00
Winfried Plappert f9b63050eb Bugfix: `restic find --pack <tree-pack>` did not produce output for tree packs (#5664) 2026-02-25 21:24:31 +01:00
rawtaz 49c988be07 Merge pull request #5724 from AdrianMastronardi/fix/5218-dead-link-installation-docs
docs: remove outdated CentOS 6/7 installation instructions
2026-02-24 12:08:32 +01:00
Adrian Mastronardi 9b1d45935a docs: remove version-specific references from RHEL/CentOS instructions 2026-02-24 01:02:42 +01:00
Adrian Mastronardi 102ea6da2b docs: document backup progress bar fields (#4258) 2026-02-24 00:06:38 +01:00
Adrian Mastronardi 4e71921a17 docs: remove outdated CentOS 6/7 installation instructions (#5218) 2026-02-23 23:15:49 +01:00
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 TruschniggandMichael Eischer 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 Eischerandudf2457 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 EischerandIlya Grigoriev 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
Michael Eischer 5be6d9c73f fail of RESTIC_READ_CONCURRENCY or RESTIC_COMPRESSION are invalid 2026-02-01 15:57:07 +01:00
gunarandMichael Eischer 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](https://github.com/docker/login-action/compare/5e57cd118135c172c3672efd75eb46360885c0ef...c94ce9fb468520275223c153574b00df6fe4bcc9)

---
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 PlappertandMichael Eischer 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
Kjetil Torgrim Homme ee099e4662 doc: restore: simplify restore target name
the suffix "-work" is visually distracting since it copies a part of the
directory path being restored.  this makes it easy to gloss over where
the "work" string actually comes from.  as a bonus, it makes the examples
slightly shorter to read.
2025-12-05 18:07:11 +01:00
Kjetil Torgrim Homme 655e527765 doc: restore: be clearer about resulting filenames in restore 2025-12-05 18:04:46 +01:00
Kjetil Torgrim Homme d34ba9b6bd doc: restore: explain how --delete and --exclude work together 2025-12-05 17:59:56 +01:00
Kjetil Torgrim Homme 0673b58d7c doc: restore: explain explicitly effect of specifying snapshot:subfolder
The effect could be read from the examples, but it was easy to miss.
2025-12-05 17:50:53 +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 NandAneesh Nireshwalia 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 PlappertandMichael Eischer 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 SaraivaandPaulo 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
ferringbandMichael Eischer 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
DoS007andMichael Eischer 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 NayakandMichael Eischer 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 PlappertandMichael Eischer 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](https://github.com/docker/login-action/compare/184bdaa0721073962dff0199f1fb9940f07167d1...5e57cd118135c172c3672efd75eb46360885c0ef)

---
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](https://github.com/docker/login-action/compare/74a5d142397b4f367a81961eba4e8cd7edddf772...184bdaa0721073962dff0199f1fb9940f07167d1)

---
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
gregosterandGreg Oster 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 GrigorievandMichael Eischer 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](https://github.com/docker/login-action/compare/9780b0c442fbb1117ed29e0efdff1e18412f7567...74a5d142397b4f367a81961eba4e8cd7edddf772)

---
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
gregosterandGreg Oster 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](https://github.com/docker/login-action/compare/74a5d142397b4f367a81961eba4e8cd7edddf772...184bdaa0721073962dff0199f1fb9940f07167d1)

---
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 GrigorievandMichael Eischer 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](https://github.com/docker/login-action/compare/9780b0c442fbb1117ed29e0efdff1e18412f7567...74a5d142397b4f367a81961eba4e8cd7edddf772)

---
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
652 changed files with 20750 additions and 11850 deletions
+25
View File
@@ -0,0 +1,25 @@
[codespell]
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
# Skip historical content (CHANGELOG, release notes archive), auto-generated
# man pages (which contain troff macros like \(bu that look like typos), and
# files we don't want to modify (go.sum, css with vendor prefixes).
skip = .git*,.gitignore,.gitattributes,go.sum,*.css,.codespellrc,CHANGELOG.md,changelog,*.1
check-hidden = true
# Protect URLs from corrections (URLs may contain words flagged as typos and
# must not be changed); also ignore camelCase/PascalCase identifiers like
# AtLeast which are valid Go identifiers, not typos.
ignore-regex = https?://\S+|\b[a-z]+[A-Z]\w*\b|\b[A-Z][a-z]+[A-Z]\w*\b
ignore-words-list =
# variable name short for "serialized", also matches [uU]ser glob pattern
ser,
# German word "ist" appearing in test data string
ist,
# intentional truncated test string in format truncation tests
fo,
# CLI flag name (--iinclude, case-insensitive include)
iinclude,
# intentional in fake test path /doesnt/exist
doesnt
+12
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 hygienic build.
*
!/*.go
!/go.*
!/cmd/*
!/docker/entrypoint.sh
!/internal/*
!/helpers/*
!/VERSION
!/.git/
+1 -1
View File
@@ -36,7 +36,7 @@ Please always follow these steps:
- 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 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'm done! This pull request is ready for review.
+4
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"
+27
View File
@@ -0,0 +1,27 @@
# Codespell configuration is within .codespellrc
---
name: Codespell
on:
# run checks on push to master, but not when other branches are pushed to
push:
branches:
- master
# run checks for all pull requests
pull_request:
merge_group:
permissions:
contents: read
jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Codespell
uses: codespell-project/actions-codespell@8f01853be192eb0f849a5c7d721450e7a467c579 # v2.2
+6 -6
View File
@@ -26,10 +26,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
@@ -37,7 +37,7 @@ jobs:
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
@@ -47,10 +47,10 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd
- name: Ensure consistent binaries
run: |
@@ -61,7 +61,7 @@ jobs:
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@15560696de535e4014efeff63c48f16952e52dd1
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294
with:
push: true
context: .
+13
View File
@@ -0,0 +1,13 @@
name: size-label
on: pull_request_target
jobs:
size-label:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: size-label
uses: "pascalgn/size-label-action@56b489b027932ec0cf60438a1a5f1a19c8fc71ff" # v0.5.7
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
+22 -20
View File
@@ -13,7 +13,7 @@ permissions:
contents: read
env:
latest_go: "1.24.x"
latest_go: "1.26.x"
GO111MODULE: on
jobs:
@@ -23,29 +23,29 @@ jobs:
# list of jobs to run:
include:
- job_name: Windows
go: 1.24.x
go: 1.26.x
os: windows-latest
- job_name: macOS
go: 1.24.x
go: 1.26.x
os: macOS-latest
test_fuse: false
- job_name: Linux
go: 1.24.x
go: 1.26.x
os: ubuntu-latest
test_cloud_backends: true
test_fuse: true
check_changelog: true
- job_name: Linux (race)
go: 1.24.x
go: 1.26.x
os: ubuntu-latest
test_fuse: true
test_opts: "-race"
- job_name: Linux
go: 1.23.x
go: 1.25.x
os: ubuntu-latest
test_fuse: true
@@ -57,10 +57,10 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v5
uses: actions/setup-go@v7
with:
go-version: ${{ matrix.go }}
@@ -137,12 +137,14 @@ jobs:
go run build.go
- name: Minimal test
timeout-minutes: 3
run: |
./restic init
./restic backup .
env:
RESTIC_REPOSITORY: ../testrepo
RESTIC_PASSWORD: password
RESTIC_DEBUG_STACKTRACE_SIGINT: "true"
- name: Run local Tests
env:
@@ -220,10 +222,10 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Set up Go ${{ env.latest_go }}
uses: actions/setup-go@v5
uses: actions/setup-go@v7
with:
go-version: ${{ env.latest_go }}
@@ -242,18 +244,18 @@ jobs:
checks: write
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Set up Go ${{ env.latest_go }}
uses: actions/setup-go@v5
uses: actions/setup-go@v7
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.64.8
version: v2.12
args: --verbose --timeout 5m
# only run golangci-lint for pull requests, otherwise ALL hints get
@@ -278,7 +280,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
uses: re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35
with:
jobs: ${{ toJSON(needs) }}
@@ -287,11 +289,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@v6
with:
# list of Docker images to use as base name for tags
images: |
@@ -307,14 +309,14 @@ jobs:
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7
with:
push: false
context: .
+87 -56
View File
@@ -1,70 +1,101 @@
# 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"
- "redefines-builtin-id:"
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/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"
repository-internals:
files:
- "**"
- "!**/internal/repository/**"
deny:
- pkg: "github.com/restic/restic/internal/repository/"
desc: "packages below internal/repository should not be imported to not depend on repository internals"
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 specifying 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$
+732 -7
View File
@@ -1,5 +1,8 @@
# Table of Contents
* [Changelog for 0.19.1](#changelog-for-restic-0191-2026-07-05)
* [Changelog for 0.19.0](#changelog-for-restic-0190-2026-06-09)
* [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)
@@ -39,6 +42,727 @@
* [Changelog for 0.6.0](#changelog-for-restic-060-2017-05-29)
# Changelog for restic 0.19.1 (2026-07-05)
The following sections list the changes in restic 0.19.1 relevant to
restic users. The changes are ordered by importance.
## Summary
* Fix #5234: Prevent mounting over the repository directory
* Fix #5667: Skip inaccessible `backup` source paths
* Fix #5722: Update `mount` latest symlink after snapshot reload
* Fix #21866: Hide `stats` progress bar in JSON mode
* Fix #21869: Restore old behavior of `snapshots --latest <n>` without `--group-by`
* Fix #21876: Show timezone location in `snapshots` output
* Fix #21879: Prevent crash in mountpoint validation if mountpoint is inaccessible
* Fix #21895: Remove read-only files via the SFTP backend on Windows servers
* Fix #21899: Make `backup` respect excludes for duplicate directory entries
## Details
* Bugfix #5234: Prevent mounting over the repository directory
Using a local repository directory as the `mount` target — or a path that
contains it, or that it contains — caused the FUSE server to read its own
backend files through the new mount, deadlocking the kernel and requiring a long
reboot to recover.
Restic now resolves both paths and refuses any such overlap with a clear error
before mounting.
https://github.com/restic/restic/issues/5234
https://github.com/restic/restic/pull/5348
* Bugfix #5667: Skip inaccessible `backup` source paths
The `backup` command only skipped source paths that did not exist. A path that
could not be accessed for another reason, such as a malformed path on Windows,
was kept and produced an empty snapshot. Restic now skips any such path and
aborts if none remain.
https://github.com/restic/restic/issues/5667
https://github.com/restic/restic/pull/21852
* Bugfix #5722: Update `mount` latest symlink after snapshot reload
When `restic mount` was kept running while new snapshots were created, the new
snapshots appeared in the mountpoint, but the `latest` symlink could still point
to the previously latest snapshot. Restic now invalidates the cached snapshot
directory entries after a snapshot reload so that `latest` points to the newest
snapshot.
https://github.com/restic/restic/issues/5722
https://github.com/restic/restic/pull/21873
* Bugfix #21866: Hide `stats` progress bar in JSON mode
Since restic 0.19.0, the `stats` command shows a progress bar. This progress bar
was unintentionally displayed also when using the `--json` option, mixing
regular text output with JSON. This is now fixed.
https://github.com/restic/restic/issues/21866
https://github.com/restic/restic/pull/21871
* Bugfix #21869: Restore old behavior of `snapshots --latest <n>` without `--group-by`
Restic 0.19.0 accidentally changed the behavior of `snapshots --latest <n>` to
no longer group snapshots by host and paths by default.
The `snapshots --latest <n>` command now again uses the old behavior of grouping
by host and paths when `--group-by` is not specified. However, when specifying
`--group-by` the output is still grouped as requested, as in restic 0.19.0.
https://github.com/restic/restic/issues/21869
https://github.com/restic/restic/pull/21875
* Bugfix #21876: Show timezone location in `snapshots` output
With restic 0.19.0, the `snapshots` command printed the current timezone when
listing snapshots. However, that timezone label might change during the year,
for example with daylight saving time. Restic now prints a more consistent and
shorter version of the text.
https://github.com/restic/restic/pull/21876
https://forum.restic.net/t/possible-bug-in-timezone-naming/10867
* Bugfix #21879: Prevent crash in mountpoint validation if mountpoint is inaccessible
Since restic 0.19.0, the `mount` command validates a mountpoint before loading
the repository. If restic was unable to stat the mountpoint, this would result
in a crash. This has now been fixed to correctly return an error instead.
https://github.com/restic/restic/pull/21879
* Bugfix #21895: Remove read-only files via the SFTP backend on Windows servers
Since restic 0.19.0, repository files on the SFTP backend are marked read-only
after save. On Windows SFTP servers, removing them failed with a permission
error. The SFTP backend now clears the read-only flag before removing the file.
https://github.com/restic/restic/issues/21895
https://github.com/restic/restic/pull/21897
* Bugfix #21899: Make `backup` respect excludes for duplicate directory entries
Since restic 0.19.0, backing up a directory with duplicate directory entries
always produced "Warning: at least one source file could not be read", even when
those files were excluded. This has now been fixed.
https://github.com/restic/restic/issues/21899
https://github.com/restic/restic/pull/21900
# Changelog for restic 0.19.0 (2026-06-09)
The following sections list the changes in restic 0.19.0 relevant to
restic users. The changes are ordered by importance.
## Summary
* Fix #2034: Support serving a `restic mount` of a Windows system via Samba
* Fix #4447: Use mode 0700 for repository directories created over SFTP
* Fix #4467: Exit with code 3 when some `backup` source paths do not exist
* Fix #4759: Error out when environment variables hold invalid values
* Fix #5233: Return exit code 3 when failing to remove snapshots
* Fix #5258: Exit with code 130 on SIGINT
* Fix #5280: Reject impossible `find` time bounds immediately
* Fix #5280: Make `find --pack` list blobs for tree packs
* Fix #5354: Allow `rclone` and `sftp` backends when running in background
* Fix #5427: Correctly restore ACL inheritance state on Windows
* Fix #5477: Password prompt was sometimes not shown for `backup -v`
* Fix #5487: Mark repository files read-only when using the SFTP backend
* Fix #5586: Correctly handle `snapshots --group-by` with `--latest`
* Fix #5595: Avoid spurious `chmod` errors on certain file backends
* Fix #5683: Prevent `backup --stdin-from-command` from hanging
* Fix #5757: Respect `--user` and `--host` in `key passwd`
* Fix #21820: Correct handling of duplicate index entries
* Fix #21820: Correctly handle pack files missing from the index
* Chg #5293: Prune small packfiles more aggressively
* Chg #5767: Prevent excluding paths explicitly passed to `backup`
* Chg #21791: Update dependencies and require Go 1.25 or newer
* Enh #3326: Limit `check` to snapshots selected by filters
* Enh #3572: Support restoring ownership by name on UNIX systems
* Enh #3738: Optional GitHub token for `self-update` API requests
* Enh #4278: Support include filters in the `rewrite` command
* Enh #4728: Support zstd compression levels `fastest` and `better`
* Enh #4868: Include repository ID in the filesystem name used by `mount`
* Enh #5175: Add status counters to `copy` in verbose text output
* Enh #5352: Support excluding cloud-backed files on macOS
* Enh #5383: Reduce progress bar refresh rates to decrease energy usage
* Enh #5424: Enable Windows filesystem privileges before file access
* Enh #5440: Make `--host` override environment variable `RESTIC_HOST`
* Enh #5448: Support configuring `nice` and `ionice` in the Docker image
* Enh #5453: Copy multiple snapshots in batches
* Enh #5523: Add Open Container Initiative labels to release Docker image
* Enh #5531: Reduce Azure storage costs by optimizing uploads
* Enh #5562: Rewrite only changed status lines each frame
* Enh #5588: Show timezone context in `snapshots` output
* Enh #5610: Reduce `check`, `copy`, `diff` and `stats` memory usage
* Enh #5689: Show more detailed progress for `stats`
* Enh #5713: Significantly speed up index loading
* Enh #5718: Stricter and earlier validation of the `mount` point
## Details
* Bugfix #2034: Support serving a `restic mount` of a Windows system via Samba
A repository mounted using `restic mount` on a POSIX system could not use Samba
to serve files from backups of Windows systems, while backups of non-Windows
systems could be served successfully. This has now been fixed.
https://github.com/restic/restic/issues/2034
https://github.com/restic/restic/issues/4382
https://github.com/restic/restic/pull/21784
* Bugfix #4447: Use mode 0700 for repository directories created over SFTP
When creating a repository over SFTP, restic created the repository directories
with the SFTP server's default permissions, often 0755, rather than the 0700
permissions it uses for local repositories.
Restic now creates these directories with 0700 permissions.
https://github.com/restic/restic/issues/4447
https://github.com/restic/restic/pull/21817
* Bugfix #4467: Exit with code 3 when some `backup` source paths do not exist
Restic used to exit with code 0 when a top-level backup source path was missing,
and exited with code 3 only when a child path under an existing source did not
exist. Scripts that relied on the exit code could therefore treat an incomplete
backup as success.
Restic now exits with code 3 when any backup source path does not exist.
https://github.com/restic/restic/issues/4467
https://github.com/restic/restic/pull/5347
* Bugfix #4759: Error out when environment variables hold invalid values
If the environment variables `RESTIC_COMPRESSION`, `RESTIC_PACK_SIZE`, or
`RESTIC_READ_CONCURRENCY` could not be parsed, restic used to ignore them.
Restic now fails with an error unless the same setting is overridden on the
command line.
https://github.com/restic/restic/issues/4759
https://github.com/restic/restic/pull/5592
https://github.com/restic/restic/pull/5700
* Bugfix #5233: Return exit code 3 when failing to remove snapshots
Previously, the `forget` command returned exit code 0 when it failed to remove
one or more snapshots. This was misleading to scripts.
The `forget` command now instead returns exit code 3 when failing to remove one
or more snapshots.
https://github.com/restic/restic/issues/5233
https://github.com/restic/restic/pull/5322
* Bugfix #5258: Exit with code 130 on SIGINT
Restic used to return exit code 1 on SIGINT. It now returns 130, the usual
convention for a process stopped by Ctrl-C.
https://github.com/restic/restic/issues/5258
https://github.com/restic/restic/pull/5363
* Bugfix #5280: Reject impossible `find` time bounds immediately
The `find` command now fails with an error when both `--oldest` and `--newest`
are set and `--oldest` is later than `--newest`.
https://github.com/restic/restic/issues/5280
https://github.com/restic/restic/pull/5310
* Bugfix #5280: Make `find --pack` list blobs for tree packs
The `find --pack <tree-pack>` command now also reports blobs for packs that only
contain tree blobs.
https://github.com/restic/restic/issues/5280
https://github.com/restic/restic/pull/5664
* Bugfix #5354: Allow `rclone` and `sftp` backends when running in background
Previously, starting restic in the background could result in unexpected
behavior when using the `rclone` or `sftp` backends. For example, `restic -r
rclone:./example --insecure-no-password init &` could cause the calling `bash`
shell to exit unexpectedly.
This has now 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
* Bugfix #5427: Correctly restore ACL inheritance state on Windows
Since security descriptor backups were added in restic 0.17.0, Access Control
Entry inheritance was not restored correctly on Windows; restored permissions
were always marked as explicit (not inherited) even when they were inherited
from a parent folder.
The inheritance flags are now correctly applied when restoring the security
descriptor, preserving the original permission structure.
https://github.com/restic/restic/issues/5427
https://github.com/restic/restic/pull/5465
* Bugfix #5477: Password prompt was sometimes not shown for `backup -v`
The repository password prompt could be hidden when running the `backup -v`
command. This has now been fixed.
https://github.com/restic/restic/issues/5477
https://github.com/restic/restic/pull/5554
* Bugfix #5487: Mark repository files read-only when using the SFTP backend
Files created through the SFTP backend previously stayed writable. New files now
get read-only permissions where the server supports `chmod`.
https://github.com/restic/restic/issues/5487
https://github.com/restic/restic/pull/5497
* Bugfix #5586: Correctly handle `snapshots --group-by` with `--latest`
For the `snapshots` command, `--latest` did not interact correctly with a
non-default `--group-by` value. This combination now behaves as intended.
https://github.com/restic/restic/issues/5586
https://github.com/restic/restic/pull/5601
* Bugfix #5595: Avoid spurious `chmod` errors on certain file backends
On filesystems that do not support `chmod` (for example CIFS or FUSE-mounted
WebDAV), restic since version 0.18.0 failed to remove stale locks, throwing the
error `chmod ...: operation not supported`. This has now been fixed.
https://github.com/restic/restic/issues/5595
https://github.com/restic/restic/pull/5596
* Bugfix #5683: Prevent `backup --stdin-from-command` from hanging
When using `--stdin-from-command`, the `backup` command could hang until
manually cancelled if the backup stopped before all subprocess output was
consumed, for example after a failed upload to the repository. This has now been
fixed.
https://github.com/restic/restic/issues/5683
https://github.com/restic/restic/pull/21829
* Bugfix #5757: Respect `--user` and `--host` in `key passwd`
The `key passwd` command previously ignored the `--user` and `--host` options
and always stored the new key with the current user and host name. These options
are now honored.
https://github.com/restic/restic/issues/5757
https://github.com/restic/restic/pull/21781
* Bugfix #21820: Correct handling of duplicate index entries
Before restic 0.10.0, a bug could, in very rare cases, split information about a
pack file across multiple index files.
Since restic 0.17.0, any operation that rewrites the index (like `prune` or
`repair packs`) could lose part of that information, resulting in errors in
later `check` or `prune` runs. This can be fixed by running `repair packs`, and
only repositories using repository format version 1 might be affected.
Split pack index entries are no longer lost during index rewrites. The `check`
command now reports these cases as errors that can be fixed using the `repair
packs` command. On older restic versions, running `repair index` twice also
fixes the problem.
https://github.com/restic/restic/issues/21820
https://github.com/restic/restic/pull/21828
* Bugfix #21820: Correctly handle pack files missing from the index
The `repair packs` command was unable to salvage blobs from a pack file if the
pack file was not contained in the index or the index entry was incomplete.
The command now uses information from both the index and the pack file header.
https://github.com/restic/restic/issues/21820
https://github.com/restic/restic/pull/21827
* Change #5293: Prune small packfiles more aggressively
The `prune` command now repacks more small packfiles by default. The option
`--repack-small` is no longer needed and has been marked as deprecated. The
`--repack-smaller-than` option can still be used to further control repacking of
small pack files.
https://github.com/restic/restic/issues/5293
https://github.com/restic/restic/pull/21803
* Change #5767: Prevent excluding paths explicitly passed to `backup`
When e.g. `restic backup --exclude-if-present .git /home/user/data` was run and
`/home/user/.git` existed, restic excluded the `data` directory from the
snapshot. The same applied to `--exclude-caches` or `--one-file-system`.
Similarly, `restic backup --exclude-larger-than 1M large-file.bin` produced an
empty snapshot when the file was larger than one megabyte.
The `backup` command now tracks which files and directories were specified on
the command line and does not apply excludes to those paths. Content inside a
backed-up directory is still filtered by excludes as before.
https://github.com/restic/restic/issues/5767
https://github.com/restic/restic/pull/21797
* Change #21791: Update dependencies and require Go 1.25 or newer
Dependencies have been updated. Building restic now requires Go 1.25 or newer.
The Windows build with Go 1.26 was also fixed.
https://github.com/restic/restic/issues/21791
https://github.com/restic/restic/pull/5619
https://github.com/restic/restic/pull/21796
* Enhancement #3326: Limit `check` to snapshots selected by filters
The `check` command can now restrict pack verification to snapshots chosen with
the usual snapshot filters (`--tag`, `--host`, `--path`, or explicit snapshot
IDs on the command line).
https://github.com/restic/restic/issues/3326
https://github.com/restic/restic/pull/5469
https://github.com/restic/restic/pull/5644
* Enhancement #3572: Support restoring ownership by name on UNIX systems
The `restore` command used to restore file ownership on UNIX systems by UID and
GID. It now supports restoring ownership by user and group name with
`--ownership-by-name`, so that snapshots can be restored on systems where
numeric IDs do not match those on the backup host.
Note: POSIX ACLs are still restored by numeric value; this change does not add
ACL-by-name support.
https://github.com/restic/restic/issues/3572
https://github.com/restic/restic/pull/5449
* Enhancement #3738: Optional GitHub token for `self-update` API requests
The `self-update` command used only unauthenticated GitHub API requests when
checking for releases. Shared IP addresses could hit the GitHub rate limit,
resulting in a 403 Forbidden error and preventing updates.
Unauthenticated requests remain the default, but authenticated requests are now
possible. Set the environment variable `GITHUB_ACCESS_TOKEN` to a GitHub
[personal access token](https://github.com/settings/tokens) to avoid rate-limit
failures.
https://github.com/restic/restic/issues/3738
https://github.com/restic/restic/pull/5568
* Enhancement #4278: Support include filters in the `rewrite` command
The `rewrite` command now accepts the same include filter options as the
`restore` command (`--include`, `--include-file`, `--iinclude`,
`--iinclude-file`, and short `-i`). Include and exclude filter options are
mutually exclusive.
https://github.com/restic/restic/issues/4278
https://github.com/restic/restic/pull/5191
* Enhancement #4728: Support 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`, or pass the
same values with the `--compression` option.
https://github.com/restic/restic/issues/4728
https://github.com/restic/restic/pull/5321
* Enhancement #4868: Include repository ID in the filesystem name used by `mount`
The filesystem exposed by the `mount` command now includes the repository ID in
its name. The ID is printed when opening a repository or can be read with
`restic cat config`.
```
$ 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
* Enhancement #5175: Add status counters to `copy` in verbose text output
The `copy` command now prints additional counters in text mode when `--verbose`
is set: blobs to copy, their on-disk size, and the number of pack files read
from the source repository.
https://github.com/restic/restic/issues/5175
https://github.com/restic/restic/pull/5319
* Enhancement #5352: Support excluding cloud-backed files on macOS
Previously, restic treated cloud-backed files (such as files stored on iCloud)
like normal local files, forcing a full download of placeholders and other
"meant to be cloud only" content during backups.
The `backup` command now supports `--exclude-cloud-files` (previously only
available on Windows) to skip those files on supported macOS versions. From
Sonoma (macOS 14.0) onward the option can prevent unwanted downloads. Older
macOS versions will still download the files during a backup run.
https://github.com/restic/restic/issues/5352
https://github.com/restic/restic/pull/5370
* Enhancement #5383: Reduce progress bar refresh rates to decrease energy usage
Progress bars were previously updated at 60 frames per second, which could cause
high CPU or GPU usage in some terminal emulators.
The refresh rate is now 10 FPS to conserve energy. For some terminal emulators,
the lower rate is also necessary to allow selecting text in the terminal.
https://github.com/restic/restic/issues/5383
https://github.com/restic/restic/pull/5551
https://github.com/restic/restic/pull/5626
* Enhancement #5424: Enable Windows filesystem privileges before file access
Restic used to enable some Windows filesystem privileges only while reading or
writing security descriptors. Extended attributes could therefore be read before
enabling the backup privilege, possibly resulting in missed data or errors.
Restic now enables the relevant filesystem privileges before any file access.
https://github.com/restic/restic/pull/5424
* Enhancement #5440: Make `--host` override environment variable `RESTIC_HOST`
Previously, when the environment variable `RESTIC_HOST` was set, snapshot
listings and other operations were always filtered to that host.
Passing `--host` as an empty string (`--host=""` or `--host=`) now overrides
`RESTIC_HOST` and shows snapshots from all hosts.
The same override applies to other commands that support snapshot filters,
including `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
* Enhancement #5448: Support configuring `nice` and `ionice` in the Docker image
The container entrypoint now reads optional scheduling hints from the
environment:
- The environment variable `NICE` sets the process nice value (see `man nice`).
- The environment variable `IONICE_CLASS` selects the I/O scheduling class (see
`man ionice`). Real-time classes need the `SYS_NICE` capability added to the
container.
- The environment variable `IONICE_PRIORITY` sets the priority within
`IONICE_CLASS` and has no effect unless `IONICE_CLASS` is set; it defaults to
`4` (neutral priority).
For further details, please see:
https://restic.readthedocs.io/en/stable/020_installation.html#docker-container
https://github.com/restic/restic/pull/5448
* Enhancement #5453: Copy multiple snapshots in batches
The `copy` command used to copy snapshots one at a time, even when doing so
produced pack files smaller than the target pack size. This led to many small
files when copying small incremental snapshots.
The `copy` command now copies multiple snapshots together so that small pack
files are avoided where possible.
https://github.com/restic/restic/issues/5453
https://github.com/restic/restic/pull/5472
* Enhancement #5523: Add Open Container Initiative labels to release Docker image
The release Docker image now includes OCI-style image annotation labels, which
helps external tooling identify the image.
https://github.com/restic/restic/pull/5523
* Enhancement #5531: Reduce Azure storage costs by optimizing uploads
Restic previously used Azure PutBlock and PutBlockList for every upload, which
cost two storage transactions per file and roughly doubled transaction charges
for repositories with many pack files.
Files up to 256 MiB now use PutBlob, requiring only a single transaction per
file and cutting typical transaction costs by about half. Larger blobs still use
block uploads as required by Azure.
https://github.com/restic/restic/issues/5531
https://github.com/restic/restic/pull/5544
* Enhancement #5562: Rewrite only changed status lines each frame
The status bar rewrote every line on each frame whenever any content changed,
which made selecting text impossible in some terminal emulators even when most
lines were unchanged.
Now only lines that actually change are rewritten on each update.
https://github.com/restic/restic/issues/5562
https://github.com/restic/restic/pull/5648
* Enhancement #5588: Show timezone context in `snapshots` output
The `snapshots` command now prints which timezone is used for displayed
timestamps. Snapshots may have been created in different timezones but are shown
in the local timezone, so a footer line (for example, timestamps shown in CET)
clarifies the display context when comparing snapshots from several sources.
https://github.com/restic/restic/pull/5588
* Enhancement #5610: Reduce `check`, `copy`, `diff` and `stats` memory usage
The `check`, `copy`, `diff` and `stats` commands now use less memory when
handling large snapshots.
https://github.com/restic/restic/pull/5610
* Enhancement #5689: Show more detailed progress for `stats`
The `stats` command used to show progress only while loading the index. During
the scan it printed only `scanning...` with no further updates. It now reports
how many snapshots, files, and blobs have been processed so far.
https://github.com/restic/restic/issues/5689
https://github.com/restic/restic/pull/5705
* Enhancement #5713: Significantly speed up index loading
Loading the index for a large repository is now significantly faster. Also, the
`mount` command now loads the index once at startup and then only loads new
index files as they appear. It also loads snapshots before printing that the
repository is being served.
https://github.com/restic/restic/pull/5713
https://github.com/restic/restic/pull/5720
* Enhancement #5718: Stricter and earlier validation of the `mount` point
The `mount` command previously accepted invalid mount points, resulting in an
error after loading the repository. The specified mount point must now refer to
a directory that the current user can access and write to, and this check is
performed before opening the repository.
https://github.com/restic/restic/pull/5718
# 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.
@@ -54,7 +778,7 @@ restic users. The changes are ordered by importance.
* 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: Promote feature flags
* 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)
@@ -76,7 +800,7 @@ restic users. The changes are ordered by importance.
* 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 #52897: Make `recover` automatically rebuild index when needed
* Enh #5287: Make `recover` automatically rebuild index when needed
## Details
@@ -208,7 +932,7 @@ restic users. The changes are ordered by importance.
https://github.com/restic/restic/pull/4938
* Change #5162: Promote feature flags
* 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
@@ -408,13 +1132,13 @@ restic users. The changes are ordered by importance.
https://github.com/restic/restic/pull/5251
* Enhancement #52897: Make `recover` automatically rebuild index when needed
* 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/52897
https://github.com/restic/restic/issues/5287
https://github.com/restic/restic/pull/5296
@@ -606,8 +1330,9 @@ restic users. The changes are ordered by importance.
correctly.
Specifying volume names is now handled correctly. To restore snapshots created
before this bugfix, use the <snapshot>:<subpath> syntax. For example, to restore
a snapshot with ID `12345678` that backed up `C:`, use the following command:
before this bugfix, use the <snapshot>:<subfolder> syntax. For example, to
restore a snapshot with ID `12345678` that backed up `C:`, use the following
command:
```
restic restore 12345678:/C/C:./ --target output/folder
+3
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
-----------
+1 -1
View File
@@ -93,7 +93,7 @@ release. Instructions on how to do that are contained in the
## News
You can follow the restic project on Mastodon [@resticbackup](https://fosstodon.org/@restic) or subscribe to
You can follow the restic project on Mastodon [@restic](https://fosstodon.org/@restic) or subscribe to
the [project blog](https://restic.net/blog/).
## License
+1 -1
View File
@@ -1 +1 @@
0.18.0
0.19.1-dev
+1 -2
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
@@ -60,7 +59,7 @@ var config = Config{
// 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: 23, Patch: 0}, // minimum Go version supported
MinVersion: GoVersion{Major: 1, Minor: 25, Patch: 0}, // minimum Go version supported
}
// Config configures the build.
+1 -1
View File
@@ -6,7 +6,7 @@ resulting snapshot would result in an error. Note that using `C:\`
as backup target worked correctly.
Specifying volume names is now handled correctly. To restore snapshots
created before this bugfix, use the <snapshot>:<subpath> syntax. For
created before this bugfix, use the <snapshot>:<subfolder> syntax. For
example, to restore a snapshot with ID `12345678` that backed up `C:`,
use the following command:
+1 -1
View File
@@ -4,5 +4,5 @@ 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/52897
https://github.com/restic/restic/issues/5287
https://github.com/restic/restic/pull/5296
+1 -1
View File
@@ -1,4 +1,4 @@
Change: Promote feature flags
Change: Graduate feature flags
The `deprecate-legacy-index`, `deprecate-s3-legacy-layout`,
`explicit-s3-anonymous-auth` and `safe-forget-keep-tags` features are
+14
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
+7
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
+7
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
+7
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
+8
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
+27
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
+7
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
+17
View File
@@ -0,0 +1,17 @@
Bugfix: Correct handling of duplicate index entries
Before restic 0.10.0, a bug could, in very rare cases, split information
about a pack file across multiple index files.
Since restic 0.17.0, any operation that rewrites the index (like `prune`
or `repair packs`) could lose part of that information, resulting in errors
in later `check` or `prune` runs. This can be fixed by running `repair packs`,
and only repositories using repository format version 1 might be affected.
Split pack index entries are no longer lost during index rewrites. The
`check` command now reports these cases as errors that can be fixed using
the `repair packs` command. On older restic versions, running `repair index`
twice also fixes the problem.
https://github.com/restic/restic/issues/21820
https://github.com/restic/restic/pull/21828
+9
View File
@@ -0,0 +1,9 @@
Enhancement: Limit `check` to snapshots selected by filters
The `check` command can now restrict pack verification to snapshots chosen with
the usual snapshot filters (`--tag`, `--host`, `--path`, or explicit snapshot
IDs on the command line).
https://github.com/restic/restic/issues/3326
https://github.com/restic/restic/pull/5469
https://github.com/restic/restic/pull/5644
+12
View File
@@ -0,0 +1,12 @@
Enhancement: Support restoring ownership by name on UNIX systems
The `restore` command used to restore file ownership on UNIX systems by UID
and GID. It now supports restoring ownership by user and group name with
`--ownership-by-name`, so that snapshots can be restored on systems where
numeric IDs do not match those on the backup host.
Note: POSIX ACLs are still restored by numeric value; this change does not
add ACL-by-name support.
https://github.com/restic/restic/issues/3572
https://github.com/restic/restic/pull/5449
+13
View File
@@ -0,0 +1,13 @@
Enhancement: Optional GitHub token for `self-update` API requests
The `self-update` command used only unauthenticated GitHub API requests when
checking for releases. Shared IP addresses could hit the GitHub rate limit,
resulting in a 403 Forbidden error and preventing updates.
Unauthenticated requests remain the default, but authenticated requests are now
possible. Set the environment variable `GITHUB_ACCESS_TOKEN` to a GitHub
[personal access token](https://github.com/settings/tokens) to avoid rate-limit
failures.
https://github.com/restic/restic/issues/3738
https://github.com/restic/restic/pull/5568
+8
View File
@@ -0,0 +1,8 @@
Enhancement: Support include filters in the `rewrite` command
The `rewrite` command now accepts the same include filter options as the `restore`
command (`--include`, `--include-file`, `--iinclude`, `--iinclude-file`, and
short `-i`). Include and exclude filter options are mutually exclusive.
https://github.com/restic/restic/issues/4278
https://github.com/restic/restic/pull/5191
+10
View File
@@ -0,0 +1,10 @@
Bugfix: Use mode 0700 for repository directories created over SFTP
When creating a repository over SFTP, restic created the repository directories
with the SFTP server's default permissions, often 0755, rather than the 0700
permissions it uses for local repositories.
Restic now creates these directories with 0700 permissions.
https://github.com/restic/restic/issues/4447
https://github.com/restic/restic/pull/21817
+11
View File
@@ -0,0 +1,11 @@
Bugfix: Exit with code 3 when some `backup` source paths do not exist
Restic used to exit with code 0 when a top-level backup source path was
missing, and exited with code 3 only when a child path under an existing
source did not exist. Scripts that relied on the exit code could therefore
treat an incomplete backup as success.
Restic now exits with code 3 when any backup source path does not exist.
https://github.com/restic/restic/issues/4467
https://github.com/restic/restic/pull/5347
+8
View File
@@ -0,0 +1,8 @@
Enhancement: Support 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`, or pass the
same values with the `--compression` option.
https://github.com/restic/restic/issues/4728
https://github.com/restic/restic/pull/5321
+10
View File
@@ -0,0 +1,10 @@
Bugfix: Error out when environment variables hold invalid values
If the environment variables `RESTIC_COMPRESSION`, `RESTIC_PACK_SIZE`, or
`RESTIC_READ_CONCURRENCY` could not be parsed, restic used to ignore them.
Restic now fails with an error unless the same setting is overridden on the
command line.
https://github.com/restic/restic/issues/4759
https://github.com/restic/restic/pull/5592
https://github.com/restic/restic/pull/5700
+14
View File
@@ -0,0 +1,14 @@
Enhancement: Include repository ID in the filesystem name used by `mount`
The filesystem exposed by the `mount` command now includes the repository ID
in its name. The ID is printed when opening a repository or can be read with
`restic cat config`.
```
$ 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
+10
View File
@@ -0,0 +1,10 @@
Bugfix: Return exit code 3 when failing to remove snapshots
Previously, the `forget` command returned exit code 0 when it failed
to remove one or more snapshots. This was misleading to scripts.
The `forget` command now instead returns exit code 3 when failing to
remove one or more snapshots.
https://github.com/restic/restic/issues/5233
https://github.com/restic/restic/pull/5322
+7
View File
@@ -0,0 +1,7 @@
Bugfix: Exit with code 130 on SIGINT
Restic used to return exit code 1 on SIGINT. It now returns 130, the usual
convention for a process stopped by Ctrl-C.
https://github.com/restic/restic/issues/5258
https://github.com/restic/restic/pull/5363
+7
View File
@@ -0,0 +1,7 @@
Bugfix: Reject impossible `find` time bounds immediately
The `find` command now fails with an error when both `--oldest`
and `--newest` are set and `--oldest` is later than `--newest`.
https://github.com/restic/restic/issues/5280
https://github.com/restic/restic/pull/5310
+9
View File
@@ -0,0 +1,9 @@
Change: Prune small packfiles more aggressively
The `prune` command now repacks more small packfiles by default. The option
`--repack-small` is no longer needed and has been marked as deprecated. The
`--repack-smaller-than` option can still be used to further control repacking
of small pack files.
https://github.com/restic/restic/issues/5293
https://github.com/restic/restic/pull/21803
+13
View File
@@ -0,0 +1,13 @@
Enhancement: Support excluding cloud-backed files on macOS
Previously, restic treated cloud-backed files (such as files stored on iCloud)
like normal local files, forcing a full download of placeholders and other
"meant to be cloud only" content during backups.
The `backup` command now supports `--exclude-cloud-files` (previously only
available on Windows) to skip those files on supported macOS versions. From
Sonoma (macOS 14.0) onward the option can prevent unwanted downloads. Older
macOS versions will still download the files during a backup run.
https://github.com/restic/restic/issues/5352
https://github.com/restic/restic/pull/5370
+13
View File
@@ -0,0 +1,13 @@
Bugfix: Allow `rclone` and `sftp` backends when running in background
Previously, starting restic in the background could result in unexpected
behavior when using the `rclone` or `sftp` backends. For example,
`restic -r rclone:./example --insecure-no-password init &` could cause the
calling `bash` shell to exit unexpectedly.
This has now 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
+12
View File
@@ -0,0 +1,12 @@
Enhancement: Reduce progress bar refresh rates to decrease energy usage
Progress bars were previously updated at 60 frames per second, which
could cause high CPU or GPU usage in some terminal emulators.
The refresh rate is now 10 FPS to conserve energy. For some terminal
emulators, the lower rate is also necessary to allow selecting text
in the terminal.
https://github.com/restic/restic/issues/5383
https://github.com/restic/restic/pull/5551
https://github.com/restic/restic/pull/5626
+14
View File
@@ -0,0 +1,14 @@
Enhancement: Make `--host` override environment variable `RESTIC_HOST`
Previously, when the environment variable `RESTIC_HOST` was set, snapshot
listings and other operations were always filtered to that host.
Passing `--host` as an empty string (`--host=""` or `--host=`) now overrides
`RESTIC_HOST` and shows snapshots from all hosts.
The same override applies to other commands that support snapshot filters,
including `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
+11
View File
@@ -0,0 +1,11 @@
Enhancement: Copy multiple snapshots in batches
The `copy` command used to copy snapshots one at a time, even when doing so
produced pack files smaller than the target pack size. This led to many small
files when copying small incremental snapshots.
The `copy` command now copies multiple snapshots together so that small pack
files are avoided where possible.
https://github.com/restic/restic/issues/5453
https://github.com/restic/restic/pull/5472
+7
View File
@@ -0,0 +1,7 @@
Bugfix: Password prompt was sometimes not shown for `backup -v`
The repository password prompt could be hidden when running the
`backup -v` command. This has now been fixed.
https://github.com/restic/restic/issues/5477
https://github.com/restic/restic/pull/5554
+7
View File
@@ -0,0 +1,7 @@
Bugfix: Mark repository files read-only when using the SFTP backend
Files created through the SFTP backend previously stayed writable. New files now
get read-only permissions where the server supports `chmod`.
https://github.com/restic/restic/issues/5487
https://github.com/restic/restic/pull/5497
+12
View File
@@ -0,0 +1,12 @@
Enhancement: Reduce Azure storage costs by optimizing uploads
Restic previously used Azure PutBlock and PutBlockList for every upload, which
cost two storage transactions per file and roughly doubled transaction charges
for repositories with many pack files.
Files up to 256 MiB now use PutBlob, requiring only a single transaction per
file and cutting typical transaction costs by about half. Larger blobs still
use block uploads as required by Azure.
https://github.com/restic/restic/issues/5531
https://github.com/restic/restic/pull/5544
+10
View File
@@ -0,0 +1,10 @@
Enhancement: Rewrite only changed status lines each frame
The status bar rewrote every line on each frame whenever any content changed,
which made selecting text impossible in some terminal emulators even when most
lines were unchanged.
Now only lines that actually change are rewritten on each update.
https://github.com/restic/restic/issues/5562
https://github.com/restic/restic/pull/5648
+7
View File
@@ -0,0 +1,7 @@
Bugfix: Correctly handle `snapshots --group-by` with `--latest`
For the `snapshots` command, `--latest` did not interact correctly with a
non-default `--group-by` value. This combination now behaves as intended.
https://github.com/restic/restic/issues/5586
https://github.com/restic/restic/pull/5601
+8
View File
@@ -0,0 +1,8 @@
Bugfix: Avoid spurious `chmod` errors on certain file backends
On filesystems that do not support `chmod` (for example CIFS or FUSE-mounted
WebDAV), restic since version 0.18.0 failed to remove stale locks, throwing
the error `chmod ...: operation not supported`. This has now been fixed.
https://github.com/restic/restic/issues/5595
https://github.com/restic/restic/pull/5596
+9
View File
@@ -0,0 +1,9 @@
Bugfix: Prevent `backup --stdin-from-command` from hanging
When using `--stdin-from-command`, the `backup` command could hang until
manually cancelled if the backup stopped before all subprocess output was
consumed, for example after a failed upload to the repository. This has
now been fixed.
https://github.com/restic/restic/issues/5683
https://github.com/restic/restic/pull/21829
+8
View File
@@ -0,0 +1,8 @@
Enhancement: Show more detailed progress for `stats`
The `stats` command used to show progress only while loading the index. During
the scan it printed only `scanning...` with no further updates. It now reports
how many snapshots, files, and blobs have been processed so far.
https://github.com/restic/restic/issues/5689
https://github.com/restic/restic/pull/5705
+8
View File
@@ -0,0 +1,8 @@
Bugfix: Respect `--user` and `--host` in `key passwd`
The `key passwd` command previously ignored the `--user` and
`--host` options and always stored the new key with the current
user and host name. These options are now honored.
https://github.com/restic/restic/issues/5757
https://github.com/restic/restic/pull/21781
+15
View File
@@ -0,0 +1,15 @@
Change: Prevent excluding paths explicitly passed to `backup`
When e.g. `restic backup --exclude-if-present .git /home/user/data` was run
and `/home/user/.git` existed, restic excluded the `data` directory from the
snapshot. The same applied to `--exclude-caches` or `--one-file-system`.
Similarly, `restic backup --exclude-larger-than 1M large-file.bin` produced
an empty snapshot when the file was larger than one megabyte.
The `backup` command now tracks which files and directories were specified on
the command line and does not apply excludes to those paths. Content inside a
backed-up directory is still filtered by excludes as before.
https://github.com/restic/restic/issues/5767
https://github.com/restic/restic/pull/21797
+9
View File
@@ -0,0 +1,9 @@
Bugfix: Support serving a `restic mount` of a Windows system via Samba
A repository mounted using `restic mount` on a POSIX system could not use
Samba to serve files from backups of Windows systems, while backups of
non-Windows systems could be served successfully. This has now been fixed.
https://github.com/restic/restic/issues/2034
https://github.com/restic/restic/issues/4382
https://github.com/restic/restic/pull/21784
+8
View File
@@ -0,0 +1,8 @@
Change: Update dependencies and require Go 1.25 or newer
Dependencies have been updated. Building restic now requires
Go 1.25 or newer. The Windows build with Go 1.26 was also fixed.
https://github.com/restic/restic/issues/21791
https://github.com/restic/restic/pull/5619
https://github.com/restic/restic/pull/21796
+9
View File
@@ -0,0 +1,9 @@
Bugfix: Correctly handle pack files missing from the index
The `repair packs` command was unable to salvage blobs from a pack file if
the pack file was not contained in the index or the index entry was incomplete.
The command now uses information from both the index and the pack file header.
https://github.com/restic/restic/issues/21820
https://github.com/restic/restic/pull/21827
+8
View File
@@ -0,0 +1,8 @@
Enhancement: Add status counters to `copy` in verbose text output
The `copy` command now prints additional counters in text mode when
`--verbose` is set: blobs to copy, their on-disk size, and the number
of pack files read from the source repository.
https://github.com/restic/restic/issues/5175
https://github.com/restic/restic/pull/5319
+10
View File
@@ -0,0 +1,10 @@
Enhancement: Enable Windows filesystem privileges before file access
Restic used to enable some Windows filesystem privileges only while reading
or writing security descriptors. Extended attributes could therefore be read
before enabling the backup privilege, possibly resulting in missed data or
errors.
Restic now enables the relevant filesystem privileges before any file access.
https://github.com/restic/restic/pull/5424
+19
View File
@@ -0,0 +1,19 @@
Enhancement: Support configuring `nice` and `ionice` in the Docker image
The container entrypoint now reads optional scheduling hints from the
environment:
- The environment variable `NICE` sets the process nice value (see `man nice`).
- The environment variable `IONICE_CLASS` selects the I/O scheduling class (see
`man ionice`). Real-time classes need the `SYS_NICE` capability added to the
container.
- The environment variable `IONICE_PRIORITY` sets the priority within
`IONICE_CLASS` and has no effect unless `IONICE_CLASS` is set; it defaults to
`4` (neutral priority).
For further details, please see:
https://restic.readthedocs.io/en/stable/020_installation.html#docker-container
https://github.com/restic/restic/pull/5448
+12
View File
@@ -0,0 +1,12 @@
Bugfix: Correctly restore ACL inheritance state on Windows
Since security descriptor backups were added in restic 0.17.0, Access Control
Entry inheritance was not restored correctly on Windows; restored permissions
were always marked as explicit (not inherited) even when they were inherited
from a parent folder.
The inheritance flags are now correctly applied when restoring the security
descriptor, preserving the original permission structure.
https://github.com/restic/restic/issues/5427
https://github.com/restic/restic/pull/5465
+6
View File
@@ -0,0 +1,6 @@
Enhancement: Add Open Container Initiative labels to release Docker image
The release Docker image now includes OCI-style image annotation labels,
which helps external tooling identify the image.
https://github.com/restic/restic/pull/5523
+9
View File
@@ -0,0 +1,9 @@
Enhancement: Show timezone context in `snapshots` output
The `snapshots` command now prints which timezone is used for displayed
timestamps. Snapshots may have been created in different timezones but are
shown in the local timezone, so a footer line (for example, timestamps shown in
CET) clarifies the display context when comparing snapshots from several
sources.
https://github.com/restic/restic/pull/5588
+6
View File
@@ -0,0 +1,6 @@
Enhancement: Reduce `check`, `copy`, `diff` and `stats` memory usage
The `check`, `copy`, `diff` and `stats` commands now use less memory
when handling large snapshots.
https://github.com/restic/restic/pull/5610
+7
View File
@@ -0,0 +1,7 @@
Bugfix: Make `find --pack` list blobs for tree packs
The `find --pack <tree-pack>` command now also reports
blobs for packs that only contain tree blobs.
https://github.com/restic/restic/issues/5280
https://github.com/restic/restic/pull/5664
+8
View File
@@ -0,0 +1,8 @@
Enhancement: Stricter and earlier validation of the `mount` point
The `mount` command previously accepted invalid mount points, resulting in an
error after loading the repository. The specified mount point must now refer to
a directory that the current user can access and write to, and this check is
performed before opening the repository.
https://github.com/restic/restic/pull/5718
+9
View File
@@ -0,0 +1,9 @@
Enhancement: Significantly speed up index loading
Loading the index for a large repository is now significantly faster. Also,
the `mount` command now loads the index once at startup and then only loads
new index files as they appear. It also loads snapshots before printing that
the repository is being served.
https://github.com/restic/restic/pull/5713
https://github.com/restic/restic/pull/5720
+8
View File
@@ -0,0 +1,8 @@
Bugfix: Hide `stats` progress bar in JSON mode
Since restic 0.19.0, the `stats` command shows a progress bar. This
progress bar was unintentionally displayed also when using the `--json`
option, mixing regular text output with JSON. This is now fixed.
https://github.com/restic/restic/issues/21866
https://github.com/restic/restic/pull/21871
+12
View File
@@ -0,0 +1,12 @@
Bugfix: Restore old behavior of `snapshots --latest <n>` without `--group-by`
Restic 0.19.0 accidentally changed the behavior of `snapshots --latest <n>`
to no longer group snapshots by host and paths by default.
The `snapshots --latest <n>` command now again uses the old behavior of
grouping by host and paths when `--group-by` is not specified. However, when
specifying `--group-by` the output is still grouped as requested, as in restic
0.19.0.
https://github.com/restic/restic/issues/21869
https://github.com/restic/restic/pull/21875
+9
View File
@@ -0,0 +1,9 @@
Bugfix: Remove read-only files via the SFTP backend on Windows servers
Since restic 0.19.0, repository files on the SFTP backend are marked
read-only after save. On Windows SFTP servers, removing them failed
with a permission error. The SFTP backend now clears the read-only flag
before removing the file.
https://github.com/restic/restic/issues/21895
https://github.com/restic/restic/pull/21897
+8
View File
@@ -0,0 +1,8 @@
Bugfix: Make `backup` respect excludes for duplicate directory entries
Since restic 0.19.0, backing up a directory with duplicate directory
entries always produced "Warning: at least one source file could not be
read", even when those files were excluded. This has now been fixed.
https://github.com/restic/restic/issues/21899
https://github.com/restic/restic/pull/21900
+12
View File
@@ -0,0 +1,12 @@
Bugfix: Prevent mounting over the repository directory
Using a local repository directory as the `mount` target — or a path
that contains it, or that it contains — caused the FUSE server to
read its own backend files through the new mount, deadlocking the
kernel and requiring a long reboot to recover.
Restic now resolves both paths and refuses any such overlap with a
clear error before mounting.
https://github.com/restic/restic/issues/5234
https://github.com/restic/restic/pull/5348
+9
View File
@@ -0,0 +1,9 @@
Bugfix: Skip inaccessible `backup` source paths
The `backup` command only skipped source paths that did not exist. A path that
could not be accessed for another reason, such as a malformed path on Windows,
was kept and produced an empty snapshot. Restic now skips any such path and
aborts if none remain.
https://github.com/restic/restic/issues/5667
https://github.com/restic/restic/pull/21852
+10
View File
@@ -0,0 +1,10 @@
Bugfix: Update `mount` latest symlink after snapshot reload
When `restic mount` was kept running while new snapshots were
created, the new snapshots appeared in the mountpoint, but the `latest`
symlink could still point to the previously latest snapshot. Restic now
invalidates the cached snapshot directory entries after a snapshot reload so
that `latest` points to the newest snapshot.
https://github.com/restic/restic/issues/5722
https://github.com/restic/restic/pull/21873
+9
View File
@@ -0,0 +1,9 @@
Bugfix: Show timezone location in `snapshots` output
With restic 0.19.0, the `snapshots` command printed the current timezone when
listing snapshots. However, that timezone label might change during the year,
for example with daylight saving time. Restic now prints a more consistent and
shorter version of the text.
https://github.com/restic/restic/pull/21876
https://forum.restic.net/t/possible-bug-in-timezone-naming/10867
+7
View File
@@ -0,0 +1,7 @@
Bugfix: Prevent crash in mountpoint validation if mountpoint is inaccessible
Since restic 0.19.0, the `mount` command validates a mountpoint before loading
the repository. If restic was unable to stat the mountpoint, this would result
in a crash. This has now been fixed to correctly return an error instead.
https://github.com/restic/restic/pull/21879
+11 -5
View File
@@ -1,14 +1,20 @@
# The first line must start with Bugfix:, Enhancement: or Change:,
# including the colon. Use present tense and the imperative mood. Remove
# lines starting with '#' from this template.
Enhancement: Allow custom bar in the foo command
# including the colon. 'Change:' is for breaking changes only.
# Documentation-only changes do not get a changelog entry.
# Include the affected command in the summary if relevant.
#
# Use present tense and the imperative mood. Remove lines starting
# with '#' from this template.
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.
# only explain the new behavior. Aim for a short and concise description.
# Use "Restic now ..." instead of "We have changed ...".
#
# Focus on user-facing behavior, not the implementation. The description should
# be understandable for a regular user without knowledge of the implementation.
Restic foo always used the system-wide bar when deciding how to frob an
item in the `baz` backend. It now permits selecting the bar with `--bar`
+7
View File
@@ -0,0 +1,7 @@
Enhancement: show excluded items during backup in verbose mode
`restic backup -vv` now shows excluded items in verbose mode. Both text and JSON
output are supported.
https://github.com/restic/restic/issues/21870
https://github.com/restic/restic/pull/21887
+11
View File
@@ -0,0 +1,11 @@
Enhancement: `restic repair snapshots --forget` removes broken snapshots
In the past restic had no command to remove broken snapshot files.
`restic repair snapshots --forget` can now remove broken snapshot files,
which have been found previously by `restic check` or by earlier error messages from restic commands.
For example, `restic repair snapshots --forget 1d204771` will remove a broken snapshot file with id `1d204771`.
https://github.com/restic/restic/issues/21892
https://github.com/restic/restic/pull/21907
+7
View File
@@ -0,0 +1,7 @@
Enhancement: Add JSON support to prune
Restic `prune` now also supports the `--json` option and gives all
statistics in JSON format.
https://github.com/restic/restic/issues/3129
https://github.com/restic/restic/pull/5239
+8
View File
@@ -0,0 +1,8 @@
Enhancement: Add warmup support for check command on S3 backend
Like the other cold storage features, warmup support for the `check` command
remains experimental and gated behind the "s3-restore" feature flag.
https://github.com/restic/restic/pull/5248
https://github.com/restic/restic/issues/3202
https://github.com/restic/restic/issues/2504
+7
View File
@@ -0,0 +1,7 @@
Enhancement: Add command to list packfiles belonging to a snapshot
This enhancement adds command `list packs snapshotID` to show the packfiles
belonging to the given snapshot.
https://github.com/restic/restic/issues/5372
https://github.com/restic/restic/pull/5396
+7
View File
@@ -0,0 +1,7 @@
Enhancement: `restic repair packs` can handle missing packfiles
Missing and damaged packfiles previously required separate approaches to fix a repository.
Now, both cases can be handled by the `repair packs` command, which is now able to handle
missing packfiles by removing them from the repository index.
https://github.com/restic/restic/pull/21845
+6
View File
@@ -0,0 +1,6 @@
Enhancement: `find --pack` can handle corrupted pack files
`restic find --pack <id>` can now also report affected snapshot if a packfile
is corrupted but still present in the repository index.
https://github.com/restic/restic/pull/21883
+8
View File
@@ -0,0 +1,8 @@
Enhancement: Reduce memory usage of the in-memory index
Restic keeps an index of the repository contents in memory during most
operations. This index now requires roughly 12% less memory, which is
especially noticeable for large repositories with many snapshots, where
a lot of index data has to be loaded.
https://github.com/restic/restic/pull/21937
+9
View File
@@ -0,0 +1,9 @@
Bugfix: Report an error instead of crashing on a truncated key or config file
Restic crashed with a slice bounds panic when a repository contained a key
file or a config file that was shorter than the encryption overhead, for
example after an upload was interrupted. Since every command has to read a
key file, the whole repository became unusable until the file was removed.
Restic now reports that the file is too short instead.
https://github.com/restic/restic/pull/21977
+7
View File
@@ -0,0 +1,7 @@
Bugfix: Redact Swift backend password in debug log output
Restic could write the OpenStack Swift backend password (OS_PASSWORD or
ST_KEY) in clear text to the debug log when debug logging was enabled.
The password is now redacted.
https://github.com/restic/restic/pull/22007
+10 -7
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()
+126 -104
View File
@@ -10,6 +10,7 @@ import (
"path"
"path/filepath"
"runtime"
"slices"
"strconv"
"strings"
"time"
@@ -19,19 +20,20 @@ import (
"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"
)
func newBackupCommand() *cobra.Command {
func newBackupCommand(globalOptions *global.Options) *cobra.Command {
var opts BackupOptions
cmd := &cobra.Command{
@@ -51,22 +53,13 @@ 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 opts.Host == "" {
hostname, err := os.Hostname()
if err != nil {
debug.Log("os.Hostname() returned err: %v", err)
return
}
opts.Host = hostname
}
PreRunE: func(_ *cobra.Command, _ []string) error {
return opts.Finalize()
},
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
term, cancel := setupTermstatus()
defer cancel()
return runBackup(cmd.Context(), opts, globalOptions, term, args)
return runBackup(cmd.Context(), opts, *globalOptions, globalOptions.Term, args)
},
}
@@ -79,7 +72,7 @@ type BackupOptions struct {
filter.ExcludePatternOptions
Parent string
GroupBy restic.SnapshotGroupByOptions
GroupBy data.SnapshotGroupByOptions
Force bool
ExcludeOtherFS bool
ExcludeIfPresent []string
@@ -89,7 +82,7 @@ type BackupOptions struct {
Stdin bool
StdinFilename string
StdinCommand bool
Tags restic.TagLists
Tags data.TagLists
Host string
FilesFrom []string
FilesFromVerbatim []string
@@ -103,11 +96,13 @@ type BackupOptions struct {
ReadConcurrency uint
NoScan bool
SkipIfUnchanged bool
readConcurrencyFlag *pflag.Flag
}
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 = restic.SnapshotGroupByOptions{Host: true, Path: true}
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)`)
@@ -134,19 +129,23 @@ func (opts *BackupOptions) AddFlags(f *pflag.FlagSet) {
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.BoolVar(&opts.IgnoreInode, "ignore-inode", false, "ignore inode number and ctime changes when checking for modified files (default: $RESTIC_IGNORE_INODE or false)")
f.BoolVar(&opts.IgnoreCtime, "ignore-ctime", false, "ignore ctime changes when checking for modified files (default: $RESTIC_IGNORE_CTIME or false)")
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(&opts.UseFsSnapshot, "use-fs-snapshot", false, "use filesystem snapshot where possible (currently only Windows VSS)")
f.BoolVar(&opts.ExcludeCloudFiles, "exclude-cloud-files", false, "excludes online-only cloud files (such as OneDrive Files On-Demand)")
}
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)
opts.ReadConcurrency = uint(readConcurrency)
opts.readConcurrencyFlag = f.Lookup("read-concurrency")
// parse read inode and ctime from env, on error the default value will be used
opts.IgnoreInode, _ = strconv.ParseBool(os.Getenv("RESTIC_IGNORE_INODE"))
opts.IgnoreCtime, _ = strconv.ParseBool(os.Getenv("RESTIC_IGNORE_CTIME"))
// parse host from env, if not exists or empty the default value will be used
if host := os.Getenv("RESTIC_HOST"); host != "" {
@@ -154,18 +153,44 @@ func (opts *BackupOptions) AddFlags(f *pflag.FlagSet) {
}
}
func (opts *BackupOptions) Finalize() error {
if envVal := os.Getenv("RESTIC_READ_CONCURRENCY"); envVal != "" && !opts.readConcurrencyFlag.Changed {
n, err := strconv.ParseUint(envVal, 10, 32)
if err != nil {
return errors.Fatalf("invalid value for RESTIC_READ_CONCURRENCY %q: %v", envVal, err)
}
opts.ReadConcurrency = uint(n)
}
if opts.Host == "" {
hostname, err := os.Hostname()
if err != nil {
debug.Log("os.Hostname() returned err: %v", err)
return nil
}
opts.Host = hostname
}
return nil
}
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")
// 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) {
// ErrNoSourceData is used to report that no source data was found
var ErrNoSourceData = errors.Fatal("all source directories/files do not exist")
// filterExisting returns the items that exist and can be accessed. It returns
// ErrNoSourceData if none remain, or ErrInvalidSourceData if some were skipped.
func filterExisting(items []string, warnf func(msg string, args ...any)) (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)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
warnf("%v does not exist, skipping\n", item)
} else {
warnf("%v cannot be accessed, skipping\n", item)
}
continue
}
@@ -173,10 +198,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
@@ -185,7 +212,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
}
@@ -196,7 +223,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)
}
@@ -221,8 +248,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
@@ -271,17 +298,15 @@ 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")
}
filesFrom := append(append(opts.FilesFrom, opts.FilesFromVerbatim...), opts.FilesFromRaw...)
for _, filename := range filesFrom {
if filename == "-" {
return errors.Fatal("unable to read password from stdin when data is to be read from stdin, use --password-file or $RESTIC_PASSWORD")
}
if slices.Contains(filesFrom, "-") {
return errors.Fatal("unable to read password from stdin when data is to be read from stdin, use --password-file or $RESTIC_PASSWORD")
}
}
@@ -306,7 +331,7 @@ 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 []archiver.RejectByNameFunc, err error) {
func collectRejectByNameFuncs(opts BackupOptions, repo *repository.Repository, warnf func(msg string, args ...any)) (fs []archiver.RejectByNameFunc, err error) {
// exclude restic cache
if repo.Cache() != nil {
f, err := rejectResticCache(repo)
@@ -317,7 +342,7 @@ func collectRejectByNameFuncs(opts BackupOptions, repo *repository.Repository) (
fs = append(fs, f)
}
fsPatterns, err := opts.ExcludePatternOptions.CollectPatterns(Warnf)
fsPatterns, err := opts.ExcludePatternOptions.CollectPatterns(warnf)
if err != nil {
return nil, err
}
@@ -330,7 +355,7 @@ 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 fs.FS) (funcs []archiver.RejectFunc, err error) {
func collectRejectFuncs(opts BackupOptions, targets []string, fs fs.FS, warnf func(msg string, args ...any)) (funcs []archiver.RejectFunc, err error) {
// allowed devices
if opts.ExcludeOtherFS && !opts.Stdin && !opts.StdinCommand {
f, err := archiver.RejectByDevice(targets, fs)
@@ -354,10 +379,7 @@ func collectRejectFuncs(opts BackupOptions, targets []string, fs fs.FS) (funcs [
}
if opts.ExcludeCloudFiles && !opts.Stdin && !opts.StdinCommand {
if runtime.GOOS != "windows" {
return nil, errors.Fatalf("exclude-cloud-files is only supported on Windows")
}
f, err := archiver.RejectCloudFiles(Warnf)
f, err := archiver.RejectCloudFiles(warnf)
if err != nil {
return nil, err
}
@@ -369,7 +391,7 @@ func collectRejectFuncs(opts BackupOptions, targets []string, fs fs.FS) (funcs [
}
for _, spec := range opts.ExcludeIfPresent {
f, err := archiver.RejectIfPresent(spec, Warnf)
f, err := archiver.RejectIfPresent(spec, warnf)
if err != nil {
return nil, err
}
@@ -381,13 +403,13 @@ func collectRejectFuncs(opts BackupOptions, targets []string, fs fs.FS) (funcs [
}
// 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 ...any), 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
}
@@ -405,14 +427,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
}
@@ -425,7 +447,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
}
@@ -439,17 +461,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
}
@@ -458,7 +475,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}
}
@@ -466,23 +483,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
}
}
@@ -492,47 +515,45 @@ 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, 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
}
var parentSnapshot *restic.Snapshot
var parentSnapshot *data.Snapshot
if !opts.Stdin {
parentSnapshot, err = findParentSnapshot(ctx, repo, opts, targets, timeStamp)
if err != nil {
@@ -541,24 +562,23 @@ 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
}
var targetFS fs.FS = fs.Local{}
targetFS := fs.NewLocal()
if runtime.GOOS == "windows" && opts.UseFsSnapshot {
if err = fs.HasSufficientPrivilegesForVSS(); err != nil {
return err
@@ -568,9 +588,9 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
_ = progressReporter.Error(item, err)
}
messageHandler := func(msg string, args ...interface{}) {
messageHandler := func(msg string, args ...any) {
if !gopts.JSON {
progressPrinter.P(msg, args...)
printer.P(msg, args...)
}
}
@@ -581,21 +601,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}
}
@@ -605,7 +626,7 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
}
// rejectFuncs collect functions that can reject items from the backup based on path and file info
rejectFuncs, err := collectRejectFuncs(opts, targets, targetFS)
rejectFuncs, err := collectRejectFuncs(opts, targets, targetFS, printer.E)
if err != nil {
return err
}
@@ -621,11 +642,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) })
}
@@ -634,7 +655,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)
@@ -648,6 +669,7 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
arch.CompleteItem = progressReporter.CompleteItem
arch.StartFile = progressReporter.StartFile
arch.CompleteBlob = progressReporter.CompleteBlob
arch.ExcludedItem = progressReporter.ExcludedItem
if opts.IgnoreInode {
// --ignore-inode implies --ignore-ctime: on FUSE, the ctime is not
@@ -665,12 +687,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)
+110 -56
View File
@@ -1,35 +1,49 @@
package main
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
"runtime"
"slices"
"strings"
"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/repository"
"github.com/restic/restic/internal/restic"
rtest "github.com/restic/restic/internal/test"
"github.com/restic/restic/internal/ui/termstatus"
"github.com/restic/restic/internal/ui/backup"
)
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 testRunBackupOutput(t testing.TB, opts BackupOptions, gopts global.Options, target []string) ([]byte, error) {
buf, err := withCaptureStdout(t, gopts, func(ctx context.Context, gopts global.Options) error {
return runBackup(ctx, opts, gopts, gopts.Term, target)
})
return buf.Bytes(), err
}
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: %v", err)
}
@@ -48,6 +62,9 @@ func testBackup(t *testing.T, useFsSnapshot bool) {
env, cleanup := withTestEnvironment(t)
defer cleanup()
// Use auto compression to ensure coverage in the integration tests
// All other tests use fastest compression for faster execution
env.gopts.Compression = repository.CompressionAuto
testSetupBackupData(t, env)
opts := BackupOptions{UseFsSnapshot: useFsSnapshot}
@@ -56,13 +73,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 +91,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 +102,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)
}
@@ -138,7 +155,7 @@ func (f *vssDeleteOriginalFS) Lstat(name string) (*fs.ExtendedFileInfo, error) {
_, _ = f.FS.Lstat(name)
// nuke testdata
var err error
for i := 0; i < 3; i++ {
for range 3 {
// The CI sometimes runs into "The process cannot access the file because it is being used by another process" errors
// thus try a few times to remove the data
err = os.RemoveAll(f.testdata)
@@ -218,41 +235,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 +279,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) {
@@ -438,13 +460,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)
}
@@ -454,14 +476,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()
@@ -481,7 +502,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)
@@ -497,7 +518,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()
@@ -509,7 +529,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)
}
@@ -567,7 +587,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"))
@@ -611,13 +631,7 @@ func linkEqual(source, dest []string) bool {
}
for i := range source {
found := false
for j := range dest {
if source[i] == dest[j] {
found = true
break
}
}
found := slices.Contains(dest, source[i])
if !found {
return false
}
@@ -632,12 +646,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)
}
@@ -700,7 +717,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)
@@ -716,10 +733,47 @@ func TestBackupSkipIfUnchanged(t *testing.T) {
testSetupBackupData(t, env)
opts := BackupOptions{SkipIfUnchanged: true}
for i := 0; i < 3; i++ {
for range 3 {
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts)
testListSnapshots(t, env.gopts, 1)
}
testRunCheck(t, env.gopts)
}
func TestBackupExcludeWithOutput(t *testing.T) {
env, cleanup := withTestEnvironment(t)
defer cleanup()
testSetupBackupData(t, env)
backupOptions := BackupOptions{}
backupOptions.Excludes = []string{"*.py"}
env.gopts.JSON = true
env.gopts.Verbosity = 2
output, err := testRunBackupOutput(t, backupOptions, env.gopts, []string{filepath.Join(env.testdata, "0", "for_cmd_ls")})
rtest.OK(t, err)
foundExclude := false
for line := range bytes.SplitSeq(output, []byte("\n")) {
if len(line) == 0 {
continue
}
type MessageType struct {
MessageType string `json:"message_type"` // any
}
var mType MessageType
rtest.OK(t, json.Unmarshal(line, &mType))
if mType.MessageType != "excluded_item" {
continue
}
var excludeLine backup.VerboseExclude
rtest.OK(t, json.Unmarshal(line, &excludeLine))
rtest.Assert(t, strings.Contains(excludeLine.Item, ".py"), "expected excluded pathname to be ending in .py, but contains %q",
excludeLine.Item)
foundExclude = true
}
rtest.Assert(t, foundExclude, "expected at least one excluded item, but found none")
}
+27 -1
View File
@@ -10,6 +10,7 @@ import (
"strings"
"testing"
"github.com/restic/restic/internal/errors"
rtest "github.com/restic/restic/internal/test"
)
@@ -67,10 +68,35 @@ 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 TestFilterExistingUnreadable(t *testing.T) {
dir := rtest.TempDir(t)
existing := filepath.Join(dir, "existing")
rtest.OK(t, os.Mkdir(existing, 0755))
file := filepath.Join(dir, "file")
rtest.OK(t, os.WriteFile(file, []byte("x"), 0600))
// Regression test for #5667. A target whose Lstat fails with an error other
// than ErrNotExist must be skipped (ENOTDIR on unix, NUL byte everywhere).
for _, unreadable := range []string{filepath.Join(file, "child"), "invalid\x00path"} {
result, err := filterExisting([]string{unreadable}, t.Logf)
rtest.Assert(t, errors.Is(err, ErrNoSourceData), "input %q: expected ErrNoSourceData; got %v", unreadable, err)
rtest.Assert(t, len(result) == 0, "input %q: expected no targets; got %v", unreadable, result)
result, err = filterExisting([]string{existing, unreadable}, t.Logf)
rtest.Assert(t, errors.Is(err, ErrInvalidSourceData), "input %q: expected ErrInvalidSourceData; got %v", unreadable, err)
rtest.Equals(t, []string{existing}, result)
}
}
func TestReadFilenamesRaw(t *testing.T) {
+13 -9
View File
@@ -10,13 +10,15 @@ import (
"github.com/restic/restic/internal/backend/cache"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/global"
"github.com/restic/restic/internal/ui"
"github.com/restic/restic/internal/ui/progress"
"github.com/restic/restic/internal/ui/table"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
func newCacheCommand() *cobra.Command {
func newCacheCommand(globalOptions *global.Options) *cobra.Command {
var opts CacheOptions
cmd := &cobra.Command{
@@ -34,7 +36,7 @@ Exit status is 1 if there was any error.
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
RunE: func(_ *cobra.Command, args []string) error {
return runCache(opts, globalOptions, args)
return runCache(opts, *globalOptions, args, globalOptions.Term)
},
}
@@ -55,7 +57,9 @@ func (opts *CacheOptions) AddFlags(f *pflag.FlagSet) {
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 := progress.NewTerminalPrinter(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")
}
@@ -83,17 +87,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 = os.RemoveAll(dir)
if err != nil {
Warnf("unable to remove %v: %v\n", dir, err)
printer.E("unable to remove %v: %v", dir, err)
}
}
@@ -123,7 +127,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
}
@@ -159,8 +163,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
}
+34 -35
View File
@@ -3,18 +3,23 @@ package main
import (
"context"
"encoding/json"
"slices"
"strings"
"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"
"github.com/restic/restic/internal/ui/progress"
)
var catAllowedCmds = []string{"config", "index", "snapshot", "key", "masterkey", "lock", "pack", "blob", "tree"}
func newCatCommand() *cobra.Command {
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",
@@ -33,7 +38,7 @@ 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)
return runCat(cmd.Context(), *globalOptions, args, globalOptions.Term)
},
ValidArgs: catAllowedCmds,
}
@@ -45,13 +50,7 @@ func validateCatArgs(args []string) error {
return errors.Fatal("type not specified")
}
validType := false
for _, v := range catAllowedCmds {
if v == args[0] {
validType = true
break
}
}
validType := slices.Contains(catAllowedCmds, args[0])
if !validType {
return errors.Fatalf("invalid type %q, must be one of [%s]", args[0], strings.Join(catAllowedCmds, "|"))
}
@@ -63,12 +62,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 := progress.NewTerminalPrinter(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
}
@@ -80,7 +81,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)
}
}
@@ -91,7 +92,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)
@@ -99,12 +100,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, "", " ")
@@ -112,7 +113,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)
@@ -125,7 +126,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(), "", " ")
@@ -133,10 +134,10 @@ 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)
lock, err := repository.LoadLock(ctx, repo, id)
if err != nil {
return err
}
@@ -146,7 +147,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string) error {
return err
}
Println(string(buf))
printer.S(string(buf))
return nil
case "pack":
@@ -158,57 +159,55 @@ 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
}
for _, t := range []restic.BlobType{restic.DataBlob, restic.TreeBlob} {
if _, ok := repo.LookupBlobSize(t, id); !ok {
if _, ok := repo.LookupBlobSize(restic.BlobHandle{Type: t, ID: id}); !ok {
continue
}
buf, err := repo.LoadBlob(ctx, t, id, nil)
buf, err := repo.LoadBlob(ctx, restic.BlobHandle{Type: t, ID: id}, nil)
if err != nil {
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
}
buf, err := repo.LoadBlob(ctx, restic.TreeBlob, *sn.Tree, nil)
buf, err := repo.LoadBlob(ctx, restic.BlobHandle{Type: restic.TreeBlob, ID: *sn.Tree}, nil)
if err != nil {
return err
}
_, err = globalOptions.stdout.Write(buf)
_, err = term.OutputRaw().Write(buf)
return err
default:
+129 -87
View File
@@ -15,25 +15,30 @@ import (
"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/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"
)
func newCheckCommand() *cobra.Command {
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.
finds.
By default, the "check" command will always load all data directly from the
repository and not use a local cache.
By default, check verifies the structural consistency and integrity of
snapshots, trees and pack files. To also verify the integrity of the actual
backed-up data, use the --read-data or --read-data-subset flags.
By default, check creates a new temporary cache directory to verify data.
To reuse the existing cache, use the --with-cache flag.
EXIT STATUS
===========
@@ -47,14 +52,13 @@ 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()
summary, err := runCheck(cmd.Context(), opts, globalOptions, args, term)
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
}
term.Print(ui.ToJSONString(summary))
globalOptions.Term.Print(ui.ToJSONString(summary))
}
return err
},
@@ -73,6 +77,7 @@ type CheckOptions struct {
ReadDataSubset string
CheckUnused bool
WithCache bool
data.SnapshotFilter
}
func (opts *CheckOptions) AddFlags(f *pflag.FlagSet) {
@@ -86,6 +91,7 @@ func (opts *CheckOptions) AddFlags(f *pflag.FlagSet) {
panic(err)
}
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 {
@@ -173,7 +179,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 restic.Printer) (cleanup func()) {
cleanup = func() {}
if opts.WithCache {
// use the default cache, no setup needed
@@ -194,7 +200,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
}
@@ -220,15 +226,12 @@ func prepareCheckCache(opts CheckOptions, gopts *GlobalOptions, printer progress
return cleanup
}
func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args []string, term *termstatus.Terminal) (checkSummary, error) {
func runCheck(ctx context.Context, opts CheckOptions, gopts global.Options, args []string, term ui.Terminal) (checkSummary, error) {
summary := checkSummary{MessageType: "summary"}
if len(args) != 0 {
return summary, errors.Fatal("the check command expects no arguments, only options - please see `restic help check` for usage and flags")
}
var printer progress.Printer
var printer restic.Printer
if !gopts.JSON {
printer = newTerminalProgressPrinter(gopts.verbosity, term)
printer = progress.NewTerminalPrinter(gopts.JSON, gopts.Verbosity, term)
} else {
printer = newJSONErrorPrinter(term)
}
@@ -239,32 +242,38 @@ 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 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 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 summary, ctx.Err()
}
errorsFound := false
salvagePacks := restic.NewIDSet()
for _, hint := range hints {
switch hint.(type) {
case *checker.ErrDuplicatePacks:
switch hint := hint.(type) {
case *repository.ErrIncompletePackEntry:
printer.E("%s", hint.Error())
salvagePacks.Insert(hint.PackID)
errorsFound = true
summary.NumErrors++
case *repository.ErrDuplicatePacks:
printer.S("%s", hint.Error())
summary.HintRepairIndex = true
case *checker.ErrMixedPack:
case *repository.ErrMixedPack:
printer.S("%s", hint.Error())
summary.HintPrune = true
default:
@@ -293,19 +302,18 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
orphanedPacks := 0
errChan := make(chan error)
salvagePacks := restic.NewIDSet()
printer.P("check all packs\n")
go chkr.Packs(ctx, errChan)
for err := range errChan {
var packErr *checker.PackError
var packErr *repository.ErrPackMetadata
if errors.As(err, &packErr) {
if packErr.Orphaned {
orphanedPacks++
printer.V("%v\n", err)
} else {
if packErr.Truncated {
if packErr.Truncated || packErr.Missing {
salvagePacks.Insert(packErr.ID)
}
errorsFound = true
@@ -331,25 +339,28 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
printer.P("check snapshots, trees and blobs\n")
errChan = make(chan error)
var brokenSnapshots []string
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
bar := printer.NewCounter("snapshots")
defer bar.Done()
chkr.Structure(ctx, bar, errChan)
}()
})
for err := range errChan {
errorsFound = true
if e, ok := err.(*checker.TreeError); ok {
switch e := err.(type) {
case *checker.TreeError:
printer.E("error for tree %v:\n", e.ID.Str())
for _, treeErr := range e.Errors {
summary.NumErrors++
printer.E(" %v\n", treeErr)
}
} else {
case *checker.SnapshotError:
printer.E("snapshot error %v: %v", e.ID, e.Message)
brokenSnapshots = append(brokenSnapshots, e.ID)
default:
summary.NumErrors++
printer.E("error: %v\n", err)
}
@@ -363,6 +374,7 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
return summary, ctx.Err()
}
// the following block only used for tests
if opts.CheckUnused {
unused, err := chkr.UnusedBlobs(ctx)
if err != nil {
@@ -374,12 +386,15 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
}
}
doReadData := func(packs map[restic.ID]int64) {
p := printer.NewCounter("packs")
p.SetMax(uint64(len(packs)))
readDataFilter, err := buildPacksFilter(opts, printer, chkr.IsFiltered())
if err != nil {
return summary, err
}
if readDataFilter != nil {
errChan := make(chan error)
go chkr.ReadPacks(ctx, packs, p, errChan)
go chkr.ReadPacks(ctx, readDataFilter, printer, errChan)
for err := range errChan {
errorsFound = true
@@ -389,48 +404,6 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
salvagePacks.Insert(err.PackID)
}
}
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 summary, 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 summary, errors.Fatal("internal error: failed to select packs to check")
}
doReadData(packs)
}
if len(salvagePacks) > 0 {
@@ -442,12 +415,18 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
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 len(brokenSnapshots) > 0 {
printer.E("\nThe repository contains damaged snapshot 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")
printer.E("restic repair snapshots --forget %s\n\n", strings.Join(brokenSnapshots, " "))
printer.E("Damaged snapshot 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 summary, ctx.Err()
}
if errorsFound {
if len(salvagePacks) == 0 {
if len(salvagePacks) == 0 && len(brokenSnapshots) == 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 summary, errors.Fatal("repository contains errors")
@@ -456,6 +435,64 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
return summary, nil
}
func buildPacksFilter(opts CheckOptions, printer restic.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.
func selectPacksByBucket(allPacks map[restic.ID]int64, bucket, totalBuckets uint) map[restic.ID]int64 {
packs := make(map[restic.ID]int64)
@@ -523,18 +560,23 @@ func newJSONErrorPrinter(term ui.Terminal) *jsonErrorPrinter {
}
}
func (*jsonErrorPrinter) NewCounter(_ string) *progress.Counter {
return nil
func (*jsonErrorPrinter) NewCounter(_ string) restic.Counter {
return restic.NoopCounter
}
func (p *jsonErrorPrinter) E(msg string, args ...interface{}) {
func (*jsonErrorPrinter) NewCounterTerminalOnly(_ string) restic.Counter {
return restic.NoopCounter
}
func (p *jsonErrorPrinter) E(msg string, args ...any) {
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) V(_ string, _ ...interface{}) {}
func (*jsonErrorPrinter) VV(_ string, _ ...interface{}) {}
func (*jsonErrorPrinter) S(_ string, _ ...any) {}
func (*jsonErrorPrinter) P(_ string, _ ...any) {}
func (*jsonErrorPrinter) PT(_ string, _ ...any) {}
func (*jsonErrorPrinter) V(_ string, _ ...any) {}
func (*jsonErrorPrinter) VV(_ string, _ ...any) {}
+75 -12
View File
@@ -1,39 +1,102 @@
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)
stdout, stderr, err := testRunCheckOutput(t, gopts, true)
if err != nil {
t.Error(output)
t.Error(stdout)
t.Error(stderr)
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, string, error) {
stdout, stderr, err := withCaptureStdoutStderr(t, gopts, func(ctx context.Context, gopts global.Options) error {
opts := CheckOptions{
ReadData: true,
CheckUnused: checkUnused,
}
_, err := runCheck(context.TODO(), opts, gopts, nil, term)
_, err := runCheck(ctx, opts, gopts, nil, gopts.Term)
return err
})
return stdout.String(), stderr.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(ctx, 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)
}
}
+5 -5
View File
@@ -9,9 +9,9 @@ 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"
)
func TestParsePercentage(t *testing.T) {
@@ -202,8 +202,8 @@ func TestPrepareCheckCache(t *testing.T) {
err := os.Remove(tmpDirBase)
rtest.OK(t, err)
}
gopts := GlobalOptions{CacheDir: tmpDirBase}
cleanup := prepareCheckCache(testCase.opts, &gopts, &progress.NoopPrinter{})
gopts := global.Options{CacheDir: tmpDirBase}
cleanup := prepareCheckCache(testCase.opts, &gopts, restic.NewNoopPrinter())
files, err := os.ReadDir(tmpDirBase)
rtest.OK(t, err)
@@ -232,8 +232,8 @@ func TestPrepareCheckCache(t *testing.T) {
}
func TestPrepareDefaultCheckCache(t *testing.T) {
gopts := GlobalOptions{CacheDir: ""}
cleanup := prepareCheckCache(CheckOptions{}, &gopts, &progress.NoopPrinter{})
gopts := global.Options{CacheDir: ""}
cleanup := prepareCheckCache(CheckOptions{}, &gopts, restic.NewNoopPrinter())
_, err := os.ReadDir(gopts.CacheDir)
rtest.OK(t, err)
+219 -112
View File
@@ -3,18 +3,24 @@ 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"
)
func newCopyCommand() *cobra.Command {
func newCopyCommand(globalOptions *global.Options) *cobra.Command {
var opts CopyOptions
cmd := &cobra.Command{
Use: "copy [flags] [snapshotID ...]",
@@ -46,7 +52,8 @@ 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(), opts, globalOptions, args)
finalizeSnapshotFilter(&opts.SnapshotFilter)
return runCopy(cmd.Context(), opts, *globalOptions, args, globalOptions.Term)
},
}
@@ -56,17 +63,63 @@ Exit status is 12 if the password is incorrect.
// CopyOptions bundles all options for the copy command.
type CopyOptions struct {
secondaryRepoOptions
restic.SnapshotFilter
global.SecondaryRepoOptions
data.SnapshotFilter
}
func (opts *CopyOptions) AddFlags(f *pflag.FlagSet) {
opts.secondaryRepoOptions.AddFlags(f, "destination", "to copy snapshots from")
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")
var errSentinelEndIteration = errors.New("end iteration")
// 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 restic.Printer,
) iter.Seq2[*data.Snapshot, error] {
return func(yield func(*data.Snapshot, error) bool) {
err := opts.SnapshotFilter.FindAll(ctx, srcSnapshotLister, srcRepo, args, func(_ string, sn *data.Snapshot, err error) error {
// check whether the destination has a snapshot with the same persistent ID which has similar snapshot fields
if err != nil {
if !yield(nil, err) {
return errSentinelEndIteration
}
return nil
}
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 {
return nil
}
}
if !yield(sn, nil) {
return errSentinelEndIteration
}
return nil
})
if err != nil && !errors.Is(err, errSentinelEndIteration) {
yield(nil, err)
}
}
}
func runCopy(ctx context.Context, opts CopyOptions, gopts global.Options, args []string, term ui.Terminal) error {
printer := progress.NewTerminalPrinter(false, gopts.Verbosity, term)
secondaryGopts, isFromRepo, err := opts.SecondaryRepoOptions.FillGlobalOpts(ctx, gopts, "destination")
if err != nil {
return err
}
@@ -75,13 +128,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
}
@@ -98,75 +151,40 @@ 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)
err = opts.SnapshotFilter.FindAll(ctx, dstSnapshotLister, dstRepo, nil, func(_ string, sn *data.Snapshot, err error) error {
if err != nil {
return err
}
if sn.Original != nil && !sn.Original.IsNull() {
dstSnapshotByOriginal[*sn.Original] = append(dstSnapshotByOriginal[*sn.Original], sn)
}
// also consider identical snapshot copies
dstSnapshotByOriginal[*sn.ID()] = append(dstSnapshotByOriginal[*sn.ID()], sn)
}
if ctx.Err() != nil {
return ctx.Err()
return nil
})
if err != nil {
return 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 ||
@@ -185,72 +203,161 @@ 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 *repository.Repository, dstRepo restic.Repository,
selectedSnapshots iter.Seq2[*data.Snapshot, error], printer restic.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.Pull2(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, err, ok := next()
if err != nil {
return err
}
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 *repository.Repository, dstRepo restic.Repository,
visitedTrees restic.AssociatedBlobSet, rootTreeID restic.ID, printer restic.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); !ok {
pb := srcRepo.LookupBlob(h)
copyBlobs.Insert(h)
for _, p := range pb {
packList.Insert(p.PackID())
}
}
}
err := data.StreamTrees(ctx, srcRepo, restic.IDs{rootTreeID}, restic.NoopCounter, 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 restic.Printer) uint64 {
// count and size
countBlobs := 0
sizeBlobs := uint64(0)
for blob := range copyBlobs.Keys() {
for _, pb := range srcRepo.LookupBlob(blob) {
countBlobs++
sizeBlobs += uint64(pb.CiphertextLength())
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 restic.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,
func(msg string, args ...interface{}) { fmt.Printf(msg+"\n", args...) },
)
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
}
+49 -9
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/progress"
)
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 both 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 := progress.NewTerminalPrinter(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 {
handles, err := repo.ListPackHandles(context.TODO(), id, size)
rtest.OK(t, err)
rtest.Assert(t, len(handles) > 0, "a packfile should contain at least one blob")
switch handles[0].Type {
case restic.TreeBlob:
countTreePacks++
case restic.DataBlob:
countDataPacks++
}
countBlobs += len(handles)
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)
+37 -399
View File
@@ -1,53 +1,44 @@
//go:build debug
// +build debug
package main
import (
"context"
"crypto/aes"
"crypto/cipher"
"encoding/json"
"fmt"
"io"
"os"
"runtime"
"sort"
"sync"
"time"
"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"
)
func registerDebugCommand(cmd *cobra.Command) {
func registerDebugCommand(cmd *cobra.Command, globalOptions *global.Options) {
cmd.AddCommand(
newDebugCommand(),
newDebugCommand(globalOptions),
)
}
func newDebugCommand() *cobra.Command {
func newDebugCommand(globalOptions *global.Options) *cobra.Command {
cmd := &cobra.Command{
Use: "debug",
Short: "Debug commands",
GroupID: cmdGroupDefault,
DisableAutoGenTag: true,
}
cmd.AddCommand(newDebugDumpCommand())
cmd.AddCommand(newDebugExamineCommand())
cmd.AddCommand(newDebugDumpCommand(globalOptions))
cmd.AddCommand(newDebugExamineCommand(globalOptions))
return cmd
}
func newDebugDumpCommand() *cobra.Command {
func newDebugDumpCommand(globalOptions *global.Options) *cobra.Command {
cmd := &cobra.Command{
Use: "dump [indexes|snapshots|all|packs]",
Short: "Dump data structures",
@@ -66,13 +57,13 @@ 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)
return runDebugDump(cmd.Context(), *globalOptions, args, globalOptions.Term)
},
}
return cmd
}
func newDebugExamineCommand() *cobra.Command {
func newDebugExamineCommand(globalOptions *global.Options) *cobra.Command {
var opts DebugExamineOptions
cmd := &cobra.Command{
@@ -80,7 +71,7 @@ func newDebugExamineCommand() *cobra.Command {
Short: "Examine a pack file",
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runDebugExamine(cmd.Context(), globalOptions, opts, args)
return runDebugExamine(cmd.Context(), *globalOptions, opts, args, globalOptions.Term)
},
}
@@ -113,7 +104,7 @@ 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
}
@@ -126,67 +117,14 @@ func debugPrintSnapshots(ctx context.Context, repo *repository.Repository, wr io
})
}
// Pack is the struct used in printPacks.
type Pack struct {
Name string `json:"name"`
func runDebugDump(ctx context.Context, gopts global.Options, args []string, term ui.Terminal) error {
printer := progress.NewTerminalPrinter(false, gopts.Verbosity, term)
Blobs []Blob `json:"blobs"`
}
// Blob is the struct used in printPacks.
type Blob struct {
Type restic.BlobType `json:"type"`
Length uint `json:"length"`
ID restic.ID `json:"id"`
Offset uint `json:"offset"`
}
func printPacks(ctx context.Context, repo *repository.Repository, wr io.Writer) 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)
return nil
}
p := Pack{
Name: id.String(),
Blobs: make([]Blob, len(blobs)),
}
for i, blob := range blobs {
p.Blobs[i] = Blob{
Type: blob.Type,
Length: blob.Length,
ID: blob.ID,
Offset: blob.Offset,
}
}
m.Lock()
defer m.Unlock()
return prettyPrintJSON(wr, p)
})
}
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, err error) error {
Printf("index_id: %v\n", id)
if err != nil {
return err
}
return idx.Dump(wr)
})
}
func runDebugDump(ctx context.Context, gopts GlobalOptions, args []string) error {
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
}
@@ -196,20 +134,20 @@ func runDebugDump(ctx context.Context, gopts GlobalOptions, args []string) error
switch tpe {
case "indexes":
return dumpIndexes(ctx, repo, globalOptions.stdout)
return repository.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 repository.DumpPacks(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 = repository.DumpIndexes(ctx, repo, gopts.Term.OutputWriter(), printer)
if err != nil {
return err
}
@@ -220,242 +158,14 @@ func runDebugDump(ctx context.Context, gopts GlobalOptions, args []string) error
}
}
func tryRepairWithBitflip(key *crypto.Key, input []byte, bytewise bool) []byte {
if bytewise {
Printf(" trying to repair blob by finding a broken byte\n")
} else {
Printf(" trying to repair blob with single bit flip\n")
}
func runDebugExamine(ctx context.Context, gopts global.Options, opts DebugExamineOptions, args []string, term ui.Terminal) error {
printer := progress.NewTerminalPrinter(false, gopts.Verbosity, term)
ch := make(chan int)
var wg errgroup.Group
done := make(chan struct{})
var fixed []byte
var found bool
workers := runtime.GOMAXPROCS(0)
Printf(" spinning up %d worker functions\n", runtime.GOMAXPROCS(0))
for i := 0; i < workers; i++ {
wg.Go(func() error {
// make a local copy of the buffer
buf := make([]byte, len(input))
copy(buf, input)
testFlip := func(idx int, pattern byte) bool {
// flip bits
buf[idx] ^= pattern
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))
close(done)
found = true
fixed = plaintext
return true
}
// flip bits back
buf[idx] ^= pattern
return false
}
for i := range ch {
if bytewise {
for j := 0; j < 255; j++ {
if testFlip(i, byte(j)) {
return nil
}
}
} else {
for j := 0; j < 7; j++ {
// flip each bit once
if testFlip(i, (1 << uint(j))) {
return nil
}
}
}
}
return nil
})
}
wg.Go(func() error {
defer close(ch)
start := time.Now()
info := time.Now()
for i := range input {
select {
case ch <- i:
case <-done:
Printf(" done after %v\n", time.Since(start))
return nil
}
if time.Since(info) > time.Second {
secs := time.Since(start).Seconds()
gps := float64(i) / secs
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",
i, len(input), float32(i)/float32(len(input))*100, gps, eta)
info = time.Now()
}
}
return nil
})
err := wg.Wait()
if err != nil {
panic("all go routines can only return nil")
}
if !found {
Printf("\n blob could not be repaired\n")
}
return fixed
}
func decryptUnsigned(k *crypto.Key, buf []byte) []byte {
// strip signature at the end
l := len(buf)
nonce, ct := buf[:16], buf[16:l-16]
out := make([]byte, len(ct))
c, err := aes.NewCipher(k.EncryptionKey[:])
if err != nil {
panic(fmt.Sprintf("unable to create cipher: %v", err))
}
e := cipher.NewCTR(c, nonce)
e.XORKeyStream(out, ct)
return out
}
func loadBlobs(ctx context.Context, opts DebugExamineOptions, repo restic.Repository, packID restic.ID, list []restic.Blob) error {
dec, err := zstd.NewReader(nil)
if err != nil {
panic(err)
}
pack, err := repo.LoadRaw(ctx, restic.PackFile, packID)
// allow processing broken pack files
if pack == nil {
return err
}
wg, ctx := errgroup.WithContext(ctx)
if opts.ReuploadBlobs {
repo.StartPackUploader(ctx, wg)
}
wg.Go(func() error {
for _, blob := range list {
Printf(" loading blob %v at %v (length %v)\n", blob.ID, blob.Offset, blob.Length)
if int(blob.Offset+blob.Length) > len(pack) {
Warnf("skipping truncated blob\n")
continue
}
buf := pack[blob.Offset : blob.Offset+blob.Length]
key := repo.Key()
nonce, plaintext := buf[:key.NonceSize()], buf[key.NonceSize():]
plaintext, err = key.Open(plaintext[:0], nonce, plaintext, nil)
outputPrefix := ""
filePrefix := ""
if err != nil {
Warnf("error decrypting blob: %v\n", err)
if opts.TryRepair || opts.RepairByte {
plaintext = tryRepairWithBitflip(key, buf, opts.RepairByte)
}
if plaintext != nil {
outputPrefix = "repaired "
filePrefix = "repaired-"
} else {
plaintext = decryptUnsigned(key, buf)
err = storePlainBlob(blob.ID, "damaged-", plaintext)
if err != nil {
return err
}
continue
}
}
if blob.IsCompressed() {
decompressed, err := dec.DecodeAll(plaintext, nil)
if err != nil {
Printf(" failed to decompress blob %v\n", blob.ID)
}
if decompressed != nil {
plaintext = decompressed
}
}
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)
prefix = "wrong-hash-"
} else {
Printf(" successfully %vdecrypted blob (length %v), hash is %v, ID matches\n", outputPrefix, len(plaintext), id)
prefix = "correct-"
}
if opts.ExtractPack {
err = storePlainBlob(id, filePrefix+prefix, plaintext)
if err != nil {
return err
}
}
if opts.ReuploadBlobs {
_, _, _, err := repo.SaveBlob(ctx, blob.Type, plaintext, id, true)
if err != nil {
return err
}
Printf(" uploaded %v %v\n", blob.Type, id)
}
}
if opts.ReuploadBlobs {
return repo.Flush(ctx)
}
return nil
})
return wg.Wait()
}
func storePlainBlob(id restic.ID, prefix string, plain []byte) error {
filename := fmt.Sprintf("%s%s.bin", prefix, id)
f, err := os.Create(filename)
if err != nil {
return err
}
_, err = f.Write(plain)
if err != nil {
_ = f.Close()
return err
}
err = f.Close()
if err != nil {
return err
}
Printf("decrypt of blob %v stored at %v\n", id, filename)
return nil
}
func runDebugExamine(ctx context.Context, gopts GlobalOptions, opts DebugExamineOptions, args []string) error {
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
}
@@ -467,7 +177,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
}
}
@@ -478,16 +188,21 @@ 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
}
examineOpts := repository.ExaminePackOptions{
TryRepair: opts.TryRepair,
RepairByte: opts.RepairByte,
ExtractPack: opts.ExtractPack,
ReuploadBlobs: opts.ReuploadBlobs,
}
for _, id := range ids {
err := examinePack(ctx, opts, repo, id)
err := repository.ExaminePack(ctx, repo, id, examineOpts, printer)
if err != nil {
Warnf("error: %v\n", err)
printer.E("error: %v", err)
}
if err == context.Canceled {
break
@@ -495,80 +210,3 @@ 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)
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))
gotID := restic.Hash(buf)
if !id.Equal(gotID) {
Printf(" wanted hash %v, got %v\n", id, gotID)
} else {
Printf(" hash for file content matches\n")
}
Printf(" ========================================\n")
Printf(" looking for info in the indexes\n")
blobsLoaded := false
// examine all data the indexes have for the pack file
for b := range repo.ListPacksFromIndex(ctx, restic.NewIDSet(id)) {
blobs := b.Blobs
if len(blobs) == 0 {
continue
}
checkPackSize(blobs, len(buf))
err = loadBlobs(ctx, opts, repo, id, blobs)
if err != nil {
Warnf("error: %v\n", err)
} else {
blobsLoaded = true
}
}
Printf(" ========================================\n")
Printf(" inspect the pack itself\n")
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))
if !blobsLoaded {
return loadBlobs(ctx, opts, repo, id, blobs)
}
return nil
}
func checkPackSize(blobs []restic.Blob, fileSize int) {
// track current size and offset
var size, offset uint64
sort.Slice(blobs, func(i, j int) bool {
return blobs[i].Offset < blobs[j].Offset
})
for _, pb := range blobs {
Printf(" %v blob %v, offset %-6d, raw length %-6d\n", 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)
}
offset = uint64(pb.Offset + pb.Length)
size += uint64(pb.Length)
}
size += uint64(pack.CalculateHeaderSize(blobs))
if uint64(fileSize) != size {
Printf(" file sizes do not match: computed %v, file size is %v\n", size, fileSize)
} else {
Printf(" file sizes match\n")
}
}
+5 -2
View File
@@ -2,8 +2,11 @@
package main
import "github.com/spf13/cobra"
import (
"github.com/restic/restic/internal/global"
"github.com/spf13/cobra"
)
func registerDebugCommand(_ *cobra.Command) {
func registerDebugCommand(_ *cobra.Command, _ *global.Options) {
// No commands to register in non-debug mode
}
+104 -107
View File
@@ -5,17 +5,19 @@ 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/restic/restic/internal/ui/progress"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
func newDiffCommand() *cobra.Command {
func newDiffCommand(globalOptions *global.Options) *cobra.Command {
var opts DiffOptions
cmd := &cobra.Command{
@@ -38,7 +40,7 @@ Metadata comparison will likely not work if a backup was created using the
To only compare files in specific subfolders, you can use the
"snapshotID:subfolder" syntax, where "subfolder" is a path within the
snapshot.
snapshot tree as shown by "restic ls".
EXIT STATUS
===========
@@ -52,7 +54,7 @@ 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(), opts, globalOptions, args)
return runDiff(cmd.Context(), opts, *globalOptions, args, globalOptions.Term)
},
}
@@ -69,10 +71,10 @@ 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
}
@@ -82,6 +84,7 @@ type Comparer struct {
repo restic.BlobLoader
opts DiffOptions
printChange func(change *Change)
printError func(string, ...any)
}
type Change struct {
@@ -105,15 +108,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 restic.NodeTypeFile:
case data.NodeTypeFile:
s.Files++
case restic.NodeTypeDir:
case data.NodeTypeDir:
s.Dirs++
default:
s.Others++
@@ -121,13 +124,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 restic.NodeTypeFile:
case data.NodeTypeFile:
for _, blob := range node.Content {
h := restic.BlobHandle{
ID: blob,
@@ -135,7 +138,7 @@ func addBlobs(bs restic.BlobSet, node *restic.Node) {
}
bs.Insert(h)
}
case restic.NodeTypeDir:
case data.NodeTypeDir:
h := restic.BlobHandle{
ID: *node.Subtree,
Type: restic.TreeBlob,
@@ -145,18 +148,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, ...any)) {
for h := range blobs.Keys() {
switch h.Type {
case restic.DataBlob:
stats.DataBlobs++
@@ -164,9 +167,9 @@ func updateBlobs(repo restic.Loader, blobs restic.BlobSet, stats *DiffStat) {
stats.TreeBlobs++
}
size, found := repo.LookupBlobSize(h.Type, h.ID)
size, found := repo.LookupBlobSize(h)
if !found {
Warnf("unable to find blob size for %v\n", h)
printError("unable to find blob size for %v", h)
continue
}
@@ -174,30 +177,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 == restic.NodeTypeDir {
if node.Type == data.NodeTypeDir {
name += "/"
}
c.printChange(NewChange(name, mode))
stats.Add(node)
addBlobs(blobs, node)
if node.Type == restic.NodeTypeDir {
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)
}
}
}
@@ -205,24 +211,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 == restic.NodeTypeDir {
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)
}
}
}
@@ -230,56 +240,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 := ""
@@ -287,12 +282,12 @@ func (c *Comparer) diffTree(ctx context.Context, stats *DiffStatsContainer, pref
mod += "T"
}
if node2.Type == restic.NodeTypeDir {
if node2.Type == data.NodeTypeDir {
name += "/"
}
if node1.Type == restic.NodeTypeFile &&
node2.Type == restic.NodeTypeFile &&
if node1.Type == data.NodeTypeFile &&
node2.Type == data.NodeTypeFile &&
!reflect.DeepEqual(node1.Content, node2.Content) {
mod += "M"
stats.ChangedFiles++
@@ -314,7 +309,7 @@ func (c *Comparer) diffTree(ctx context.Context, stats *DiffStatsContainer, pref
c.printChange(NewChange(name, mod))
}
if node1.Type == restic.NodeTypeDir && node2.Type == restic.NodeTypeDir {
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)
@@ -322,35 +317,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 == restic.NodeTypeDir {
if node1.Type == data.NodeTypeDir {
prefix += "/"
}
c.printChange(NewChange(prefix, "-"))
stats.Removed.Add(node1)
if node1.Type == restic.NodeTypeDir {
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 == restic.NodeTypeDir {
if node2.Type == data.NodeTypeDir {
prefix += "/"
}
c.printChange(NewChange(prefix, "+"))
stats.Added.Add(node2)
if node2.Type == restic.NodeTypeDir {
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)
}
}
}
@@ -359,12 +354,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 := progress.NewTerminalPrinter(gopts.JSON, gopts.Verbosity, term)
ctx, repo, unlock, err := openWithReadLock(ctx, gopts, gopts.NoLock, printer)
if err != nil {
return err
}
@@ -386,10 +383,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
}
@@ -401,30 +397,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)
}
}
}
@@ -437,9 +434,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})
@@ -450,23 +447,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(stats.Added.Bytes))
Printf(" Removed: %-5s\n", ui.FormatBytes(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

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