You are here

protected static function InPlaceUpdate::doBackup in Automatic Updates 7

Execute file backup.

Parameters

string $file: The file to backup.

string $project_root: The project root directory.

Return value

bool Return TRUE if backup succeeds, FALSE otherwise.

1 call to InPlaceUpdate::doBackup()
InPlaceUpdate::backup in ./InPlaceUpdate.php
Backup before an update.

File

./InPlaceUpdate.php, line 323

Class

InPlaceUpdate
Class to apply in-place updates.

Code

protected static function doBackup($file, $project_root) {
  $directory = self::$backup . dirname($file);
  if (!file_exists($directory) && !drupal_mkdir($directory, NULL, TRUE)) {
    return FALSE;
  }
  $project_real_path = self::getProjectRealPath($file, $project_root);
  if (file_exists($project_real_path) && !is_dir($project_real_path)) {
    $success = file_unmanaged_copy($project_real_path, self::$backup . $file, FILE_EXISTS_REPLACE);
    if (!$success) {
      return FALSE;
    }
    watchdog('automatic_updates', '"@file" was backed up in preparation for an update.', [
      '@file' => $project_real_path,
    ], WATCHDOG_INFO);
  }
  return TRUE;
}