diff options
Diffstat (limited to 'configBackup.go')
| -rw-r--r-- | configBackup.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/configBackup.go b/configBackup.go index d9bc396..137cb08 100644 --- a/configBackup.go +++ b/configBackup.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "io" - "log" "os" "path/filepath" "time" @@ -15,12 +14,8 @@ import ( func backupConfig() error { // make a new dir to backup the files - now := time.Now() - // timestamp := now.Format("2022.07.18.190545") // 50yr shout out to K&R - timestamp := now.Format("2006.01.02.150405") // bummer. other date doesn't work? srcDir := filepath.Join(os.Getenv("FORGE_CONFIG")) - destDir := filepath.Join(os.Getenv("FORGE_CONFIG"), timestamp) - + destDir := filepath.Join(os.Getenv("FORGE_CONFIG"), "backup") return backupFiles(srcDir, destDir) } @@ -44,7 +39,7 @@ func backupFiles(srcDir string, destDir string) error { continue } - log.Println("backing up file", entry.Name()) + // log.Println("backing up file", entry.Name()) srcPath := filepath.Join(srcDir, entry.Name()) destPath := filepath.Join(destDir, entry.Name()) @@ -64,6 +59,9 @@ func copyFile(src, dest string) error { } defer srcFile.Close() + now := time.Now() + timestamp := now.Format("2006.01.02.150405") // bummer. other date doesn't work? + dest = dest + timestamp destFile, err := os.Create(dest) if err != nil { return err |
