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
|
# Todo
|
||||||
- start cron jobs after backup restore?
|
|
||||||
- fix watchTemplates after filter.Var2 change
|
- fix watchTemplates after filter.Var2 change
|
||||||
- fix schedules layout, h5 schedule td ?
|
- 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
web.cron.Stop()
|
||||||
|
|
||||||
err = web.db.Transaction(func(tx *gorm.DB) error {
|
err = web.db.Transaction(func(tx *gorm.DB) error {
|
||||||
delete := tx.Where("1 = 1").Delete(&Watch{})
|
connections := tx.Where("1 = 1").Delete(&FilterConnection{})
|
||||||
if delete.Error != nil {
|
if connections.Error != nil {
|
||||||
return err
|
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)
|
watches := tx.Create(&backup.Watches)
|
||||||
if watches.Error != nil {
|
if watches.Error != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -1313,13 +1336,15 @@ func (web *Web) backupRestore(c *gin.Context) {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.HTML(http.StatusOK, "backupRestore", gin.H{
|
c.HTML(http.StatusOK, "backupView", gin.H{
|
||||||
"Error": err,
|
"Error": err,
|
||||||
"urlPrefix": web.urlPrefix,
|
"urlPrefix": web.urlPrefix,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
go web.initCronJobs()
|
||||||
|
|
||||||
c.HTML(http.StatusOK, "backupRestore", gin.H{
|
c.HTML(http.StatusOK, "backupRestore", gin.H{
|
||||||
"Backup": backup,
|
"Backup": backup,
|
||||||
"BackupPath": backupFullPath,
|
"BackupPath": backupFullPath,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue