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

@think201/database-backup

v1.0.7

Published

A utility that can back up PostgreSQL or MongoDB databases.

Downloads

510

Readme

🎉 @think201/database-backup

Welcome to the Database Backup Tool by Think201! 🚀 Your trusty sidekick for effortlessly backing up your databases to AWS S3. Whether you're a PostgreSQL wizard or a MongoDB maestro, this tool has got your back!

🛠️ Features

  • Database Support: Back up your PostgreSQL and MongoDB databases like a pro! 🥇
  • AWS S3 Integration: Say goodbye to local storage worries and hello to the cloud! ☁️
  • Retention Policy: Keep your backups tidy with a configurable retention policy. No more clutter! 🧹
  • Easy Peasy Setup: Get started in no time with our simple setup process. 🎈

📦 Installation

Ready to roll? Install the package with a single command:

npm install @think201/database-backup

🚀 Usage

Let's get this backup party started! Here's how to use the Database Backup Tool:

require('dotenv').config(); // Load environment variables from .env file
const AutomatedBackupTool = require('@think201/database-backup');

const backupTool = new AutomatedBackupTool({
    database: 'postgres', // Change to 'mongodb' if you want to test MongoDB
    storage: 'aws',
    retention: 7, // Keep backups for 7 days (because who needs clutter?
    awsCredentials: {
        accessKeyId: process.env.AWS_ACCESS_KEY_ID,
        secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
        region: process.env.AWS_REGION,
        bucket: process.env.AWS_BUCKET, // S3 bucket where backups will be stored
        backupDir: 'my_custom_backup_folder', // Specify your custom backup directory
    },
    dbCredentials: {
        postgres: {
            host: process.env.POSTGRES_HOST,
            port: process.env.POSTGRES_PORT,
            user: process.env.POSTGRES_USER,
            password: process.env.POSTGRES_PASSWORD,
            database: process.env.POSTGRES_DATABASE
        },
        mongodb: {
            url: process.env.MONGODB_URL
        }
    }
});

backupTool.backup()
    .then(() => {
        console.log('🎉 Backup process completed successfully! 🎉');
    })
    .catch(error => {
        console.error('😱 Error during backup process:', error);
    });

🌱 Environment Variables

To make this tool work its magic, you need to set up some environment variables. Create a .env file in the root of your project and fill it with your secrets:

# PostgreSQL Credentials
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=your_username
POSTGRES_PASSWORD=your_password
POSTGRES_DATABASE=your_database

# MongoDB Credentials (if using MongoDB)
MONGODB_URL=mongodb://username:password@localhost:27017/database

# AWS Credentials
AWS_ACCESS_KEY_ID=your_access_key_id
AWS_SECRET_ACCESS_KEY=your_secret_access_key
AWS_REGION=your_aws_region
AWS_BUCKET=your_s3_bucket_name

📝 Requirements

  • Node.js 12 or higher
  • For PostgreSQL backups: pg_dump command-line tool must be installed
  • For MongoDB backups: mongodump command-line tool must be installed
  • AWS credentials with S3 access