Backup database + VM to a unix-like box...
Posted: 30 Mar 2005 12:33
I was asked to backup the database and voicemail of 9 nodes on a box. My choice was to do it from a linux box, which is backuped on tapes.
Here is the PERL script that connect to a Alcatel PCX and the VoiceMail:
=====
# Database & Voicemail backup,
# Made by <frank's email> from http://www.AlcatelUnleashed.com
# We assume that there will be no errors!
#!/usr/bin/perl -w
use Net::FTP;
my $server=$ARGV[0];
my $localfile=$ARGV[1];
my $user="mtcl";
my $password="mtcl";
my $vmfile="sbr.sbz";
my @pbxfiles=("cho-dat", "cho-dat_CS", "mao-dat", "mao-dat_CS");
my $ftp=Net::FTP->new($server);
$ftp->login($user, $password);
$ftp->pasv();
$ftp->binary();
if (!length($ARGV[2]))
{
$ftp->get($vmfile, $localfile.".voicemail.sbr.sbz");
}
else
{
$ftp->cwd("/usr4/BACKUP/DAY");
$ftp->get($pbxfiles[0], $localfile.".".$pbxfiles[0]);
$ftp->get($pbxfiles[1], $localfile.".".$pbxfiles[1]);
$ftp->get($pbxfiles[2], $localfile.".".$pbxfiles[2]);
$ftp->get($pbxfiles[3], $localfile.".".$pbxfiles[3]);
}
$ftp->quit;
Then to run this script, you have to call it (from another script if you want, in the crontab for exemple) like that:
perl /path/to/your/script/ftp.pl server_ip_address local_file_name DUMMY
server_ip_address: is the IP address of the system you want to go to (PCX or VM)
local_file_name: is the local file name you want to save the file as
DUMMY: Here you can put any word instead of DUMMY (like 'a' or 'test' or 'dummy' or whatever you want). This is just to give a 3rd argument to the script: If there is only 2 arguments (ip and localfilename), the script will look for a voicemail system. If there is 3 arguments, the script will look for PBX4400 files. Ex:
perl ./ftp.pl 192.168.1.10 newyork
this will save the voicemail file under
voicemail.newyork.sbr.sbz
perl ./ftp.pl 192.168.1.10 newyork blahblah
this will save the files from the PCX under the name
newyork.cho-dat
newyork.cho-dat_CS
newyork.mao-dat
newyork.mao-dat_CS
The script is looking for a BACKUP folder too. You have to create one !
Hope this is clear, if you have any trouble, write back in the forum. Also, remember to set up the BACKUP in the voicemail !
Frank.
Here is the PERL script that connect to a Alcatel PCX and the VoiceMail:
=====
# Database & Voicemail backup,
# Made by <frank's email> from http://www.AlcatelUnleashed.com
# We assume that there will be no errors!
#!/usr/bin/perl -w
use Net::FTP;
my $server=$ARGV[0];
my $localfile=$ARGV[1];
my $user="mtcl";
my $password="mtcl";
my $vmfile="sbr.sbz";
my @pbxfiles=("cho-dat", "cho-dat_CS", "mao-dat", "mao-dat_CS");
my $ftp=Net::FTP->new($server);
$ftp->login($user, $password);
$ftp->pasv();
$ftp->binary();
if (!length($ARGV[2]))
{
$ftp->get($vmfile, $localfile.".voicemail.sbr.sbz");
}
else
{
$ftp->cwd("/usr4/BACKUP/DAY");
$ftp->get($pbxfiles[0], $localfile.".".$pbxfiles[0]);
$ftp->get($pbxfiles[1], $localfile.".".$pbxfiles[1]);
$ftp->get($pbxfiles[2], $localfile.".".$pbxfiles[2]);
$ftp->get($pbxfiles[3], $localfile.".".$pbxfiles[3]);
}
$ftp->quit;
Then to run this script, you have to call it (from another script if you want, in the crontab for exemple) like that:
perl /path/to/your/script/ftp.pl server_ip_address local_file_name DUMMY
server_ip_address: is the IP address of the system you want to go to (PCX or VM)
local_file_name: is the local file name you want to save the file as
DUMMY: Here you can put any word instead of DUMMY (like 'a' or 'test' or 'dummy' or whatever you want). This is just to give a 3rd argument to the script: If there is only 2 arguments (ip and localfilename), the script will look for a voicemail system. If there is 3 arguments, the script will look for PBX4400 files. Ex:
perl ./ftp.pl 192.168.1.10 newyork
this will save the voicemail file under
voicemail.newyork.sbr.sbz
perl ./ftp.pl 192.168.1.10 newyork blahblah
this will save the files from the PCX under the name
newyork.cho-dat
newyork.cho-dat_CS
newyork.mao-dat
newyork.mao-dat_CS
The script is looking for a BACKUP folder too. You have to create one !
Hope this is clear, if you have any trouble, write back in the forum. Also, remember to set up the BACKUP in the voicemail !
Frank.