yemot-recordings-backup
Version:
Automatic backup tool for Yemot HaMashiach call recordings to Amazon S3
185 lines (140 loc) • 4.23 kB
Markdown
# Yemot Recordings 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
- Docker support for containerized deployment
## Requirements
- Node.js 14 or later
- AWS S3 bucket
- Yemot HaMashiach system credentials
## Installation
```bash
# Install globally to use the CLI
npm install -g yemot-recordings-backup
# Or install locally in your project
npm install yemot-recordings-backup
```
## CLI Usage
Once installed globally, you can use the `yemot-backup` command:
```bash
# Show help
yemot-backup --help
# Run backup immediately
yemot-backup run
# Run backup from a specific path
yemot-backup run --yemot-path "/path/to/backup"
# Schedule daily backups
yemot-backup schedule
# 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
# 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:status
```
## Library Usage
You can also use this package as a library in your Node.js projects:
```javascript
const yemotBackup = require('yemot-recordings-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', '/specific/path');
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:
1. Create a `.env` file 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
```
2. Create a `systems.json` file in the `src` directory:
```json
[
{
"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