v1.5.1: Sauvegarde/restauration intégrale AstDB et synchronisation SIP immédiate des téléphones (check-sync)
This commit is contained in:
1 parent
accec47d08
commit
65a62ca0e4
6 files changed
+89
-5
No files matched your search
@@ -257,6 +257,17 @@ class BackupManager
|
||||
}
|
||||
$manifestFiles['asterisk_custom_conf'] = ['count' => count(glob($destConfs . '/*'))];
|
||||
|
||||
// E2. Base interne Asterisk AstDB (contacts enregistrés, renvois, DND)
|
||||
$astDbPath = '/var/lib/asterisk/astdb.sqlite3';
|
||||
if (file_exists($astDbPath)) {
|
||||
$destAstDb = $stageDir . '/astdb.sqlite3';
|
||||
copy($astDbPath, $destAstDb);
|
||||
$manifestFiles['astdb.sqlite3'] = [
|
||||
'size' => filesize($destAstDb),
|
||||
'md5' => md5_file($destAstDb),
|
||||
];
|
||||
}
|
||||
|
||||
// F. Avatars et photos des contacts de l'annuaire (/var/www/nexus-pbx/public/avatars/)
|
||||
$publicAvatars = '/var/www/nexus-pbx/public/avatars';
|
||||
if (is_dir($publicAvatars)) {
|
||||
@@ -595,6 +606,15 @@ class BackupManager
|
||||
exec("chmod -R 775 " . escapeshellarg($destAvatars));
|
||||
}
|
||||
|
||||
// 9c. Restauration de la base interne AstDB (contacts enregistrés, renvois, DND)
|
||||
if (file_exists($stageDir . '/astdb.sqlite3')) {
|
||||
$targetAstDb = '/var/lib/asterisk/astdb.sqlite3';
|
||||
copy($stageDir . '/astdb.sqlite3', $targetAstDb);
|
||||
@chown($targetAstDb, 'asterisk');
|
||||
@chgrp($targetAstDb, 'asterisk');
|
||||
@chmod($targetAstDb, 0664);
|
||||
}
|
||||
|
||||
// 10. Régénération intégrale des configurations Asterisk avec la nouvelle base restaurée
|
||||
Database::resetConnection();
|
||||
$dbFresh = Database::getConnection(true);
|
||||
@@ -609,6 +629,25 @@ class BackupManager
|
||||
$reloadRes = ['success' => false, 'error' => $e->getMessage()];
|
||||
}
|
||||
|
||||
// 12. Notification de réenregistrement immédiat des téléphones IP (check-sync)
|
||||
try {
|
||||
$extList = $dbFresh->query("SELECT extension FROM extensions WHERE enabled = 1")->fetchAll(\PDO::FETCH_COLUMN);
|
||||
foreach ($extList as $extItem) {
|
||||
$ami->runCommand("pjsip send notify snom-check-cfg endpoint {$extItem}");
|
||||
}
|
||||
$astContacts = $ami->runCommand("database show registrar/contact");
|
||||
foreach (preg_split('/\r?\n/', $astContacts) ?: [] as $cLine) {
|
||||
if (preg_match('/^\/registrar\/contact\/([^;]+);@[a-f0-9]+:\s*(\{.*\})/i', $cLine, $cM)) {
|
||||
$meta = json_decode($cM[2], true);
|
||||
if (!empty($meta['uri'])) {
|
||||
$ami->runCommand("pjsip send notify snom-check-cfg uri " . escapeshellarg($meta['uri']));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// Silencieux si échec d'envoi NOTIFY
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => 'Restauration complète effectuée avec succès ! Base de données réintégrée, fichiers audio, messageries vocales et configurations Asterisk rechargées.',
|
||||
|
||||
Reference in new issue
Block a user