From 4f3a5345ad98e3f227822f229995b3a0c5ef9b58 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 29 Mar 2017 15:08:53 -0600 Subject: [PATCH] Update fusionpbx-maintenance.sh --- .../resources/backup/fusionpbx-maintenance.sh | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/debian/resources/backup/fusionpbx-maintenance.sh b/debian/resources/backup/fusionpbx-maintenance.sh index ce48df3..ec58653 100644 --- a/debian/resources/backup/fusionpbx-maintenance.sh +++ b/debian/resources/backup/fusionpbx-maintenance.sh @@ -1,38 +1,46 @@ #!/bin/sh +#settings export PGPASSWORD="zzz" db_host=127.0.0.1 db_port=5432 +switch_package=true # true or false +#set the date now=$(date +%Y-%m-%d) + +#make sure the directory exists mkdir -p /var/backups/fusionpbx/postgresql #show message to the console echo "Maintenance Started" #delete freeswitch logs older 7 days -#source -#find /usr/local/freeswitch/log/freeswitch.log.* -mtime +7 -exec rm {} \; -#package -find /var/log/freeswitch/freeswitch.log.* -mtime +7 -exec rm {} \; +if [ .$switch_package = .true ]; then + find /var/log/freeswitch/freeswitch.log.* -mtime +7 -exec rm {} \; +else + find /usr/local/freeswitch/log/freeswitch.log.* -mtime +7 -exec rm {} \; +fi #delete fax older than 90 days -#source -#find /usr/local/freeswitch/storage/fax/* -name '*.tif' -mtime +90 -exec rm {} \; -#find /usr/local/freeswitch/storage/fax/* -name '*.pdf' -mtime +90 -exec rm {} \; -#package -#find /var/lib/freeswitch/storage/fax/* -name '*.tif' -mtime +90 -exec rm {} \; -#find /var/lib/freeswitch/storage/fax/* -name '*.pdf' -mtime +90 -exec rm {} \; +if [ .$switch_package = .true ]; then + #find /var/lib/freeswitch/storage/fax/* -name '*.tif' -mtime +90 -exec rm {} \; + #find /var/lib/freeswitch/storage/fax/* -name '*.pdf' -mtime +90 -exec rm {} \; +else + #find /usr/local/freeswitch/storage/fax/* -name '*.tif' -mtime +90 -exec rm {} \; + #find /usr/local/freeswitch/storage/fax/* -name '*.pdf' -mtime +90 -exec rm {} \; +fi #delete from the database #psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_fax_files WHERE fax_date < NOW() - INTERVAL '90 days'" #delete voicemail older than 90 days -#source -#find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.wav' -mtime +90 -exec rm {} \; -#find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.mp3' -mtime +90 -exec rm {} \; -#package -#find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.wav' -mtime +90 -exec rm {} \; -#find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.mp3' -mtime +90 -exec rm {} \; +if [ .$switch_package = .true ]; then + #find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.wav' -mtime +90 -exec rm {} \; + #find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.mp3' -mtime +90 -exec rm {} \; +else + #find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.wav' -mtime +90 -exec rm {} \; + #find /usr/local/freeswitch/storage/voicemail/* -name 'msg_*.mp3' -mtime +90 -exec rm {} \; +fi #psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_voicemail_messages WHERE to_timestamp(created_epoch) < NOW() - INTERVAL '90 days'" #delete call detail records older 90 days #psql --host=127.0.0.1 --username=fusionpbx -c "delete from v_xml_cdr WHERE start_stamp < NOW() - INTERVAL '90 days'"