You are here

function _backup_migrate_gzip_encode in Backup and Migrate 5

Same name and namespace in other branches
  1. 5.2 includes/files.inc \_backup_migrate_gzip_encode()
  2. 6 backup_migrate.module \_backup_migrate_gzip_encode()

Gzip encode a file.

2 calls to _backup_migrate_gzip_encode()
BackupMigrateUnitTest::testGZipEncode in tests/BackupMigrateUnitTest.test
_backup_migrate_dump_tables in ./backup_migrate.module
Build the database dump file. Takes a list of tables to exclude and some formatting options.

File

./backup_migrate.module, line 1141
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_gzip_encode($source, $dest, $level = 9) {
  $success = FALSE;
  if (@function_exists("gzopen")) {
    if (($fp_out = gzopen($dest, 'wb' . $level)) && ($fp_in = fopen($source, 'rb'))) {
      while (!feof($fp_in)) {
        gzwrite($fp_out, fread($fp_in, 1024 * 512));
      }
      $success = TRUE;
    }
    @fclose($fp_in);
    @gzclose($fp_out);
  }
  return $success;
}