unlock on error and named arrays for config

This commit is contained in:
2021-04-11 17:02:34 +02:00
parent 8a1fe41825
commit 6e25b90915
14 changed files with 138 additions and 49 deletions

View File

@@ -28,24 +28,20 @@ var backupCmd = &cobra.Command{
Use: "backup",
Short: "Create backups for given locations",
Run: func(cmd *cobra.Command, args []string) {
config := internal.GetConfig()
{
err := config.CheckConfig()
cobra.CheckErr(err)
}
{
err := lock.Lock()
cobra.CheckErr(err)
}
err := lock.Lock()
CheckErr(err)
defer lock.Unlock()
{
selected, err := internal.GetAllOrSelected(cmd, false)
cobra.CheckErr(err)
for _, name := range selected {
location := config.Locations[name]
fmt.Printf("Backing up: `%s`", name)
location.Backup()
}
config := internal.GetConfig()
err = config.CheckConfig()
CheckErr(err)
selected, err := internal.GetAllOrSelected(cmd, false)
CheckErr(err)
for _, name := range selected {
location, _ := internal.GetLocation(name)
fmt.Printf("Backing up: `%s`", name)
location.Backup()
}
},
}