added manual WAL checkpoints before creating the zip backup to avoid copying unnecessary data

This commit is contained in:
Gani Georgiev 2024-11-17 12:33:23 +02:00
parent 32e0eadc2f
commit 7f2fcc0046
1 changed files with 5 additions and 0 deletions

View File

@ -76,6 +76,11 @@ func (app *BaseApp) CreateBackup(ctx context.Context, name string) error {
tempPath := filepath.Join(localTempDir, "pb_backup_"+security.PseudorandomString(6)) tempPath := filepath.Join(localTempDir, "pb_backup_"+security.PseudorandomString(6))
createErr := e.App.RunInTransaction(func(txApp App) error { createErr := e.App.RunInTransaction(func(txApp App) error {
return txApp.AuxRunInTransaction(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...) return archive.Create(txApp.DataDir(), tempPath, e.Exclude...)
}) })
}) })