Send restoration status information to the console

This commit is contained in:
Dane Everitt 2021-01-30 18:49:07 -08:00
parent adc0732af3
commit 4bd18f7dd8
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
2 changed files with 8 additions and 3 deletions

View File

@ -99,12 +99,15 @@ func postServerRestoreBackup(c *gin.Context) {
middleware.CaptureAndAbort(c, err)
return
}
go func(logger *log.Entry) {
logger.Info("restoring server from local backup...")
go func(s *server.Server, b backup.BackupInterface, logger *log.Entry) {
logger.Info("starting restoration process for server backup using local driver")
if err := s.RestoreBackup(b, nil); err != nil {
logger.WithField("error", err).Error("failed to restore local backup to server")
}
}(logger)
s.Events().Publish(server.DaemonMessageEvent, "Completed server restoration from local backup.")
s.Events().Publish(server.BackupRestoreCompletedEvent, "")
logger.Info("completed server restoration from local backup")
}(s, b, logger)
c.Status(http.StatusAccepted)
return
}
@ -143,6 +146,7 @@ func postServerRestoreBackup(c *gin.Context) {
if err := s.RestoreBackup(backup.NewS3(uuid, ""), res.Body); err != nil {
logger.WithField("error", errors.WithStack(err)).Error("failed to restore remote S3 backup to server")
}
s.Events().Publish(server.DaemonMessageEvent, "Completed server restoration from S3 backup.")
s.Events().Publish(server.BackupRestoreCompletedEvent, "")
logger.Info("completed server restoration from S3 backup")
}(s, c.Param("backup"), logger)

View File

@ -151,6 +151,7 @@ func (s *Server) RestoreBackup(b backup.BackupInterface, reader io.ReadCloser) (
// in the file one at a time and writing them to the disk.
s.Log().Debug("starting file writing process for backup restoration")
err = b.Restore(reader, func(file string, r io.Reader) error {
s.Events().Publish(DaemonMessageEvent, "(restoring): "+file)
return s.Filesystem().Writefile(file, r)
})