You are here

function backup_migrate_file_compress in Backup and Migrate 5.2

Compress a file with the given settings. Also updates settings to reflect new file mime and file extension.

1 call to backup_migrate_file_compress()
backup_migrate_perform_backup in ./backup_migrate.module
Perform a backup with the given settings.

File

includes/files.inc, line 88
General file handling code for Backup and Migrate.

Code

function backup_migrate_file_compress($file, &$settings) {
  switch ($settings['compression']) {
    case "gzip":
      $temp_gz = backup_migrate_temp_file('gz');
      if ($success = _backup_migrate_gzip_encode($file, $temp_gz, 9)) {
        $file = $temp_gz;
        $settings['filename'] .= ".gz";
        $settings['filemime'] = 'application/x-gzip';
      }
      break;
    case "bzip":
      $temp_bz = backup_migrate_temp_file('bz');
      if ($success = _backup_migrate_bzip_encode($file, $temp_bz)) {
        $file = $temp_bz;
        $settings['filename'] .= ".bz";
        $settings['filemime'] = 'application/x-bzip';
      }
      break;
    case "zip":
      $temp_zip = backup_migrate_temp_file('zip');
      if ($success = _backup_migrate_zip_encode($file, $temp_zip, $filename)) {
        $file = $temp_zip;
        $settings['filename'] .= ".zip";
        $settings['filemime'] = 'application/zip';
      }
      break;
  }
  if (!$file) {
    _backup_migrate_message("Could not compress backup file. Try backing up without compression.", array(), 'error');
  }
  return $file;
}