forked from TrueCloudLab/restic
Improve migrate command
This commit is contained in:
parent
92816fa966
commit
3af6c180e4
1 changed files with 12 additions and 4 deletions
|
@ -8,11 +8,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var cmdMigrate = &cobra.Command{
|
var cmdMigrate = &cobra.Command{
|
||||||
Use: "migrate [flags] [name]",
|
Use: "migrate [flags] [migration name] [...]",
|
||||||
Short: "Apply migrations",
|
Short: "Apply migrations",
|
||||||
Long: `
|
Long: `
|
||||||
The "migrate" command applies migrations to a repository. When no migration
|
The "migrate" command checks which migrations can be applied for a repository
|
||||||
name is explicitly given, a list of migrations that can be applied is printed.
|
and prints a list with available migration names. If one or more migration
|
||||||
|
names are specified, these migrations are applied.
|
||||||
|
|
||||||
EXIT STATUS
|
EXIT STATUS
|
||||||
===========
|
===========
|
||||||
|
@ -41,6 +42,8 @@ func init() {
|
||||||
func checkMigrations(opts MigrateOptions, gopts GlobalOptions, repo restic.Repository) error {
|
func checkMigrations(opts MigrateOptions, gopts GlobalOptions, repo restic.Repository) error {
|
||||||
ctx := gopts.ctx
|
ctx := gopts.ctx
|
||||||
Printf("available migrations:\n")
|
Printf("available migrations:\n")
|
||||||
|
found := false
|
||||||
|
|
||||||
for _, m := range migrations.All {
|
for _, m := range migrations.All {
|
||||||
ok, err := m.Check(ctx, repo)
|
ok, err := m.Check(ctx, repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -48,10 +51,15 @@ func checkMigrations(opts MigrateOptions, gopts GlobalOptions, repo restic.Repos
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
Printf(" %v: %v\n", m.Name(), m.Desc())
|
Printf(" %v\t%v\n", m.Name(), m.Desc())
|
||||||
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
Printf("no migrations found")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue