3.7. Backups

As we pointed out earlier, all changes made on the keys stored in gconf are automatically backed up the first time a write or delete operation is carried on. Consequently, all these changes could be restored automatically if the user wishes to dismiss or restore them from a file.This is actually true as long as you use the methods provided by EBox::GConfModule to do so.

If your module has at least some part independent from GConf, it must override methods dumpConfig and restoreConfig.

Additionally, apart from module configuration if you want to add some other data concerned to the module which comprise user files, log content and so on; it must implement the methods extendedBackup and extendedRestore. Remember all these information will just save and restore whether user requests it explicitly. Let's show how with an example:

Example 3.14. Overriding backup functions

sub dumpConfig
{
  my ($self, $dir) = @_;
 
  $self->{ldap}->dumpLdapData($dir);
}


sub restoreConfig
{
  my ($self, $dir) = @_;

  $self->{ldap}->loadLdapData($dir);
}

ebox-logs module is intended to administer eBox logs. We wish to have the chance to back up its contents. As module configuration does not include these data, we are going to use extendedBackup and extendedRestore. Remember that this kind of data is only stored if user chooses it.

explicitly. The next example shows how ebox-logs implement these features:

Example 3.15. Overriding functions for extended backups


sub extendedBackup
{
  my ($self, %params) = @_;
  my $dir    = $params{dir};
  
  my $dbengine = EBox::DBEngineFactory::DBEngine();
  my $dumpFile = "$dir/eboxlogs.dump";

  $dbengine->dumpDB($dumpFile);
}


sub extendedRestore
{
  my ($self, %params) = @_;
  my $dir    = $params{dir};

  my $dbengine = EBox::DBEngineFactory::DBEngine();
  my $dumpFile = "$dir/eboxlogs.dump";

  $dbengine->restoreDB($dumpFile);
}