CDR detail in the DB

Voipy

Member
Feb 5, 2026
45
1
8
56
Hi

On our Fusion set up we periodically run a script to remove most of the information from the CDRs. There is huge amount of info which is really useful when troubleshooting, but there is no need to keep this after a few days. We do need to keep the CDRs for 5 years so we want them as compact as possible.

Is there a need to do this on FS PBX as well, bearing in mind the 5 years, or does it store far less info to begin with?
 
I suggest you continue to run your script and perform a vacuum periodically. It's not enough to just delete records
 
Hi - thanks. Autovacuum should be running though so no need to to perform this manually I think?
 
Last edited:
Hi

Log into postgres - the username will be fusionpbx. If you don't know the pass, it will be in /etc/fusionpbx/config.conf

that will get you in. I am far from well versed in postgres stuff but remember that a vacuum full will lock the tables, so that you should do when you have no traffic. A normal vacuum does not, but will not release the space to the OS, only make it available to Postgres again.
 
I appreciate the quick response, but I am a total newbie with this issue.

How do I get to the login into postgres?
I'm sure that once I get to log into postgres, I can figure it out.
 
If by getting to "a login" you mean a gui page - there isn't one. For that you would need something like phpmyadmin.

from the cli - something like:

psql --host=127.0.0.1 --username=fusionpbx

It will ask for the password - give that, and you're in. From there you will have to run the commands. A google may be best here but be careful, you're working on the live DB so you may want to make sure you have a backup in case you do something wrong.
 
Thanks for this tip.

I was able to get to the DB and ran VACUUM FULL but it didn't shrink down the size on the disk.
Is there a way to shrink this to free up space on the disk?
 
Did you first delete records? VACUUM FULL doesn't do anything on it's own to reduce the space.
You need to first delete the records. They will be marked as deleted and running VACUUM FULL will reclaim that space
 
I deleted all the Voicemails, Call Recordings and Email Queues already before running the VACUUM.

Do you mean the Call Detail Records? I can't figure out how to delete those.
 
Last edited:
The stuff you are deleting is not in the DB so by deleting those you already created space.

Postgres does not give space back to the OS when you delete things - vacuum full will, AFTER you deleted records from the DB. To delete CDRs older than 90 days, you would do something like::

DELETE FROM v_xml_cdr WHERE start_stamp < NOW() - INTERVAL '90 days';"

This forum and other places are full of examples of this.