MongoDB backup to S3 on Kubernetes- Alt Digital Technologies

 

Introduction

Kubernetes CronJob makes it very easy to run Jobs on a time-based schedule. These automated jobs run like Cron tasks on a Linux or UNIX system.

In this post, we’ll make use of Kubernetes CronJob to schedule a recurring backup of the MongoDB database and upload the backup archive to AWS S3.

There are several ways of achieving this, but then again, I had to stick to one using Kubernetes since I already have a Kubernetes cluster running.

Prerequisites: 

  • Docker installed on your machine
  • Container repository (Docker Hub, Google Container Registry, etc) – I’ve used docker hub
  • Kubernetes cluster running

Steps to achieve this:

  • MongoDB installed on the server and running or MongoDB Atlas – I’ve used Atlas
  • AWS CLI installed in a docker container
  • A bash script will be run on the server to backup the database
  • AWS S3 Bucket configured
  • Build and deploy on Kubernetes

MongoDB Setup:

You can set up a mongo database on your server or use a MongoDB Atlas cluster instead. The Atlas cluster is a great way to set up a mongo database and is free for M0 clusters. You can also use a mongo database on your server or on a Kubernetes cluster.

After creating your MongoDB instance, we will need the Connection String. Please keep it safe somewhere, we will need it later.

Choosing a connection string may confuse which one to pick. So we need to select the MongoDB Compass one that looks in the below format. Read more!!

Comments

Followers

Popular posts from this blog

Unleashing the Power of Digital Marketing Advertising with Alt Digital Technologies

Ultimate Guide to Understand BFF in Web Development

Alt Digital Technologies, your trusted partner in digital customer experience transformation, is here to help you enhance your business! 🌟