46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
require('dotenv').config();
|
|
const {
|
|
downloadBackupFile,
|
|
compressBackupFile,
|
|
formatBytes,
|
|
sendTelegramBroadcast
|
|
} = require('./index.js');
|
|
|
|
async function downloadOnly() {
|
|
try {
|
|
console.log('Starting download process...');
|
|
|
|
// Download backup file from SMB share
|
|
const localBackupFile = await downloadBackupFile();
|
|
console.log('Download completed:', localBackupFile);
|
|
|
|
// Optionally compress the file
|
|
if (process.argv.includes('--compress')) {
|
|
const compressedFile = await compressBackupFile(localBackupFile);
|
|
console.log('Compression completed:', compressedFile);
|
|
|
|
// Optionally send notification
|
|
if (process.argv.includes('--notify')) {
|
|
await sendTelegramBroadcast('all', `Backup downloaded and compressed ✅\nFile: ${compressedFile}`);
|
|
}
|
|
} else if (process.argv.includes('--notify')) {
|
|
await sendTelegramBroadcast('all', `Backup downloaded ✅\nFile: ${localBackupFile}`);
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('Download failed:', error);
|
|
|
|
// Optionally notify on error
|
|
if (process.argv.includes('--notify')) {
|
|
await sendTelegramBroadcast('errors', `Download failed 🔴\nError: ${error.message}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Run if called directly
|
|
if (require.main === module) {
|
|
downloadOnly();
|
|
}
|
|
|
|
module.exports = { downloadOnly };
|