Backup script to move the call recording file from 1 single older to year month day


(Superdigi) #1

Hi All,

My Pabx are storing the call recording files in 1 single folder name monitor. I would like to write a scripts to separate it to year month day. May I know how to we write the script to separate it? below is the files name pattern. this all file will backup into folder /2015/09/25/filesname.wav

20150925-161109-1443168650.30077.wav
OUT5081-20150925-161159-1443168719.30081.wav


(Lorne Gaetz) #2

How have you configured recording? A stock FreePBX system already separates recordings into daily folders.


(Superdigi) #3

old version Pabx are storing under /var/spool/asterisk/monitor/recordingfile.wav . it not separate the daily folder. I would like to get a script to backup those files with separate it.


#4

paste a sample filename, the date is generally encoded twice in the name, one quit obviously, the other in the ‘uniqueid’ (which includes seconds since the epoch) so piping a ‘ls’ through a ‘for loop’ filter should be easy


#5

Some simple bashisms for a call

CALL=($(echo /var/spool/asterisk/monitor/ondemand-18555551212-2001-20200831-103317-1598895197.3719.wav|tr '-' ' '|tr '.' ' '))
echo "Original directory:-  $(dirname ${CALL[0]})"
echo "Original calltype:-  $(basename ${CALL[0]})"
echo "Source:- ${CALL[1]}"
echo "Destination:- ${CALL[2]}"
echo "Hour:- ${CALL[3]}" # spurious data
echo "Minute:- ${CALL[4]}" # spurious data
echo "TimeStamp:- ${CALL[5]}"

# so  for the mv destination, something like 
NEWNAME=$(date -d @${CALL[5]} +/NEW/DIRECTORY/YOU/WANT/%Y/%m/%d/From-${CALL[1]}_T0-${CALL[2]}-${CALL[5]}.${CALL[6]}.${CALL[7]})
echo $NEWNAME