mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
REST API dumpdata: allow to specify the resources to dump
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -51,6 +51,7 @@ func validateBackupFile(outputFile string) (string, error) {
|
||||
func dumpData(w http.ResponseWriter, r *http.Request) {
|
||||
r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize)
|
||||
var outputFile, outputData, indent string
|
||||
var scopes []string
|
||||
if _, ok := r.URL.Query()["output-file"]; ok {
|
||||
outputFile = strings.TrimSpace(r.URL.Query().Get("output-file"))
|
||||
}
|
||||
@@ -60,6 +61,9 @@ func dumpData(w http.ResponseWriter, r *http.Request) {
|
||||
if _, ok := r.URL.Query()["indent"]; ok {
|
||||
indent = strings.TrimSpace(r.URL.Query().Get("indent"))
|
||||
}
|
||||
if _, ok := r.URL.Query()["scopes"]; ok {
|
||||
scopes = getCommaSeparatedQueryParam(r, "scopes")
|
||||
}
|
||||
|
||||
if outputData != "1" {
|
||||
var err error
|
||||
@@ -78,7 +82,7 @@ func dumpData(w http.ResponseWriter, r *http.Request) {
|
||||
logger.Debug(logSender, "", "dumping data to: %q", outputFile)
|
||||
}
|
||||
|
||||
backup, err := dataprovider.DumpData()
|
||||
backup, err := dataprovider.DumpData(scopes)
|
||||
if err != nil {
|
||||
logger.Error(logSender, "", "dumping data error: %v, output file: %q", err, outputFile)
|
||||
sendAPIResponse(w, r, err, "", getRespStatus(err))
|
||||
|
||||
Reference in New Issue
Block a user