mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 23:09:41 +02:00
fix(migration): close the database before running backups EE-3627 (#7218)
* fix(migration): close the database before running backups On certain filesystems, particuarly NTFS when a network mounted windows file server is used to store portainer's database, you are unable to copy the database while it is open. To fix this we simply close the database and then re-open it after a backup. * handle close and open errors * dont return error on nil
This commit is contained in:
parent
5fd202d629
commit
958a8e97e9
1 changed files with 19 additions and 1 deletions
|
@ -103,8 +103,26 @@ func (store *Store) backupWithOptions(options *BackupOptions) (string, error) {
|
||||||
store.createBackupFolders()
|
store.createBackupFolders()
|
||||||
|
|
||||||
options = store.setupOptions(options)
|
options = store.setupOptions(options)
|
||||||
|
dbPath := store.databasePath()
|
||||||
|
|
||||||
return options.BackupPath, store.copyDBFile(store.databasePath(), options.BackupPath)
|
if err := store.Close(); err != nil {
|
||||||
|
return options.BackupPath, fmt.Errorf(
|
||||||
|
"error closing datastore before creating backup: %v",
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := store.copyDBFile(dbPath, options.BackupPath); err != nil {
|
||||||
|
return options.BackupPath, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := store.Open(); err != nil {
|
||||||
|
return options.BackupPath, fmt.Errorf(
|
||||||
|
"error opening datastore after creating backup: %v",
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return options.BackupPath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestoreWithOptions previously saved backup for the current Edition with options
|
// RestoreWithOptions previously saved backup for the current Edition with options
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue