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-restore

v1.0.1

Published

Restore MongoDB Backups stored on S3 with a (Optional) Web GUI

Downloads

11

Readme

s3-mongo-restore

Restore MongoDB Backups stored in S3, Using a CLI or directly in your code using this as a library

Features

  • Download and Restore MongoDB Backups
  • Inbuilt CLI and Library
  • Presents a Searchable field to lookup the database
  • Promises!

Usage

As a CLI

Usage
$ s3mr [<mongodburi|accessKey|secretKey|bucketName> ...]

  Options
    -u, --uri               MongoDB URI
    -a, --accessKey         S3 Access Key
    -s, --secretKey         S3 Secret Key
    -b, --bucketName        S3 Bucket Name
    -r, --region            S3 Region
    -lff, --load-from-file  Load Configuration from a JSON file

Configuration File Example
    {
    mongodb: "mongodb://localhost:27017",
        s3: {
        secretKey: "<s3 secret key>",
        accessKey: "<s3 access key>",
        region: "<s3 region>",
        bucketName: "<s3 bucket name>"
        }      
    }

As a Library

Import

const restore = require('s3-mongo-restore');

Create a configuration Object

var restoreConfig = {
  mongodb: "mongodb://localhost:27017", // MongoDB URI
    s3: {
      secretKey: "<s3 secret key>",     // S3 Secret Key
      accessKey: "<s3 access key>",     // S3 Access Key
      region: "<s3 region>",            // S3 Region
      bucketName: "<s3 bucket name>"    // S3 Bucket Name
    }      
}

Call the Function and pass configuration object to it

This module exposes two functions, List and Restore. List is used to list all the backups in the database and takes just the configuration object. Restore is used to restore a database and takes the configuration object and the name of database.

//List
restore.List(restoreConfig)
  .then(result => {
    // When everything is ok, result is an Object containing information about all the backups
      console.log(result);
}, error => {
    // When Anything goes wrong!
    console.log(error);
});

//Restore
restore.Restore(restoreConfig, "<A backup name>")
    .then(result => {
        console.log(result);
    }, error => {
        console.log(error);
    });

See examples directory for more examples

License

MIT

NOTE

  1. This module uses mongorestore to restore database, You need to have it installed on the machine on which you are using this module.

  2. To backup the databases,

     mongodump --host localhost --port=27017 --gzip --archive=<path to backup.gz>
    
     // or, in mongodump version 3.4+
    
     mongodump --uri=\<MongoDB URI\> --gzip --archive=<path to backup.gz>