npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

s3-mongo-backup

v2.0.2

Published

Backup and Upload MongoDB Databases to S3

Downloads

283

Readme

s3-mongo-backup

This Module Helps in automating mongodb database Backups and uploading them to AWS S3.

Features

  • Supports Promises
  • Uploads Backups to S3
  • Uses GZip Compression to reduce Backup Size

Usage

Import

const MBackup = require('s3-mongo-backup');

Create a configuration Object

var backupConfig = {
   mongodb: "mongodb://username:password@localhost:27017", // MongoDB Connection URI 
    s3: {
        accessKey: "",  //AccessKey
        secretKey: "",  //SecretKey
        region: "",     //S3 Bucket Region
        accessPerm: "private", //S3 Bucket Privacy, Since, You'll be storing Database, Private is HIGHLY Recommended
        bucketName: "" //Bucket Name
    },
    keepLocalBackups: false,  //If true, It'll create a folder in project root with database's name and store backups in it and if it's false, It'll use temporary directory of OS
    noOfLocalBackups: 5, //This will only keep the most recent 5 backups and delete all older backups from local backup directory
    timezoneOffset: 300 //Timezone, It is assumed to be in hours if less than 16 and in minutes otherwise
}

Or 

var backupConfig = {
    mongodb: {
        "database": "freecodecamp",
        "host": "localhost",
        "username": "admin",
        "password": "password",
        "port": 27017
    },   
    s3: {
        accessKey: "",  //AccessKey
        secretKey: "",  //SecretKey
        region: "",     //S3 Bucket Region
        accessPerm: "private", //S3 Bucket Privacy, Since, You'll be storing Database, Private is HIGHLY Recommended
        bucketName: "" //Bucket Name
    },
    keepLocalBackups: false,  //If true, It'll create a folder in project root with database's name and store backups in it and if it's false, It'll use temporary directory of OS
    noOfLocalBackups: 5, //This will only keep the most recent 5 backups and delete all older backups from local backup directory
    timezoneOffset: 300 //Timezone, It is assumed to be in hours if less than 16 and in minutes otherwise
}

Call the Function and provide Configuration Object to it.

MBackup(backupConfig)
  .then(
    onResolve => {
    // When everything was successful
      console.log(onResolve);
}
    onReject => {
    // When Anything goes wrong!
      console.log(onReject);
});

See examples directory for more examples

Timezone offset's Purpose

Database zip files are stored in format {database_name}_{YYYY-MM-DDTHH:mm:ss}. Here, If you don't provide a Timezone offset, It'll assume UTC timezone and name all the backups accordingly. Now, If something goes wrong at "2:00 PM" in your timezone and you need to restore a backup made at "1:00 PM" in your timezone, You'll have to change UTC time to your time and then see which backup you have to restore.

But If you provide a timezone of where ever you live, You can immdiately recognise which backup can be useful.

To see how to provide Timezone offset, Please refer to moment#utcOffset

License

MIT

Changelog

2.0.0 -> Uses MongoDB Connection URI directly, instead of asking for individual values of username, database name, password and database host.

NOTE

  1. This module uses mongodump to create backup of database, You need to have it installed on the machine on which you are using this module.

  2. To restore the generated backups

    mongorestore --host localhost --port=27017 --gzip --archive=<path to backup.gz>