f88bef851af103d0811e2150f36d2771c7793d09
MongoDB Backup Script
A script to automatically handle the backing up of MongoDB databases and optionally the storage of the archive to a github repository. Designed as a script to be run as a service on a server.
Setup
-
Rename
.env.exampleto.env -
Set the parameters of your mongoURI, database names, and optionally a gitub url/ssh link. Ex.
mongoURI=mongodb://localhost:27017 databases=db_name_1, db_name_2, ... github=git@github:Username/MongoDB_Backup_Repo.gitNote: If you wish to backup more than one database at a time, be sure to seperate the database names with a comma and a space as follows "
,". -
Setup your service on your UNIX-based OS, for example an Ubuntu Server.
i. Build the project to a binary.$ go build main.goii. Create a System Service file
$ vim /lib/systemd/system/mongobackup.serviceNow within the
mongobackup.servicefile, write the configuration for the program.[Unit] Description=MongoDB Backup Service [Service] Type=simple Restart=always RestartSec=5 ExecStart=/path/to/binary/file [Install] WantedBy=multi-user.targetiii. Finally start the service.
$ service mongobackup start
Description
A script to automatically backup MongoDB database(s) locally and optionally to a github repository.
Readme
38 KiB
0 Stars
1 Watchers
0 Forks
Languages
Go
100%