You are here

function backup_migrate_backup in Backup and Migrate 6

Same name and namespace in other branches
  1. 5 backup_migrate.module \backup_migrate_backup()

The backup/export form.

1 string reference to 'backup_migrate_backup'
backup_migrate_menu in ./backup_migrate.module
Implementation of hook_menu().

File

./backup_migrate.module, line 213
Create (manually or scheduled) and restore backups of your Drupal MySQL database with an option to exclude table data (f.e. cache_*)

Code

function backup_migrate_backup() {
  $form = array();
  $tables = _backup_migrate_get_table_names();
  $form['backup_migrate_exclude_tables'] = array(
    "#type" => "select",
    "#multiple" => TRUE,
    "#title" => t("Exclude the following tables altogether"),
    "#options" => $tables,
    "#default_value" => variable_get("backup_migrate_exclude_tables", _backup_migrate_default_exclude_tables()),
    "#description" => t("The selected tables will not be added to the backup file."),
  );
  $form['backup_migrate_nodata_tables'] = array(
    "#type" => "select",
    "#multiple" => TRUE,
    "#title" => t("Exclude the data from the following tables"),
    "#options" => $tables,
    "#default_value" => variable_get("backup_migrate_nodata_tables", _backup_migrate_default_structure_only_tables()),
    "#description" => t("The selected tables will have their structure backed up but not their contents. This is useful for excluding cache data to reduce file size."),
  );
  $form['backup_migrate_file_name'] = array(
    "#type" => "textfield",
    "#title" => t("Backup file name"),
    "#default_value" => variable_get("backup_migrate_file_name", _backup_migrate_default_file_name()),
  );
  if (module_exists('token')) {
    $form['token_help'] = array(
      '#title' => t('Replacement patterns'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#description' => t('Prefer raw-text replacements for text to avoid problems with HTML entities!'),
    );
    $form['token_help']['help'] = array(
      '#value' => theme('token_help', ''),
    );
  }
  $compression_options = array(
    "none" => t("No Compression"),
  );
  if (@function_exists("gzencode")) {
    $compression_options['gzip'] = t("GZip");
  }
  if (@function_exists("bzcompress")) {
    $compression_options['bzip'] = t("BZip");
  }
  if (class_exists('ZipArchive')) {
    $compression_options['zip'] = t("Zip");
  }
  $form['backup_migrate_compression'] = array(
    "#type" => "radios",
    "#title" => t("Compression"),
    "#options" => $compression_options,
    "#default_value" => variable_get("backup_migrate_compression", "none"),
  );
  $destination_options = array(
    "download" => t("Download"),
  );
  if (_backup_migrate_check_destination_dir('manual')) {
    $destination_options['save'] = t("Save to Files Directory");
  }
  $form['backup_migrate_destination'] = array(
    "#type" => "radios",
    "#title" => t("Destination"),
    "#options" => $destination_options,
    "#default_value" => variable_get("backup_migrate_destination", "download"),
  );
  $form['backup_migrate_append_timestamp'] = array(
    "#type" => "checkbox",
    "#title" => t("Append a timestamp."),
    "#default_value" => variable_get("backup_migrate_append_timestamp", 1),
  );
  $form['backup_migrate_timestamp_format'] = array(
    "#type" => "textfield",
    "#title" => t("Timestamp format"),
    "#default_value" => variable_get("backup_migrate_timestamp_format", 'Y-m-d\\TH-i-s'),
    "#description" => t('Should be a PHP <a href="!url">date()</a> format string.', array(
      '!url' => 'http://www.php.net/date',
    )),
  );
  $form['backup_migrate_save_settings'] = array(
    "#type" => "checkbox",
    "#title" => t("Save these settings."),
    "#default_value" => 1,
  );
  $form[] = array(
    '#type' => 'submit',
    '#value' => t('Backup Database'),
  );
  return $form;
}