Fusionpbx – release disk space

handle history files voicemail + fax

cd /var/lib/freeswitch/storage/voicemail/
find . -mtime +360 -print > /tmp/a
# remove directory entries in /tmp/a 

cd /var/lib/freeswitch/storage/fax

handle database (postgres)

# get cdr tables schema
pg_dump --verbose -cs  -U fusionpbx fusionpbx -t v_xml_cdr -f /tmp/b.sql

# export database
root@fusionpbx:~# more fusionpbx_backup.sh

now=$(date +%Y-%m-%d)
echo "Server Backup at "$now;
export PGPASSWORD="1CQorF0aQYmBnRIpNklTUz3pU"

pg_dump --verbose -Fc --host= --port=5432 -U fusionpbx fusionpbx --schema=public -f /root/f.sql
echo 'Backup Complete';

stop freeswitch, make sure no new entries generated in database

create a new table, same with cdr, select recent 12 months cdr entries in it, drop cdr, rename temp table as cdr, create index

service nginx stop
systemctl stop freeswitch

DROP INDEX public.index_start_stamp;
DROP INDEX public.index_cdr_start_epoch;
DROP INDEX public.index_cdr_domain_uuid;

DROP TABLE public.v_xml_cdr;
ALTER TABLE v_xml_cdr OWNER TO fusionpbx;

CREATE INDEX index_cdr_domain_uuid ON v_xml_cdr USING btree (domain_uuid);
CREATE INDEX index_cdr_start_epoch ON v_xml_cdr USING btree (start_epoch);
CREATE INDEX index_start_stamp ON v_xml_cdr USING btree (start_stamp);

GRANT ALL ON TABLE v_xml_cdr TO neon_user;

systemctl start freeswitch
service nginx start