yemot-backup
v1.0.11
Published
Automatic backup tool for Yemot HaMashiach call recordings to Amazon S3
Readme
Yemot Backup
Automatic backup tool for Yemot HaMashiach call recordings to Amazon S3.
Features
- Scheduled daily backups of Yemot HaMashiach recordings at midnight
- Support for multiple Yemot systems
- Automated filtering for recordings from the previous day
- Maintains original directory structure in S3
- Command-line interface for manual backup operations
- Background scheduler with PM2 process management
- System and AWS configuration management
Requirements
- Node.js 14 or later
- AWS S3 bucket
- Yemot HaMashiach system credentials
- PM2 for background tasks (
npm install -g pm2)
Installation
# Install globally to use the CLI
npm install -g yemot-backup
# Or install locally in your project
npm install yemot-backupCLI Usage
Once installed globally, you can use the yemot-backup command:
# Show help
yemot-backup --help
# Run backup immediately
yemot-backup run
# Run backup from a specific path
yemot-backup run --yemot-path "Trash/SIPRecordIn"
# Schedule daily backups (foreground process)
yemot-backup schedule
# Background Scheduler Commands
# Start scheduler in background with PM2
yemot-backup schedule:start
# Stop background scheduler
yemot-backup schedule:stop
# Check scheduler status
yemot-backup schedule:status
# List all active schedulers
yemot-backup schedule:list
# System-Specific Scheduler Commands
# Start scheduler for a specific system
yemot-backup system:schedule -i system-id
# Start scheduler with custom cron and path
yemot-backup system:schedule -i system-id -s "0 2 * * *" -p "Trash/SIPRecordIn"
# Stop scheduler for a specific system
yemot-backup system:schedule:stop -i system-id
# Check scheduler status for a specific system
yemot-backup system:schedule:status -i system-id
# Test connection to all systems
yemot-backup test-connection
# System Management Commands
# List all systems
yemot-backup systems:list
# Add a new system
yemot-backup systems:add -i system-id -u username -p password
# Add a system without verifying credentials
yemot-backup systems:add -i system-id -u username -p password --skip-verification
# Update a system
yemot-backup systems:update -i system-id -u new-username -p new-password -e true
# Remove a system
yemot-backup systems:remove -i system-id
# Show system details
yemot-backup systems:show -i system-id
# AWS Configuration Commands
# Configure AWS credentials
yemot-backup aws:configure -k ACCESS_KEY -s SECRET_KEY -r region -b bucket-name
# Show AWS configuration
yemot-backup aws:statusLibrary Usage
You can also use this package as a library in your Node.js projects:
const yemotBackup = require('yemot-backup');
// Run backup for all enabled systems
async function backup() {
try {
await yemotBackup.runBackup();
console.log('Backup completed successfully');
} catch (error) {
console.error('Backup failed:', error);
}
}
// Run backup for a specific system
async function backupSystem() {
try {
await yemotBackup.runSystemBackup('system-1', 'Trash/SIPRecordIn');
console.log('System backup completed successfully');
} catch (error) {
console.error('System backup failed:', error);
}
}
// Create a custom backup service
const customBackup = () => {
const system = {
id: 'custom-system',
username: 'username',
password: 'password'
};
const backupService = new yemotBackup.BackupService(system);
return backupService.runBackup('/custom/path');
};
// System management
function manageYemotSystems() {
// Get all systems
const systems = yemotBackup.getSystems();
console.log('All systems:', systems);
// Add a new system
yemotBackup.addSystem({
id: 'new-system',
username: '0733512777',
password: 'secret-password',
enabled: true
});
// Update a system
yemotBackup.updateSystem('system-1', {
username: 'new-username',
enabled: false
});
// Get a specific system
const system = yemotBackup.getSystem('system-1');
console.log('System details:', system);
// Remove a system
yemotBackup.removeSystem('old-system');
}
// AWS configuration
function configureAwsSettings() {
yemotBackup.configureAws({
accessKeyId: 'YOUR_ACCESS_KEY',
secretAccessKey: 'YOUR_SECRET_KEY',
region: 'us-east-1',
bucket: 'your-bucket-name'
});
}Configuration
The package reads configuration from environment variables and a systems.json file:
- Create a
.envfile with AWS credentials:
AWS_ACCESS_KEY_ID=your_key_id
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=us-east-1
AWS_S3_BUCKET=your-bucket-name- Create a
systems.jsonfile in thesrcdirectory:
[
{
"id": "system-1",
"username": "your_yemot_username",
"password": "your_yemot_password",
"enabled": true
}
]S3 Paths
Files are stored in S3 with the following path structure:
system-id/yemot-path/date/filename
License
MIT
