summaryrefslogtreecommitdiff
path: root/system/admin/handlers.go
diff options
context:
space:
mode:
authorSteve <nilslice@gmail.com>2017-01-24 10:35:18 -0800
committerGitHub <noreply@github.com>2017-01-24 10:35:18 -0800
commit3a897e4db97cc6f5e47f395662499402eb4c2bda (patch)
tree61350d459fb5cbf044e878042c0239acb060c7da /system/admin/handlers.go
parent0cf0d36f7613bbb2e13c0c8406689de3be9ee8d5 (diff)
[core] System backups (uploads, system.db, analytics.db) (#42)
Diffstat (limited to 'system/admin/handlers.go')
-rw-r--r--system/admin/handlers.go34
1 files changed, 33 insertions, 1 deletions
diff --git a/system/admin/handlers.go b/system/admin/handlers.go
index 3195239..a99a62c 100644
--- a/system/admin/handlers.go
+++ b/system/admin/handlers.go
@@ -19,13 +19,14 @@ import (
"github.com/ponzu-cms/ponzu/system/admin/upload"
"github.com/ponzu-cms/ponzu/system/admin/user"
"github.com/ponzu-cms/ponzu/system/api"
+ "github.com/ponzu-cms/ponzu/system/api/analytics"
"github.com/ponzu-cms/ponzu/system/db"
"github.com/ponzu-cms/ponzu/system/item"
- "github.com/tidwall/gjson"
"github.com/gorilla/schema"
emailer "github.com/nilslice/email"
"github.com/nilslice/jwt"
+ "github.com/tidwall/gjson"
)
func adminHandler(res http.ResponseWriter, req *http.Request) {
@@ -188,6 +189,37 @@ func configHandler(res http.ResponseWriter, req *http.Request) {
}
+func backupHandler(res http.ResponseWriter, req *http.Request) {
+ switch req.URL.Query().Get("source") {
+ case "system":
+ err := db.Backup(res)
+ if err != nil {
+ log.Println("Failed to run backup on system:", err)
+ res.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+
+ case "analytics":
+ err := analytics.Backup(res)
+ if err != nil {
+ log.Println("Failed to run backup on analytics:", err)
+ res.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+
+ case "uploads":
+ err := upload.Backup(res)
+ if err != nil {
+ log.Println("Failed to run backup on uploads:", err)
+ res.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+
+ default:
+ res.WriteHeader(http.StatusBadRequest)
+ }
+}
+
func configUsersHandler(res http.ResponseWriter, req *http.Request) {
switch req.Method {
case http.MethodGet: