To Backup MongoDB Database and Files into AWS S3 Bucket
It will dump your MongoDB database with archive and copy it into your local folder and S3 Bucket
It's located in database
directory and following is brief description about the config file:
- Change config file inside
configs/configs.json
with appropriate information about your database and S3 Bucket uri
is connection string used to connect into your databasearchivename
is your archive name that contains all dump files from your databasearchivesuffix_dateformat
used to add suffix into archive name. It can be used as a flag to determine your dump time. This format 20060102 is similar to yyyyMMdd format and 150405 is similar to HHmmssdestpath
is destination directory for your dump files as archive fileretentionday
key use to set your object retention in S3 bucket for N days For example: If this apps run in 15 July 2019 andretentionday: 7
, it will keep object between 8 July 2019 - 15 July 2019 in particular folder, and all objects before 8 July 2019 will be deleted- If you don't want to use retention feature just set the
retentionday: 0
region
is your S3 Bucket regionbucket
is your S3 Bucket name- If you want to upload into your S3 Bucket folder just add your folder name into
folder
key with structurefolder
orfolder/subfolder
etc, don't worry if you write it as/folder
orfolder/
or/folder/
this apps will trim it - To test it just run
go run main.go
. - To run it in scheduler just build it and add parameter
-config=yourconfigfilelocation
.
It will copy your files into S3 Bucket
It's located in file
directory and following is brief description about the config file:
- Change config file inside
configs/configs.json
with appropriate information about your files directory location and S3 Bucket dirpath
is your upload directory location- When you set
initialrun: true
, it will copy all files inside particular directory, after that it will setinitialrun: false
automatically - When you set
initialrun: false
, it will copy files in the same day when this apps run backuptype
key use to determine whether you want to copy files or folders set- If you want to copy folders you can also determine archiving method for this particular directory on
archivemethod
key, the options arezip
,tar
ortar.gz
region
is your S3 Bucket regionbucket
is your S3 Bucket name- If you want to upload into your S3 Bucket folder just add your folder name into
folder
key with structurefolder
orfolder/subfolder
etc, don't worry if you write it as/folder
orfolder/
or/folder/
this apps will trim it - To test it just run
go run main.go
. - To run it in scheduler just build it and add parameter
-config=yourconfigfilelocation
.