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

backup-mongo-to-s3

v2.0.0

Published

Make mongo db backup to s3

Downloads

15

Readme

backup-mongo-to-s3

A module that makes database backup and uploads to s3.

INTRODUCTION

This module involves the following steps.

  1. Make DB backup on disk.
  2. Make a zip file out of localbackup.
  3. Delete the local-backup directory.
  4. Upload the zip file to s3.
  5. Delete zip file, if 'keepLocalBackups' parameter is not set to true.
  6. Delete outdated cloud backup zip files, outdated refers to zip files older than the latest 'noOfTotalBackups'.

USAGE

  1. Require the module.
  2. Use the init method to pass argument object.
  3. Use the start method to start the process.
  4. Compatible with cron-job to schedule backup-process.

PARAMETERS

1.  mongodbUri       : MANDATORY | <string>    | e.g. "localhost:27017"
2.  backupDir        : MANDATORY | <string>    | e.g. "/tmp/backupDir"                    => The path to the directory, where localDB will be dumped.
3.  zipPath          : MANDATORY | <string>    | e.g. '/tmp/backup.zip'                   => The path where the backupDir is zipped to.
4.  key              : MANDATORY | <string>    | e.g. "jfdasdlkfjfdak3al2lkasdfjlk"       => aws s3 key value.
5.  secret           : MANDATORY | <string>    | e.g. "fdjaksdf_e34jk53wlksdj2092jk"      => aws s3 secret value.
6.  region           : MANDATORY | <string>    | e.g. 'us-southwest-01'                   => the region name of the s3 bucket. 
7.  bucket           : MANDATORY | <string>    | e.g. 'scheduled-backups'                 => The name of the bucket, where backup zips will be posted to.
8.  dir              : MANDATORY | <string>    | e.g. 'backupDir'                         => The directory in the bucket, where zips are stored into.
9.  name             : OPTIONAL  | <string>    | default : 'backup'                       => The alias with which we want to store our backup.zip by.
10. debugMode        : OPTIONAL  | <boolean>   | default : false                          => Enable logs from module, if false, module simply throws.
11. keepLocalBackups : OPTIONAL  | <boolean>   | default : false                          => retain or delete localBackup.
12. noOfTotalBackups : OPTIONAL  | <number>    | default : 7                              => The no. of latest n-backup to keep, older ones are automatically deleted.

EXAMPLE

const module = require ('backup-mongo-to-s3');

// Take note of the MANDATORY and OPTIONAL parameters.
const config = {
		mongodbUri       : <string>,
		backupDir        : <string>,
		zipPath          : <string>,
		keepLocalBackups : <boolean>,
		noOfTotalBackups : <number>,
		debug            : <boolean>,

		s3         : {
			key     : <string>,
			secret  : <string>,
			region  : <string>,
			bucket  : <string>,
			name    : <string>,
			dir     : <string>,
		},
	};

// synchronous method.
module.init (config);

// asynchronous method.
module.start ();