Data - HoseaCodes/Blog GitHub Wiki

Backups

Resources

AWS Secured Bucket - hc-mongodbback

Automating MongoDB backups using Node.js.

Mongodump is a MongoDB utility to create a backup of the content of a database. The procedure primarily involves two steps: leveraging the mongodump utility for data backup and scheduling these backups with the cron job scheduler.

The initial step requires the use of MongoDB’s inbuilt utility, mongodump, to generate a backup of the entire database. This backup, also known as a “dump,” is saved in a backup folder that houses your database collections.

To kick off, construct a backup directory named ‘database-backup’ to hold the archive produced by mongodump.

Packages Used

MongoDB is a NoSQL database that is document-oriented and used for high-volume data storage. MongoDB, unlike traditional relational databases, uses collections and documents to provide high scalability, performance, and flexibility.

MongoDB Database Tools are a set of command-line utilities used to interact with a MongoDB deployment.

Node.js is a JavaScript runtime based on the V8 JavaScript engine in Chrome. It is a cross-platform open-source runtime environment for executing JavaScript code outside of a web browser.

In Node.js, child processes are separate processes that run independently of the main Node.js process. They can be used in Node.js for a variety of tasks, including running multiple independent tasks, performing background tasks, and breaking down a large task into smaller, more manageable parts. In Node.js, the most commonly used methods for creating child processes are exec(), spawn(), and fork():

  • The exec() method runs a shell command in a child process and returns the output.
  • The spawn() method starts a new process and returns anChildProcess object that can be used to communicate with it.
  • The fork() method is a variant of the spawn() method that appears to be intended for use with Node.js scripts. It enables the child process to communicate.

AWS S3 (Simple Storage Service) is a cloud-based object storage service with industry-leading scalability, data availability, security, and performance that can be used to store any type of data and files.

GitHub Actions is a YAML-based tool for automating software development workflow directly in a GitHub repository. It allows developers to focus on writing code by automating tasks like building, testing, and deploying code. GitHub Actions triggers are based on a variety of events, including push events, pull request events, releases, cron job actions, manual events, and so on.

References