Introduction

The new FreePBX backup now allows each module to handle their own data.  To see modules that implement the new backup you can run the command: fwconsole bu --Implemented

Please note in 15 the backup and restore methods are removed. Please remove these from the modules BMO class. They are unimplemented.

The Files

Implementation uses 2 classes. One class for each purpose.

Skeleton Files

You can copy these from the backup directory then change the module name as required.

[root@freepbx blacklist]# pwd
/usr/src/freepbx/blacklist
[root@freepbx blacklist]# cp ../backup/examples/Backup.php.template Backup.php
[root@freepbx blacklist]# cp ../backup/examples/Restore.php.template Restore.php
[root@freepbx blacklist]# sed -i 's/__MODULENAME__/Blacklist/g' Backup.php
[root@freepbx blacklist]# sed -i 's/__MODULENAME__/Blacklist/g' Restore.php

The Code

Backup.php

<?php
namespace FreePBX\modules\Recordings;
use FreePBX\modules\Backup as Base;
class Backup Extends Base\BackupBase{
  public function runBackup($id,$transaction){
    //$this->FreePBX
  }
}

Restore.php

<?php
namespace FreePBX\modules\Recordings;
use FreePBX\modules\Backup as Base;
class Restore Extends Base\RestoreBase{ 
  public function runRestore(){
    //$this->FreePBX
    //$this->tmpdir
  }
}

Namespaces

<?php
namespace FreePBX\modules\Recordings;
use FreePBX\modules\Backup as Base;
class Restore Extends Base\RestoreBase{
  ..code goes here..
}


<?php
namespace FreePBX\modules\Recordings;
use FreePBX\modules\Backup as Base;
class Backup Extends Base\BackupBase{
  ..code goes here..
}

Logging

Backup.php and Restore.php both implement a backend logger which you can utilize as such:

$this->log($msg,$level);

If $level is not set then the default level will be used which is INFO, you can also use the following levels:

Backup.php

Backup Module Variables

By default the class inherits:

Backup Module Methods

Backup configuration methods

Backup Overridable methods

Backup Helper Methods

Restore.php

Restore Module Variables

By default you will have access to:

Restore Module Methods

Restore configuration methods

Restore Overridable methods

Restore Helper Methods

Legacy Restore

Restore legacy methods are added to the same Restore.php class file as the 15+ restore. They do not conflict.

Legacy Restore Configuration Methods

Legacy Restore Overridable methods

Legacy Restore Helper Methods