fixed backups
This commit is contained in:
parent
a5ecd217c8
commit
e150a84782
2 changed files with 29 additions and 5 deletions
1
todo.md
1
todo.md
|
@ -1,4 +1,3 @@
|
|||
# Todo
|
||||
- start cron jobs after backup restore?
|
||||
- fix watchTemplates after filter.Var2 change
|
||||
- fix schedules layout, h5 schedule td ?
|
33
web/web.go
33
web/web.go
|
@ -1285,12 +1285,35 @@ func (web *Web) backupRestore(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
web.cron.Stop()
|
||||
|
||||
err = web.db.Transaction(func(tx *gorm.DB) error {
|
||||
delete := tx.Where("1 = 1").Delete(&Watch{})
|
||||
if delete.Error != nil {
|
||||
connections := tx.Where("1 = 1").Delete(&FilterConnection{})
|
||||
if connections.Error != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
values := tx.Where("1 = 1").Delete(&FilterOutput{})
|
||||
if values.Error != nil {
|
||||
return err
|
||||
}
|
||||
filters := tx.Where("1 = 1").Delete(&Filter{})
|
||||
if filters.Error != nil {
|
||||
return err
|
||||
}
|
||||
watches := tx.Where("1 = 1").Delete(&Watch{})
|
||||
if watches.Error != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
c.HTML(http.StatusOK, "backupView", gin.H{
|
||||
"Error": err,
|
||||
"urlPrefix": web.urlPrefix,
|
||||
})
|
||||
return
|
||||
}
|
||||
err = web.db.Transaction(func(tx *gorm.DB) error {
|
||||
watches := tx.Create(&backup.Watches)
|
||||
if watches.Error != nil {
|
||||
return err
|
||||
|
@ -1313,13 +1336,15 @@ func (web *Web) backupRestore(c *gin.Context) {
|
|||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
c.HTML(http.StatusOK, "backupRestore", gin.H{
|
||||
c.HTML(http.StatusOK, "backupView", gin.H{
|
||||
"Error": err,
|
||||
"urlPrefix": web.urlPrefix,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
go web.initCronJobs()
|
||||
|
||||
c.HTML(http.StatusOK, "backupRestore", gin.H{
|
||||
"Backup": backup,
|
||||
"BackupPath": backupFullPath,
|
||||
|
|
Loading…
Add table
Reference in a new issue