Skip to content

vsbuidev/automated_db_backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated Backup and Restoration in MongoDB

This project automates the backup of a MongoDB database every 12 hours and uploads it to an AWS S3 bucket. It also provides a script to restore the latest backup from S3.

Features

  • Automated Database Backup: Uses mongodump to create a backup.
  • Upload to S3: Utilizes aws-cli to store backups in S3.
  • GitHub Actions Integration: Scheduled workflow to run every 12 hours.
  • Restore Script: Downloads and restores the latest backup from S3.

Prerequisites

Setup Instructions

1. Set Up MongoDB Server locally by refering to the link

2. Seed the Database

Run the seed.sh script to add sample data:

chmod +x seed.sh
./seed.sh

3. Backup and Upload to S3

Using a Cron Job (On Server)

  1. Install AWS CLI and configure it:

  2. To Execute a backup script (backup.sh):

    ./backup.sh
  3. Add a cron job to schedule the backup every 12 hours:

    crontab -e

    Add this line:

    0 */12 * * * /home/ubuntu/backup.sh >> /home/ubuntu/backup.log 2>&1

3. Restore the Latest Backup

Run the restore.sh script to download and restore the latest backup:

chmod +x restore.sh
./restore.sh

Screenshot

screenshot

This project is part of vsbuidev's Roadmap DevOps projects.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages