TIPS Moving voicemail between servers via a cron job

Keith McCabe

New Member
Joined
Nov 9, 2015
Messages
2
Reaction score
0
Although I'm not a newbie, I have to admit that this is a bit over my head. Here is the situation. We have added a "fallback" PBX system at our datacenter in case our office has power/internet issues. Our phone systems are routed that in case of problems all phone calls will go to the data center. We are running Asterisk 11 and FreePBX 2.11.0.43. For all the users, the system will send them all their calls via voicemail emails. But some of our users still want to get their voicemails on their Polycom phones as well. I have created a cron job that will .tar the folder and send the data over to the server. (It uses a method that I read in the forums).
My question is, how can I get this cron job to run every hour, but only to run the data to our production Asterisk server when there are voicemails on the redundant server?
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,634
Reaction score
846
Make sure you have a keybased login on the remote (ssh-copy-id "(user)@ip.of.remote.machine -p (ssh port)" ) on both machines and on both also but use * 30 * * * on one:-

crontab -e -u (user)

add

* 0 * * * [ ! -z "$(find /var/spool/asterisk/voicemail/ -name *.txt -mmin -60)" ] && rsync -av --delete -e 'ssh -p(sshport) /var/spool/asterisk/voicemail/ (user)@ip.of.remote.machine:/var/spool/asterisk/voicemail/ >/dev/null


if you want the monitor files also , use /var/spool/asterisk/
 
Last edited:

Keith McCabe

New Member
Joined
Nov 9, 2015
Messages
2
Reaction score
0
Make sure you have a keybased login on the remote (ssh-copy-id "(user)@ip.of.remote.machine -p (ssh port)" )

crontab -e -u (user)

add

* 0 * * * rsync -av -e 'ssh -p(sshport) /var/spool/asterisk/voicemail/ (user)@ip.of.remote.machine:/var/spool/asterisk/voicemail/ >/dev/null


if you want the monitor files also , use /var/spool/asterisk/
********************************************************************************************************
Yes, but how do you get it to send the data ONLY if you have something to sync.?
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,634
Reaction score
846
It will,

man rsync

I edited the post to make it "swing both ways"

you can use cron jobs on a far tighter schedules if you don't try to do it at the exact same time

man crontab

A couple of other possibilities include glusterfs (my prefered method) and rsnapshot but they both takes some RTFM'ing
 
Last edited:

Members online

Forum statistics

Threads
25,821
Messages
167,814
Members
19,246
Latest member
abuhyder
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top