Categories
Asterisk Support FreePBX Knowledge Base Support Technical

Backing up files in FreePBX 15

The first time you come to restore your FREEpbx 15 system you may find that not everything that you expected is there !

The new backup module backs up on a module by module base and not like before where is was DBs and Files.

Linked here is a repository that has the files to create a module that can be edited to backup directories.

https://bitbucket.org/cybercottage/filebackup

The file you need to edit is Backup.php

<?php

namespace FreePBX\modules\Filebackup;
use FreePBX\modules\Backup as Base;

class Backup extends Base\BackupBase
{
    public function runBackup($id, $transaction)
    {
        $this->addDirectories([
            '/etc/asterisk','/tftpboot',
        ]);
        $files = glob("/etc/asterisk/*conf");
        foreach ($files as $file) {
            $path = pathinfo($file, PATHINFO_DIRNAME);
            $this->addFile(basename($file), $path, '', "conf");
    }
    $files = glob("/tftpboot/*xml");
        foreach ($files as $file) {
            $path = pathinfo($file, PATHINFO_DIRNAME);
            $this->addFile(basename($file), $path, '', "conf");
        }
        return $this;
    }
}

As you see we are backing up /etc/asterisk and /tftpboot , But only *.conf files in /etc/asterisk and only *.xml files in /tftpboot

Details on the new backup system are here https://wiki.freepbx.org/display/FOP/Implementing+Backup

Thanks to James Finstrom for the original version of this, This version is not to replace his work but only to give an example of working with Multiple directories

The downloaded zip file needs to be added as a Local module via Module Admin and enabled, It will obviously give a signing error but this can be disabled in Advanced settings or ignored ;-)

Enjoy but don’t blame me if it doesn’t work. Ive tested it on my systems and all seems good by your experience may be different