From c803fa68550499aeb2ecd912ff150036c451d4c3 Mon Sep 17 00:00:00 2001 From: Eric Merrill Date: Mon, 2 Mar 2015 13:55:18 -0500 Subject: [PATCH] MDL-49298 backup: Make tgz file format standard for backups --- admin/settings/development.php | 9 --------- config-dist.php | 5 +++++ lang/en/admin.php | 2 -- lib/db/upgrade.php | 7 +++++++ lib/filestorage/mbz_packer.php | 7 ++++--- lib/filestorage/tests/mbz_packer_test.php | 8 +++----- version.php | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/admin/settings/development.php b/admin/settings/development.php index c645deabfbdcb..41427f0690a68 100644 --- a/admin/settings/development.php +++ b/admin/settings/development.php @@ -18,15 +18,6 @@ $enablecssoptimiser->set_updatedcallback('theme_reset_all_caches'); $temp->add($enablecssoptimiser); - // Backup archive .mbz format: switching to .tar.gz enables larger files, better - // progress reporting and possibly better performance. This is an experimental - // setting but if successful, should be removed and enabled by default in a future - // version. Note: this setting controls newly-created backups only; restore always - // supports both formats. - $temp->add(new admin_setting_configcheckbox('enabletgzbackups', - new lang_string('enabletgzbackups', 'admin'), - new lang_string('enabletgzbackups_desc', 'admin'), 0)); - $ADMIN->add('experimental', $temp); // "debugging" settingpage diff --git a/config-dist.php b/config-dist.php index fc59406353977..58d386af4ae60 100644 --- a/config-dist.php +++ b/config-dist.php @@ -173,6 +173,11 @@ // and then restore on the target server. // $CFG->forcedifferentsitecheckingusersonrestore = true; // +// Force the backup system to continue to create backups in the legacy zip +// format instead of the new tgz format. Does not affect restore, which +// auto-detects the underlying file format. +// $CFG->usezipbackups = true; +// // Prevent stats processing and hide the GUI // $CFG->disablestatsprocessing = true; // diff --git a/lang/en/admin.php b/lang/en/admin.php index 69dbb497bc9e4..8f0f8f31df4e0 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -481,8 +481,6 @@ $string['enablerssfeeds'] = 'Enable RSS feeds'; $string['enablesafebrowserintegration'] = 'Enable Safe Exam Browser integration'; $string['enablestats'] = 'Enable statistics'; -$string['enabletgzbackups'] = 'Enable new backup format'; -$string['enabletgzbackups_desc'] = 'If enabled, future backups will be created in a new compression format for .mbz files (internally stored as a .tar.gz file). This removes the 4GB backup size restriction and may improve performance. Restore supports both formats and the difference should be transparent to users.'; $string['enabletrusttext'] = 'Enable trusted content'; $string['enablewebservices'] = 'Enable web services'; $string['enablewsdocumentation'] = 'Web services documentation'; diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 7b9944a582369..f4699d8582850 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -4216,5 +4216,12 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2015030400.00); } + if ($oldversion < 2015030500.01) { + // Unset old config variable. + unset_config('enabletgzbackups'); + + upgrade_main_savepoint(true, 2015030500.01); + } + return true; } diff --git a/lib/filestorage/mbz_packer.php b/lib/filestorage/mbz_packer.php index d9dfed97f1972..749c622b12a33 100644 --- a/lib/filestorage/mbz_packer.php +++ b/lib/filestorage/mbz_packer.php @@ -146,10 +146,11 @@ protected function get_packer_for_archive_operation() { global $CFG; require_once($CFG->dirroot . '/lib/filestorage/tgz_packer.php'); - if ($CFG->enabletgzbackups) { - return get_file_packer('application/x-gzip'); - } else { + if (!empty($CFG->usezipbackups)) { + // Allow forced use of zip backups. return get_file_packer('application/zip'); + } else { + return get_file_packer('application/x-gzip'); } } diff --git a/lib/filestorage/tests/mbz_packer_test.php b/lib/filestorage/tests/mbz_packer_test.php index 682ec47bd7a06..5882218379a50 100644 --- a/lib/filestorage/tests/mbz_packer_test.php +++ b/lib/filestorage/tests/mbz_packer_test.php @@ -40,8 +40,8 @@ public function test_archive_with_both_options() { // Set up basic archive contents. $files = array('1.txt' => array('frog')); - // Create 2 archives (each with one file in) in default mode. - $CFG->enabletgzbackups = false; + // Create 2 archives (each with one file in) in zip mode. + $CFG->usezipbackups = true; $filefalse = $CFG->tempdir . '/false.mbz'; $this->assertNotEmpty($packer->archive_to_pathname($files, $filefalse)); $context = context_system::instance(); @@ -49,7 +49,7 @@ public function test_archive_with_both_options() { $files, $context->id, 'phpunit', 'data', 0, '/', 'false.mbz')); // Create 2 archives in tgz mode. - $CFG->enabletgzbackups = true; + $CFG->usezipbackups = false; $filetrue = $CFG->tempdir . '/true.mbz'; $this->assertNotEmpty($packer->archive_to_pathname($files, $filetrue)); $context = context_system::instance(); @@ -61,8 +61,6 @@ public function test_archive_with_both_options() { $this->assertNotEquals($storagefalse->get_filesize(), $storagetrue->get_filesize()); // Extract files into storage and into filesystem from both formats. - // (Note: the setting does not matter, but set to false just to check.) - $CFG->enabletgzbackups = false; // Extract to path (zip). $packer->extract_to_pathname($filefalse, $CFG->tempdir); diff --git a/version.php b/version.php index fee9e93764e36..ce3d06a7b165b 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2015030500.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2015030500.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes.