1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-09-16 17:46:19 +02:00

[#5541] lock the logs database during backup

This commit is contained in:
Gani Georgiev
2024-09-18 06:24:22 +03:00
parent 5547c0dede
commit ad92992324
34 changed files with 51 additions and 44 deletions

View File

@@ -72,9 +72,11 @@ func (app *BaseApp) CreateBackup(ctx context.Context, name string) error {
// Run in transaction to temporary block other writes (transactions uses the NonconcurrentDB connection).
// ---
tempPath := filepath.Join(localTempDir, "pb_backup_"+security.PseudorandomString(4))
createErr := app.Dao().RunInTransaction(func(txDao *daos.Dao) error {
// @todo consider experimenting with temp switching the readonly pragma after the db interface change
return archive.Create(app.DataDir(), tempPath, exclude...)
createErr := app.Dao().RunInTransaction(func(dataTXDao *daos.Dao) error {
return app.LogsDao().RunInTransaction(func(logsTXDao *daos.Dao) error {
// @todo consider experimenting with temp switching the readonly pragma after the db interface change
return archive.Create(app.DataDir(), tempPath, exclude...)
})
})
if createErr != nil {
return createErr