1.0.3 β’ Published 8 months ago
database-backup v1.0.3
π Database Backup Tool
Welcome to the Database Backup Tool! π 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 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('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
},
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:
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=your_username
POSTGRES_PASSWORD=your_password
POSTGRES_DATABASE=your_database
# AWS Credentials
AWS_ACCESS_KEY_ID=your_access_key_id
AWS_SECRET_ACCESS_KEY=your_secret_access_key
AWS_REGION=your_aws_region