FreePBX | Register | Issues | Wiki | Portal | Support

Backup/Restore voicemail on specific extensions

freepbx
Tags: #<Tag:0x00007fcd245067b8>

(Bob Blevins) #1

Hi All ,
I’ve searched online but haven’t found to much out there . My question is this is there a way to backup / restore a handful of voicemail messages for a group of extensions? We currently delete all messages that are 30 days old automatically currently there was a request to have some extensions bypass the deleting process, also is there a way to restore specific extensions voicemail messages? We do nightly backups of the system / voicemail.
thanks in advance for your help !
FreePBX 13.0.195.4
firmware 10.13.66-20
Aterisk 11.25.3


(Dave Burgess) #2

Comedian Mail (which is the application that manages your voicemail) isn’t particularly well suited to getting messed with. Having said that, you can backup the call recording (in the voicemail directory tree). IIRC, though, the naming conventions used in Comedian Mail are less than awesome, as in, the file numbering is ‘1’, ‘2’, ‘3’, and either fills in missing numbers or starting over at ‘1’ if the directory is empty (@dicko has written on this extensively in the past).

Basically, if you want to save the recordings, that’s doable, but you have to manage the filenames deliberately unless you are OK with recordings getting randomly overwritten.


(Tom Ray) #3

The voicemail server does NOT fill in missing voicemails. Yes, it uses msg0000.wav and could use up to msg9999.wav depending on how many messages you allow to be stored.

Each time an event happens in the Voicemail App such as a new voicemail is left, voicemail is deleted, etc. Something that changes the contents of the folder the Voicemail App re-maps the names of the files. So if you have msg0000.wav to msg0006.wav you have 7 voicemails in your INBOX. Someone leaves a new voicemail you now have msg0007.wav in your INBOX. You go in via *97/*98 and delete your second new voicemail and listen to the first three, the two that you listened to are moved to the Old folder you now have msg0000.wav to msg0004.wav, leaving you with 5 messages left in your INBOX.

If you have the original 8 messages and delete them from the system at the CLI level leaving you with msg0001.wav, msg0004.wav and msg0007.wav the moment you access your mailbox via the Voicemail App and it remaps those messages (delete one, move one, a new one is added) those msg0001.wav, msg0004.wav and msg0007.wav files are re-mapped like normal and you end up with msg0000.wav to msg0003.wav.

So each time a voicemail is removed/moved/added to a folder the Voicemail App re-maps each file name to be in a sequential order. It doesn’t fill in new messages with missing file names it always re-maps and gives the newest message the highest number mapping.


(Dave Burgess) #4

It’s awesome that we are in violent agreement.

The way that message file names are managed in comedian mail is not consistent with trying to “archive these messages in an outside system”. Thanks for repeating the information about how the message files are mapped and re-mapped.


(Tom Ray) #5

@bblevins To achieve what you are looking for is going to require some coding.

  1. Under Voicemail Admin --> Settings Tab --> General Sub Tab there is a setting for “Max Number of Deleted Messages” set that to a number you are comfortable with. When a message is deleted via the voicemail app, in any folder, it will store that message in the Deleted folder. If a user deletes a message and the Max Deleted is reached, just like with any other folder, the oldest message is removed so the new message can be saved.

This should help with keeping a backup of voicemails for longer than 30 days in either the INBOX/Old/Family/Friends/Work folders where the user can have messages.

  1. Restoring voicemails from the Deleted folder. Here’s where you need to break out your coding skills. Each voicemail has two files associated with it, a .txt and .wav. The .txt aka the MFI stores information about that particular message. Here is an example.

;
; Message Information file
;
[message]
origmailbox=2112
context=macro-vm
macrocontext=from-internal
exten=s-DIRECTDIAL
rdnis=unknown
priority=3
callerchan=SIP/2112-00000319
callerid=“Tom Ray” <2112>
origdate=Sun Sep 16 01:38:40 PM UTC 2018
origtime=1537105120
category=
msg_id=1537105120-0000001e
flag=
duration=3

So to simply take all the messages in the Deleted folder and throw them back into the INBOX folder you would just take the .txt/.wav files and re-map them with the proper name to match what is currently in the INBOX. That’s the easy part.

To look for and restore particular voicemails by say CallerID or Date/Time you would have to loop through the .txt files in the Deleted Folder and parse out each .txt file and look for the information there. You can look at the callerid, the date time, and the msg_id is unique so even loop through the folders and pull that information at anytime to keep track of it.

Once you find the file(s) you want to restore, same end process as before. You just move them into the folder you want and re-map the names to the proper ordered names based on the current contents of the folder.

If you restore messages to the INBOX you can use the AMI action VoicemailRefresh to force a new MWI notify to the device(s).

If you have physically deleted all traces of the file off the server and want to pull it from a restore, you would need to take the .tar.gz file of the backup and untar/gzip it somewhere. It’s going to put the entire file structure where ever you do this so I would do it on another server or a folder in your PC. Because you’re going to have to drill down into the folder structures into the /var/spool/asterisk/voicemail folder and into the right mailbox and folder then get the files from there.

You would just need to take those files and put them on the PBX and restore them to the mailbox folders as I mentioned above. Always keep in mind that you need to update and make sure the ownership and group for the files is asterisk:asterisk so the system can access them without problem.


(Bob Blevins) #6

Thank you for your response ! I haven’t done any coding yet but i will learn so any tips there would be greatly appreciated.