From 70347e95d5799b6eb798eb12f1908a1e4a16d4b8 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Fri, 12 Jun 2020 09:24:38 +0200 Subject: [PATCH] disable index uploads for prune command + modifications of changelog --- changelog/unreleased/pull-2773 | 6 ++---- cmd/restic/cmd_prune.go | 3 +++ internal/repository/packer_manager.go | 3 +++ internal/repository/repository.go | 5 +++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/changelog/unreleased/pull-2773 b/changelog/unreleased/pull-2773 index 800583f94..9a4622c2f 100644 --- a/changelog/unreleased/pull-2773 +++ b/changelog/unreleased/pull-2773 @@ -1,8 +1,6 @@ -Enhancement: Optimize repository implementation - -We've optimized the implementation of handling index entries in the repository. +Enhancement: Optimize handling of new index entries Restic now uses less memory for backups which add a lot of data, e.g. large initial backups. -Also it is more stable in some edge situations and allows easier future enhancments. +In addition, we've improved the stability in some edge cases. https://github.com/restic/restic/pull/2773 diff --git a/cmd/restic/cmd_prune.go b/cmd/restic/cmd_prune.go index 07d005c65..6a3af8332 100644 --- a/cmd/restic/cmd_prune.go +++ b/cmd/restic/cmd_prune.go @@ -87,6 +87,9 @@ func runPrune(gopts GlobalOptions) error { return err } + // we do not need index updates while pruning! + repo.DisableAutoIndexUpdate() + return pruneRepository(gopts, repo) } diff --git a/internal/repository/packer_manager.go b/internal/repository/packer_manager.go index e1382c0be..7cfa67004 100644 --- a/internal/repository/packer_manager.go +++ b/internal/repository/packer_manager.go @@ -140,6 +140,9 @@ func (r *Repository) savePacker(ctx context.Context, t restic.BlobType, p *Packe r.idx.StorePack(id, p.Packer.Blobs()) // Save index if full + if r.noAutoIndexUpdate { + return nil + } return r.SaveFullIndex(ctx) } diff --git a/internal/repository/repository.go b/internal/repository/repository.go index eba8a1362..2ccaa0a87 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -28,6 +28,7 @@ type Repository struct { keyName string idx *MasterIndex restic.Cache + noAutoIndexUpdate bool treePM *packerManager dataPM *packerManager @@ -45,6 +46,10 @@ func New(be restic.Backend) *Repository { return repo } +func (r *Repository) DisableAutoIndexUpdate() { + r.noAutoIndexUpdate = true +} + // Config returns the repository configuration. func (r *Repository) Config() restic.Config { return r.cfg