Esempio n. 1
0
 /**
  * @param $migration
  */
 protected function archiveSite(&$migration)
 {
     $exclude = $this->exclude($migration);
     $files = $this->filesToBackup(DRUPAL_ROOT, $exclude);
     if (!empty($files) && isset($migration['file'])) {
         $this->validateArchiveFiles($migration, $files);
         if ($migration['error'] != FALSE) {
             return;
         }
         $dest_file = $migration['file'] . '.tar';
         if (!empty($migration['compression_ext'])) {
             $dest_file .= '.' . $migration['compression_ext'];
         }
         $gz = new Archiver\ArchiveTar($dest_file, $migration['compression_ext'] ? $migration['compression_ext'] : NULL);
         if (!empty($migration['db_file'])) {
             // Add db file.
             $ret = $gz->addModify(array($migration['db_file']), '', $migration['dir'] . DIRECTORY_SEPARATOR);
         }
         // Remove Drupal root from the file paths, OS dependent.
         if (defined('OS_WINDOWS')) {
             $remove_dir = DRUPAL_ROOT . '\\';
         } else {
             $remove_dir = DRUPAL_ROOT . '/';
         }
         $ret = $gz->addModify($files, '', $remove_dir);
         $migration['tar_file'] = $dest_file;
     } else {
         $migration['error'] = TRUE;
     }
 }