(configPath string)
| 27 | } |
| 28 | |
| 29 | func backupOpenCloudConfigFile(configPath string) (string, error) { |
| 30 | sourceConfig := path.Join(configPath, configFilename) |
| 31 | targetBackupConfig := path.Join(configPath, configFilename+"."+time.Now().Format("2006-01-02-15-04-05")+".backup") |
| 32 | source, err := os.Open(sourceConfig) |
| 33 | if err != nil { |
| 34 | log.Fatalf("Could not read %s (%s)", sourceConfig, err) |
| 35 | } |
| 36 | defer source.Close() |
| 37 | target, err := os.Create(targetBackupConfig) |
| 38 | if err != nil { |
| 39 | log.Fatalf("Could not generate backup %s (%s)", targetBackupConfig, err) |
| 40 | } |
| 41 | defer target.Close() |
| 42 | _, err = io.Copy(target, source) |
| 43 | if err != nil { |
| 44 | log.Fatalf("Could not write backup %s (%s)", targetBackupConfig, err) |
| 45 | } |
| 46 | return targetBackupConfig, nil |
| 47 | } |
| 48 | |
| 49 | // printBanner prints the generated opencloud config banner. |
| 50 | func printBanner(targetPath, ocAdminServicePassword string, adminPWgenerated bool, targetBackupConfig string) { |
no test coverage detected