feat(dump): add flag to allow specifying dump path
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Resolves https://community.vikunja.io/t/vikunja-0-24-docker-bin-sh/2621/3
This commit is contained in:
parent
c2b116de70
commit
9d7b6d3d9a
@ -17,11 +17,14 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/initialize"
|
||||
"code.vikunja.io/api/pkg/log"
|
||||
"code.vikunja.io/api/pkg/modules/dump"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -29,6 +32,8 @@ func init() {
|
||||
rootCmd.AddCommand(dumpCmd)
|
||||
}
|
||||
|
||||
var dumpPathFlag string
|
||||
|
||||
var dumpCmd = &cobra.Command{
|
||||
Use: "dump",
|
||||
Short: "Dump all vikunja data into a zip file. Includes config, files and db.",
|
||||
@ -37,8 +42,18 @@ var dumpCmd = &cobra.Command{
|
||||
},
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
filename := "vikunja-dump_" + time.Now().Format("2006-01-02_15-03-05") + ".zip"
|
||||
if err := dump.Dump(filename); err != nil {
|
||||
|
||||
path := config.ServiceRootpath.GetString()
|
||||
if dumpPathFlag != "" {
|
||||
path = dumpPathFlag
|
||||
}
|
||||
|
||||
if err := dump.Dump(filepath.Join(path, filename)); err != nil {
|
||||
log.Critical(err.Error())
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
dumpCmd.Flags().StringVarP(&dumpPathFlag, "path", "p", "", "The folder path where the dump file should be saved. Vikunja will use the configured root path or the binary location if the flag is not provided.")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user