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.jsonwith appropriate information about your database and S3 Bucket uriis connection string used to connect into your databasearchivenameis your archive name that contains all dump files from your databasearchivesuffix_dateformatused 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 HHmmssdestpathis destination directory for your dump files as archive fileretentiondaykey 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 regionis your S3 Bucket regionbucketis your S3 Bucket name- If you want to upload into your S3 Bucket folder just add your folder name into
folderkey with structurefolderorfolder/subfolderetc, don't worry if you write it as/folderorfolder/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.jsonwith appropriate information about your files directory location and S3 Bucket dirpathis your upload directory location- When you set
initialrun: true, it will copy all files inside particular directory, after that it will setinitialrun: falseautomatically - When you set
initialrun: false, it will copy files in the same day when this apps run backuptypekey 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
archivemethodkey, the options arezip,tarortar.gz regionis your S3 Bucket regionbucketis your S3 Bucket name- If you want to upload into your S3 Bucket folder just add your folder name into
folderkey with structurefolderorfolder/subfolderetc, don't worry if you write it as/folderorfolder/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.