From 7f2fcc004619375836a21d536d85b5f1612442d4 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Sun, 17 Nov 2024 12:33:23 +0200 Subject: [PATCH] added manual WAL checkpoints before creating the zip backup to avoid copying unnecessary data --- core/base_backup.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/base_backup.go b/core/base_backup.go index 2b272bd8..81ed764e 100644 --- a/core/base_backup.go +++ b/core/base_backup.go @@ -76,6 +76,11 @@ func (app *BaseApp) CreateBackup(ctx context.Context, name string) error { tempPath := filepath.Join(localTempDir, "pb_backup_"+security.PseudorandomString(6)) createErr := e.App.RunInTransaction(func(txApp App) error { return txApp.AuxRunInTransaction(func(txApp App) error { + // run manual checkpoint and truncate the WAL files + // (errors are ignored because it is not that important and the PRAGMA may not be supported by the used driver) + txApp.DB().NewQuery("PRAGMA wal_checkpoint(TRUNCATE)").Execute() + txApp.AuxDB().NewQuery("PRAGMA wal_checkpoint(TRUNCATE)").Execute() + return archive.Create(txApp.DataDir(), tempPath, e.Exclude...) }) })