diff --git a/backup/backuplib.php b/backup/backuplib.php index d2bd32b071310..33968ff926019 100644 --- a/backup/backuplib.php +++ b/backup/backuplib.php @@ -1110,30 +1110,40 @@ function copy_zip_to_course_dir ($preferences) { 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 30539d4f82b55..1441efef93b1e 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -16,7 +16,7 @@ function backup_set_config($name, $value) { //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; }