pbx-backup-tool
Version:
A tool for backing up Vodia PBX systems
51 lines (44 loc) • 1.38 kB
JavaScript
const { program } = require('commander');
// Convert to async immediately since we'll use await
(async () => {
// Dynamically import ESM modules
const { default: inquirer } = await import('inquirer');
const { runBackup } = await import('../lib/backup.js');
program
.name('pbx-backup')
.description('Vodia PBX Backup Tool')
.version('1.0.0');
program
.command('backup')
.description('Run PBX backup')
.action(async () => {
try {
const answers = await inquirer.prompt([
{
type: 'confirm',
name: 'whitelisted',
message: 'Have you whitelisted the WAN IP of this machine on the remote PBX?',
default: false
},
{
type: 'confirm',
name: 'proceed',
message: 'This will back up the entire PBX, which may take time and increase CPU usage on the remote server. Do you want to proceed?',
default: false,
when: (answers) => answers.whitelisted
}
]);
if (answers.proceed) {
await runBackup();
} else {
console.log('Operation canceled.');
process.exit(1);
}
} catch (error) {
console.error('Error:', error.message);
process.exit(1);
}
});
program.parse(process.argv);
})();