CLI: Improve backup and restore commands

This commit is contained in:
Michael Mayer
2021-10-07 13:17:16 +02:00
parent 66cad5c486
commit a7b6107d5e
2 changed files with 13 additions and 11 deletions

View File

@@ -11,6 +11,8 @@ import (
"regexp"
"time"
"github.com/dustin/go-humanize/english"
"github.com/urfave/cli"
"github.com/photoprism/photoprism/internal/config"
@@ -37,7 +39,7 @@ var restoreFlags = []cli.Flag{
},
cli.BoolFlag{
Name: "albums, a",
Usage: "restore albums from YAML files",
Usage: "restore albums from YAML backups",
},
cli.StringFlag{
Name: "albums-path",
@@ -45,11 +47,11 @@ var restoreFlags = []cli.Flag{
},
cli.BoolFlag{
Name: "index, i",
Usage: "restore index from SQL dump",
Usage: "restore index from database SQL dump",
},
cli.StringFlag{
Name: "index-path",
Usage: "custom index backup `PATH`",
Usage: "custom database backup `PATH`",
},
}
@@ -186,7 +188,7 @@ func restoreAction(ctx *cli.Context) error {
}
}
log.Infoln("migrating database")
log.Infoln("migrating index database schema")
conf.InitDb()
@@ -198,14 +200,14 @@ func restoreAction(ctx *cli.Context) error {
}
if !fs.PathExists(albumsPath) {
log.Warnf("albums path %s not found", txt.Quote(albumsPath))
log.Warnf("albums backup path %s not found", txt.Quote(albumsPath))
} else {
log.Infof("restoring albums from %s", txt.Quote(albumsPath))
if count, err := photoprism.RestoreAlbums(albumsPath, true); err != nil {
return err
} else {
log.Infof("%d albums restored from yaml files", count)
log.Infof("restored %s from YAML backups", english.Plural(count, "album", "albums"))
}
}
}