You are here

function demo_drush_create_snapshot in Demonstration site (Sandbox / Snapshot) 6

Callback for drush command demo-create.

1 string reference to 'demo_drush_create_snapshot'
demo_drush_command in ./demo.drush.inc
Implementation of hook_drush_command().

File

./demo.drush.inc, line 111

Code

function demo_drush_create_snapshot($filename = NULL, $description = NULL) {

  // filename validation code
  if (empty($filename)) {
    drush_set_error('Argument file name is not given. See "drush help demo-create" for usage.');
    return;
  }
  if (!preg_match('/^[-_\\.a-zA-Z0-9]+$/', $filename)) {
    drush_set_error(t('Dump filename %title must contain alphanumeric characters, dots, dashes and underscores only. Other characters, including blanks (spaces), are not allowed.', array(
      '%title' => $filename,
    )));
    return;
  }

  // invoke _demo_dump() to create snapshot
  module_load_include('inc', 'demo', 'demo.admin');
  $options = array(
    'filename' => $filename,
    'description' => $description,
    'tables' => demo_enum_tables(),
  );
  if ($fileconfig = _demo_dump($options)) {
    drush_log('Successfully created snapshot ' . $fileconfig['sqlfile'], 'ok');
  }
}