From 37afa39a5e43db37498a4789a67bcaec0dc55ef1 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 1 Dec 2003 20:25:50 +0000 Subject: [PATCH] Added support in copy_zip_to_course_dir() to save course backup file in a custom directory (via $preferences->backup_destination). Needed in scheduled backups. --- backup/backuplib.php | 46 +++++++++++++++++++++++++++----------------- backup/lib.php | 2 +- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/backup/backuplib.php b/backup/backuplib.php index d2bd32b071..33968ff926 100644 --- a/backup/backuplib.php +++ b/backup/backuplib.php @@ -1110,30 +1110,40 @@ global $CFG; + $status = true; + //Define zip location (from) $from_zip_file = $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/".$preferences->backup_name; - //Define zip destination (course dir) - $to_zip_file = $CFG->dataroot."/".$preferences->backup_course; - - //echo "

From: ".$from_zip_file."
"; //Debug - - //echo "

Checking: ".$to_zip_file."
"; //Debug + //Initialise $to_zip_file + $to_zip_file=""; - //Checks course dir exists - $status = check_dir_exists($to_zip_file,true); - - //Define zip destination (backup dir) - $to_zip_file = $to_zip_file."/backupdata"; - - //echo "

Checking: ".$to_zip_file."
"; //Debug + //If $preferences->backup_destination isn't empty, then copy to custom directory + if (!empty($preferences->backup_destination)) { + $to_zip_file = $preferences->backup_destination."/".$preferences->backup_name; + } else { + //Define zip destination (course dir) + $to_zip_file = $CFG->dataroot."/".$preferences->backup_course; + + //echo "

From: ".$from_zip_file."
"; //Debug + + //echo "

Checking: ".$to_zip_file."
"; //Debug + + //Checks course dir exists + $status = check_dir_exists($to_zip_file,true); + + //Define zip destination (backup dir) + $to_zip_file = $to_zip_file."/backupdata"; + + //echo "

Checking: ".$to_zip_file."
"; //Debug + + //Checks backup dir exists + $status = check_dir_exists($to_zip_file,true); - //Checks backup dir exists - $status = check_dir_exists($to_zip_file,true); + //Define zip destination (zip file) + $to_zip_file = $to_zip_file."/".$preferences->backup_name; + } - //Define zip destination (zip file) - $to_zip_file = $to_zip_file."/".$preferences->backup_name; - //echo "

To: ".$to_zip_file."
"; //Debug //Copy zip file diff --git a/backup/lib.php b/backup/lib.php index 30539d4f82..1441efef93 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -16,7 +16,7 @@ //Gets all the information from backup_config table function backup_get_config() { $backup_config = null; - if ($configs = get_records('backup_config')) { + if ($configs = get_records("backup_config")) { foreach ($configs as $config) { $backup_config[$config->name] = $config->value; } -- 2.39.5