You are here

function _backup_migrate_setup_database_defaults in Backup and Migrate 6.2

Same name and namespace in other branches
  1. 8.2 backup_migrate.install \_backup_migrate_setup_database_defaults()
  2. 7.2 backup_migrate.install \_backup_migrate_setup_database_defaults()
2 calls to _backup_migrate_setup_database_defaults()
backup_migrate_install in ./backup_migrate.install
Implementation of hook_install().
backup_migrate_update_2000 in ./backup_migrate.install
Update from 1.x to 2.x.

File

./backup_migrate.install, line 182
Install hooks for Backup and Migrate.

Code

function _backup_migrate_setup_database_defaults() {
  require_once './' . drupal_get_path('module', 'backup_migrate') . '/backup_migrate.module';
  require_once './' . drupal_get_path('module', 'backup_migrate') . '/includes/crud.inc';
  require_once './' . drupal_get_path('module', 'backup_migrate') . '/includes/profiles.inc';
  require_once './' . drupal_get_path('module', 'backup_migrate') . '/includes/files.inc';
  if (variable_get("backup_migrate_file_name", NULL)) {
    $settings = array(
      'profile_id' => 'default',
      'filename' => variable_get("backup_migrate_file_name", _backup_migrate_default_filename()),
      'append_timestamp' => variable_get("backup_migrate_append_timestamp", FALSE) ? 1 : 0,
      'timestamp_format' => variable_get("backup_migrate_timestamp_format", 'Y-m-d\\TH-i-s'),
      'filters' => array(
        'compression' => variable_get("backup_migrate_compression", "none"),
        'exclude_tables' => variable_get("backup_migrate_exclude_tables", array()),
        'nodata_tables' => variable_get("backup_migrate_nodata_tables", array()),
      ),
      'name' => t('Default Settings'),
    );
    $profile = backup_migrate_crud_create_item('profile', $settings);
    $profile
      ->save();
    variable_set("backup_migrate_profile_id", 'default');

    // Set up the default schedules.
    if (variable_get("backup_migrate_schedule_backup_period", 0)) {
      require_once './' . drupal_get_path('module', 'backup_migrate') . '/includes/schedules.inc';
      $schedule = array(
        'name' => t('Default Schedule'),
        'profile_id' => $profile
          ->get_id(),
        'enabled' => 1,
        'destination_id' => 'scheduled',
        'period' => array(
          'number' => variable_get("backup_migrate_schedule_backup_period", 0),
          'type' => 'hours',
        ),
        'keep' => variable_get("backup_migrate_schedule_backup_keep", 0),
      );
      $schedule = backup_migrate_crud_create_item('schedule', $schedule);
      $schedule
        ->save();
    }
  }
}