Skip to content

Commit

Permalink
Add timestamp to backup
Browse files Browse the repository at this point in the history
  • Loading branch information
rcaught committed Sep 15, 2019
1 parent cd140a7 commit f5fb336
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (
"os/signal"
"regexp"
"runtime"
"strconv"
"strings"
"syscall"
"time"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -139,7 +141,7 @@ func createHostsBackup(hostsFileLocation *string) {
return
}

backupLocation := *hostsFileLocation + ".backup"
backupLocation := *hostsFileLocation + ".backup-" + strconv.FormatInt(time.Now().Unix(), 10)

err = ioutil.WriteFile(backupLocation, input, 0644)
if err != nil {
Expand Down

0 comments on commit f5fb336

Please sign in to comment.