diff --git a/shell.go b/shell.go index e017f0c..1a891d2 100644 --- a/shell.go +++ b/shell.go @@ -225,6 +225,9 @@ GLOBAL OPTIONS: if err := db.Find(&config.ACLs).Error; err != nil { return err } + if err := db.Find(&config.Settings).Error; err != nil { + return err + } config.Date = time.Now() enc := json.NewEncoder(s) if c.Bool("indent") { @@ -255,6 +258,7 @@ GLOBAL OPTIONS: fmt.Fprintf(s, "* %d UserGroups\n", len(config.UserGroups)) fmt.Fprintf(s, "* %d Userkeys\n", len(config.UserKeys)) fmt.Fprintf(s, "* %d Users\n", len(config.Users)) + fmt.Fprintf(s, "* %d Settings\n", len(config.Settings)) if !c.Bool("confirm") { fmt.Fprintf(s, "restore will erase and replace everything in the database.\nIf you are ok, add the '--confirm' to the restore command\n") @@ -264,7 +268,7 @@ GLOBAL OPTIONS: tx := db.Begin() // FIXME: do everything in a transaction - for _, tableName := range []string{"hosts", "users", "acls", "host_groups", "user_groups", "ssh_keys", "user_keys"} { + for _, tableName := range []string{"hosts", "users", "acls", "host_groups", "user_groups", "ssh_keys", "user_keys", "settings"} { if err := tx.Exec(fmt.Sprintf("DELETE FROM %s;", tableName)).Error; err != nil { tx.Rollback() return err @@ -312,6 +316,12 @@ GLOBAL OPTIONS: return err } } + for _, setting := range config.Settings { + if err := tx.Create(&setting).Error; err != nil { + tx.Rollback() + return err + } + } if err := tx.Commit().Error; err != nil { return err