Backup filling entire 2TB drive

I recently upgraded to V16, but during the process I came up with a few errors. Most were solvable, but I upgraded with out a recent backup as everytime I tried to backup, it would completely fill the 2TB ssd. The entire system takes up around 40% of the drive under normal usage. Any idea why the backups are so big?

The client is keeping a large history of call records and recordings, some many years old. The total size is still quite small (relatively, to the size of the drive). Any ideas what could be causing this large of a backup?

It’s a standard tar.file open it up and look. Modern backups are mostly a series of json files so they should be smaller. The bulk of size will be things like sounds or call recordings

The other space eater is CDR records. CDR’s are the FreePBX - Reports - Call Event Logging; this is separate from the Call Recordings. FreePBX does not have a native way to trim or truncate CDR records so they just keep growing. These records are stored in a separate MySQL database named ‘asteriskcdrdb’. You can find this DB file(s) at /var/lib/mysql/asteriskcdrdb. Take a look at the physical files for a quick check on current size. If you are backing up the CDR with your Backup, then these are being written into that backup too.

If you are looking to truncate your CDR records a good post is: https://community.freepbx.org/t/cleaning-up-asteriskcdrdb-mysql-database/89412

There are a few gotchas to watch out for. MySQL by default was storing all of a databases tables in a single DB file. This MySQL setup would not allow for the DB file to be shrunk after deleting CEL and CDR table records. There is a procedure to change your FreePBX MySQL setup so that your MySQL DB files are stored individually. You can search the forum for suggestions on this.

It never finishes before the drive is filled, but I will attempt to open it and see. It seems weird to me that the backup size can be bigger than the entire system.

This was the road we were going down too. Would the backup of the database be bigger than the current database? He doesn’t really need all the call logs, but he doesn’t really want to delete them all either, and is curious on why the backup size is bigger than the full system install, including all the databases and voice files.

This sounds like something is in a loop perhaps generating a file. I would exclude cdr/cel and see if the results are the same…

an example return 0 added in case someone tries to run this… don’t

<?php
return 0;
$file = 'large_file.txt';


$handle = fopen($file, 'a');
if ($handle) {
    $data = str_repeat('Lorem ipsum dolor sit amet, ', 1000); // Repeat a sample text

    // Loop to write data until there is no space left on the drive
    while (fwrite($handle, $data) !== false) {
        // Continue writing until no space left
    }

    fclose($handle);

    echo "File '$file' written until no space left on the drive.";
} else {
    echo "Unable to open file '$file' for writing.";
}

Try setting up a NEW Backup without backing up the CDR or Monitor (call recordings). This backup should be quite reasonably sized. If this works, then you have both a useable backup and will have narrowed down your issue with outsized backups. In Admin → Backup & Restore, Modules, uncheck the ‘CDR Reports’ and ‘Call Recordings’.

If your CDR database is kept remotely (not on your FreePBX install), then YES your backup could be bigger than your whole FreePBX install.

Also, check what your backup has configured under Custom Files. The basic initial Backup only has 1 entry here; Directory - ASTETCDIR.

Thanks for the feedback, I’ll check the custom files. The database is local to the install (on the same drive as the system).

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.