Recordings on other hard drive, Moving it in live environment, Possible? any input appreciated!

Status
Not open for further replies.

bdmonsey

Member
Jul 23, 2019
146
6
18
42
My server is filling up with recordings, i'm to 95% i do have an additional hard drive mounted to this server, whats the easiest and safest way moving over the old files and setting that all recordings from now to go to the new hard drive?

And at the same time, is is possible to store on like google drive or any other external syncing backup software?

Thanks
 

ad5ou

Active Member
Jun 12, 2018
884
196
43
The script below will probably help save some space. This requires "ffmpeg" to convert the wav files to opus.
You will need to modify the directories to match your environment. My system records directly to a secondary dive mounted to "/mnt/retain"
The script runs during the night to convert "yesterday's" wav files to the space saving opus versions and updates database.

There are a few other versions of this script posted here on the forums.

Bash:
#!/bin/sh
#
#  Needs ffmpeg to work.  Verify recordings directory and set database PW
#
PGPASSWORD="$(grep db_password /etc/fusionpbx/config.php | cut -d "'" -f2)"
export PGPASSWORD
#
echo $(date -u) "conversions started" >> /root/convert.log
#Find wav files from yesterday and convert them to opus, then delete original fi                                                                                                                                                             les, then update xml cdr and call recording database entries
for DIRECTORY in /mnt/retain/*/; do
  DIRYESTERDAY=/mnt/retain/`basename "$DIRECTORY"`/archive/`date -d "yesterday"                                                                                                                                                              +%Y/%b/%d`
    if [ -d "$DIRYESTERDAY" ]; then
      for WAVFILE in /mnt/retain/`basename "$DIRECTORY"`/archive/`date -d 'yeste                                                                                                                                                             rday' +%Y/%b/%d`/*.wav; do
      BNAME=`basename $WAVFILE .wav`
echo $BNAME
        ffmpeg -i $WAVFILE -c:a libopus -b:a 8k $DIRYESTERDAY/$BNAME.ogg >> /dev                                                                                                                                                             /null
        psql --host=127.0.0.1 --username=fusionpbx -t -c "UPDATE v_call_recordin                                                                                                                                                             gs SET call_recording_name = '$BNAME.ogg' WHERE call_recording_name = '$BNAME.wa                                                                                                                                                             v' and call_recording_path = '$DIRYESTERDAY'"
        psql --host=127.0.0.1 --username=fusionpbx -t -c "UPDATE v_xml_cdr set r                                                                                                                                                             ecord_name = '$BNAME.ogg' WHERE record_name = '$BNAME.wav'"
      done
    rm $DIRYESTERDAY/*.wav
    fi
 chown -R www-data:www-data $DIRYESTERDAY/*
done
# run again for plain -archive- directory calls
for DIRECTORY in /mnt/retain/*/; do
  DIRYESTERDAY=/mnt/retain/`basename "$DIRECTORY"`/`date -d "yesterday" +%Y/%b/%                                                                                                                                                             d`
    if [ -d "$DIRYESTERDAY" ]; then
      for WAVFILE in /mnt/retain/`basename "$DIRECTORY"`/`date -d 'yesterday' +%                                                                                                                                                             Y/%b/%d`/*.wav; do
      BNAME=`basename $WAVFILE .wav`
echo $BNAME
        ffmpeg -i $WAVFILE -c:a libopus -b:a 8k $DIRYESTERDAY/$BNAME.ogg >> /dev                                                                                                                                                             /null
        psql --host=127.0.0.1 --username=fusionpbx -t -c "UPDATE v_call_recordin                                                                                                                                                             gs SET call_recording_name = '$BNAME.ogg' WHERE call_recording_name = '$BNAME.wa                                                                                                                                                             v' and call_recording_path = '$DIRYESTERDAY'"
        psql --host=127.0.0.1 --username=fusionpbx -t -c "UPDATE v_xml_cdr set r                                                                                                                                                             ecord_name = '$BNAME.ogg' WHERE record_name = '$BNAME.wav'"
      done
    rm $DIRYESTERDAY/*.wav
    fi
 chown -R www-data:www-data $DIRYESTERDAY/*
done
echo $(date -u) "conversions complete" >> /root/convert.log


find /mnt/retain/* -name '*.tar.bz2' -mtime +3 -exec rm {} \;
 
Status
Not open for further replies.