The postgres database continuously grows and a lot of the data can be safely deleted. I run these scripts as part of my nightly maintenance and have cut the size of my postgres database by 70%.
Device logs can quickly take up a lot of space and can safely be removed. You can replace the interval amount with a value that works for you
psql --host=127.0.0.1 --username=fusionpbx -t -c "delete from v_device_logs where timestamp < NOW() - interval '10 days'";
If you are running the new SMS message queue, it will grow rapidly. Right now I have mine set to 1 day because I'm only testing.
psql --host=127.0.0.1 --username=fusionpbx -t -c "delete from v_message_queue where message_date < NOW() - interval '1 days'";
The JSON field in v_xml_cdr has useful data for debugging calls but after time, the data is stale and no longer useful.
psql --host=127.0.0.1 --username=fusionpbx -t -c "update v_xml_cdr set json=NULL WHERE start_stamp < NOW() - INTERVAL '10 days'";
Finally, run a vacuum to clean up the database.
psql --host=127.0.0.1 --username=fusionpbx -t -c "vacuum (full)";
Device logs can quickly take up a lot of space and can safely be removed. You can replace the interval amount with a value that works for you
psql --host=127.0.0.1 --username=fusionpbx -t -c "delete from v_device_logs where timestamp < NOW() - interval '10 days'";
If you are running the new SMS message queue, it will grow rapidly. Right now I have mine set to 1 day because I'm only testing.
psql --host=127.0.0.1 --username=fusionpbx -t -c "delete from v_message_queue where message_date < NOW() - interval '1 days'";
The JSON field in v_xml_cdr has useful data for debugging calls but after time, the data is stale and no longer useful.
psql --host=127.0.0.1 --username=fusionpbx -t -c "update v_xml_cdr set json=NULL WHERE start_stamp < NOW() - INTERVAL '10 days'";
Finally, run a vacuum to clean up the database.
psql --host=127.0.0.1 --username=fusionpbx -t -c "vacuum (full)";