To schedule backup mongodb to AWS S3 could be done extremely easy in any docker pipeline, here is an example using DroneCI docker pipeline and cronjob feature. The complete code example could be found here: https://github.com/Asing1001/mongodb-s3-backup.
- Create
.drone.jsonnetfile using docker pipeline - Use
mongodumpin step1 to create archive Upload the archive by
s3 pluginin step21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39local backupLocation = 'mongo-archive.gz';
[{
kind: 'pipeline',
name: 'default',
steps: [
{
name: 'mongodump',
image: 'mongo:3.6.5',
environment: {
DB_URI: {
from_secret: 'db_uri'
},
},
commands: [
'mongodump --gzip --uri="$DB_URI" --archive=' + backupLocation,
],
},
{
name: 'upload',
image: 'plugins/s3',
settings: {
bucket: 'mongo-backup',
access_key: {
from_secret: 'aws_access_key_id',
},
secret_key: {
from_secret: 'aws_secret_access_key',
},
source: backupLocation,
target: '/',
},
},
],
trigger: {
event: ['cron', 'push'],
branch: 'master'
},
}]Activate the project in DroneCI and fill up variables
aws_access_key_id,aws_secret_access_key,db_uriSetup Cron jobs in Drone project’s settings

Push the repository and verify the job :)