]> git.mjollnir.org Git - moodle.git/commitdiff
backup: MDL-17145 And actually copy the backup file there!
authortjhunt <tjhunt>
Thu, 6 Nov 2008 07:17:34 +0000 (07:17 +0000)
committertjhunt <tjhunt>
Thu, 6 Nov 2008 07:17:34 +0000 (07:17 +0000)
backup/backuplib.php

index 54b9dddb2a9d44b9c9a7cde54292c75bd6416318..18cded66b69a3fb49d59006f26a153b56ed4a96d 100644 (file)
         //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;
+
+            //Copy zip file
+            if ($status) {
+                $status = backup_copy_file ($from_zip_file,$to_zip_file);
+            }
         } 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);
-
-            //Define zip destination (zip file)
-            $to_zip_file = $to_zip_file."/".$preferences->backup_name;
+            $context = get_context_instance(CONTEXT_COURSE, $preferences->backup_course);
+            $fs = get_file_storage();
+            $file_record = array('contextid'=>$context->id, 'filearea'=>'course_backup',
+                    'itemid'=>0, 'filepath'=>'/', 'filename'=>$preferences->backup_name,
+                    'timecreated'=>time(), 'timemodified'=>time());
+            $fs->create_file_from_pathname($file_record, $from_zip_file);
         }
-
-        //echo "<p>To: ".$to_zip_file."<br />";                                              //Debug
-
-        //Copy zip file
-        if ($status) {
-            $status = backup_copy_file ($from_zip_file,$to_zip_file);
-        }
-
         return $status;
     }