@@ -333,7 +333,12 @@ export class Controller extends events.EventEmitter<ControllerEventMap> {
333333 logger . error ( `Failed to disable join on stop: ${ error } ` , NS ) ;
334334 }
335335
336- await this . backup ( ) ; // always calls databaseSave()
336+ try {
337+ await this . backup ( ) ; // always calls databaseSave()
338+ } catch ( error ) {
339+ logger . error ( `Failed to backup on stop ${ error } ` , NS ) ;
340+ }
341+
337342 await this . adapter . stop ( ) ;
338343
339344 this . adapterDisconnected = true ;
@@ -365,17 +370,13 @@ export class Controller extends events.EventEmitter<ControllerEventMap> {
365370 if ( this . options . backupPath && this . adapter . supportsBackup ) {
366371 logger . debug ( "Creating coordinator backup" , NS ) ;
367372
368- try {
369- const backup = await this . adapter . backup ( this . getDeviceIeeeAddresses ( ) ) ;
370- const unifiedBackup = BackupUtils . toUnifiedBackup ( backup ) ;
371- const tmpBackupPath = `${ this . options . backupPath } .tmp` ;
373+ const backup = await this . adapter . backup ( this . getDeviceIeeeAddresses ( ) ) ;
374+ const unifiedBackup = BackupUtils . toUnifiedBackup ( backup ) ;
375+ const tmpBackupPath = `${ this . options . backupPath } .tmp` ;
372376
373- fs . writeFileSync ( tmpBackupPath , JSON . stringify ( unifiedBackup , null , 2 ) ) ;
374- fs . renameSync ( tmpBackupPath , this . options . backupPath ) ;
375- logger . info ( `Wrote coordinator backup to '${ this . options . backupPath } '` , NS ) ;
376- } catch ( error ) {
377- logger . error ( `Unable to backup ${ error } ` , NS ) ;
378- }
377+ fs . writeFileSync ( tmpBackupPath , JSON . stringify ( unifiedBackup , null , 2 ) ) ;
378+ fs . renameSync ( tmpBackupPath , this . options . backupPath ) ;
379+ logger . info ( `Wrote coordinator backup to '${ this . options . backupPath } '` , NS ) ;
379380 }
380381 }
381382
0 commit comments