diff --git a/README.md b/README.md index 8328b43..c0be430 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A script to automatically handle the backing up of MongoDB databases and optiona 3. Setup your service on your UNIX-based OS, for example an Ubuntu Server. **i.** Build the project to a binary. ```bash - $ go build + $ go build main.go ``` **ii.** Create a System Service file ```bash diff --git a/main.go b/main.go index 274f3a6..17655ab 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,7 @@ func LogToFile(message string) { f, err := os.OpenFile("databaseBackup.log", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666) Handle(err) defer f.Close() - + log.SetOutput(f) log.Println(fmt.Sprintf(" | %s", message)) } @@ -55,8 +55,11 @@ func UploadToGithub(archiveDir string) { } func main() { + path, err := os.Getwd() + Handle(err) + // Load environment variables - godotenv.Load(".env") + godotenv.Load(fmt.Sprintf("%s/.env", path)) var mongoURI string = os.Getenv("mongoURI") var database_string string = os.Getenv("databases") var github string = os.Getenv("github")