MCPcopy
hub / github.com/opencloud-eu/opencloud / backupOpenCloudConfigFile

Function backupOpenCloudConfigFile

opencloud/pkg/init/functions.go:29–47  ·  view source on GitHub ↗
(configPath string)

Source from the content-addressed store, hash-verified

27}
28
29func 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.
50func printBanner(targetPath, ocAdminServicePassword string, adminPWgenerated bool, targetBackupConfig string) {

Callers 1

CreateConfigFunction · 0.85

Calls 3

FatalfMethod · 0.80
CloseMethod · 0.65
CreateMethod · 0.65

Tested by

no test coverage detected