Skip to content

Commit

Permalink
Added support in copy_zip_to_course_dir() to save course
Browse files Browse the repository at this point in the history
backup file in a custom directory (via $preferences->backup_destination).
Needed in scheduled backups.
  • Loading branch information
stronk7 committed Dec 1, 2003
1 parent 81434da commit 37afa39
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
46 changes: 28 additions & 18 deletions backup/backuplib.php
Expand Up @@ -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 "<p>From: ".$from_zip_file."<br>"; //Debug

//echo "<p>Checking: ".$to_zip_file."<br>"; //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 "<p>Checking: ".$to_zip_file."<br>"; //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 "<p>From: ".$from_zip_file."<br>"; //Debug

//echo "<p>Checking: ".$to_zip_file."<br>"; //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 "<p>Checking: ".$to_zip_file."<br>"; //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 "<p>To: ".$to_zip_file."<br>"; //Debug

//Copy zip file
Expand Down
2 changes: 1 addition & 1 deletion backup/lib.php
Expand Up @@ -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;
}
Expand Down

0 comments on commit 37afa39

Please sign in to comment.