- Backup FrontEnd............................................IN PROGRESS
- Check Security........................................DONE
- Select Info to Backup.(from mods).....................DONE
- - Check (summary info)..................................IN PROGRESS
+ - Check (summary info)..................................DONE
- Check mods.......................................DONE
- - Check logs.......................................IN PROGRESS
+ - Check logs.......................................DONE
- Check users......................................DONE
+ - Check User Files.................................DONE
+ - Check Course Files...............................DONE
- Launch Backup.........................................NO EXISTS
- Show progress.........................................NO EXISTS
- Determine Backup location.............................NO EXISTS
$db->debug=false;
if (set_config("backup_version", $a->newversion)) {
notify($strdatabasesuccess, "green");
+ notify("You are running Backup/Recovery version ".$backup_release,"black");
print_continue("backup.php");
die;
} else {
// database (backup_version) to determine whether upgrades should
// be performed (see db/backup_*.php)
-$backup_version = 2003050301; // The current version is a date (YYYYMMDDXX)
+$backup_version = 2003050401; // The current version is a date (YYYYMMDDXX)
$backup_release = "0.1.0 beta"; // User-friendly version number
echo get_string("backupdetails").":";
echo "</td></tr>";
+ //This is tha align to every ingo table
+ $table->align = array ("LEFT","RIGHT");
+
if ($allmods = get_records("modules") ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
if ($backup_logs) {
echo "<tr>";
echo "<td colspan=\"2\"><P><B>";
- echo "<li>".get_string("includelogentries");;
+ echo "<li>".get_string("includelogentries")."<P>";
+ //Print info
+ $table->data = log_check_backup($id);
+ print_table($table);
echo "</td></tr>";
}
//Add as hidden name
if ($backup_user_files) {
echo "<tr>";
echo "<td colspan=\"2\"><P><B>";
- echo "<li>".get_string("includeuserfiles");;
+ echo "<li>".get_string("includeuserfiles")."<P>";
+ //Print info
+ $table->data = user_files_check_backup($id,$backup_unique_code);
+ print_table($table);
echo "</td></tr>";
}
//Add as hidden name
if ($backup_course_files) {
echo "<tr>";
echo "<td colspan=\"2\"><P><B>";
- echo "<li>".get_string("includecoursefiles");;
+ echo "<li>".get_string("includecoursefiles")."<P>";
+ //Print info
+ $table->data = course_files_check_backup($id,$backup_unique_code);
+ print_table($table);
echo "</td></tr>";
}
//Add as hidden name
if ($oldversion < 2003050301 and $result) {
$result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
ADD `info` VARCHAR(30)");
+ }
+
+ if ($oldversion < 2003050400 and $result) {
+ $result = execute_sql("ALTER TABLE `{$CFG->prefix}backup_ids`
+ MODIFY `info` VARCHAR(255)");
}
+ if ($oldversion < 2003050401 and $result) {
+ $result = execute_sql("CREATE TABLE `{$CFG->prefix}backup_files` (
+ `backup_code` INT( 10 ) UNSIGNED NOT NULL ,
+ `file_type` VARCHAR( 10 ) NOT NULL ,
+ `path` VARCHAR( 255 ) NOT NULL ,
+ `old_id` INT( 10 ) UNSIGNED,
+ `new_id` INT( 10 ) UNSIGNED,
+ PRIMARY KEY ( `backup_code` , `file_type` , `path` )
+ ) COMMENT = 'To store and recode ids to user & course files.'");
+ }
//Finally, return result
return $result;
return $info;
}
+ //Calculate the number of log entries to backup
+ //Return an array of info (name,value)
+ function log_check_backup($course) {
+
+ global $CFG;
+
+ //Execute the insert
+ $status = execute_sql($sql_insert,false);
+
+ //Now execute the select
+ $ids = get_records_sql("SELECT DISTINCT l.id,l.course
+ FROM {$CFG->prefix}log l
+ WHERE l.course = '$course'");
+ //Gets the user data
+ $info[0][0] = get_string("logs");
+ if ($ids) {
+ $info[0][1] = count($ids);
+ } else {
+ $info[0][1] = 0;
+ }
+
+ return $info;
+ }
+
+ //Calculate the number of user files to backup
+ //Under $CFG->dataroot/users
+ //and put them (their path) in backup_ids
+ //Return an array of info (name,value)
+ function user_files_check_backup($course,$backup_unique_code) {
+
+ global $CFG;
+
+ $rootdir = $CFG->dataroot."/users";
+ $coursedirs = get_directory_list($rootdir);
+ foreach ($coursedirs as $dir) {
+ //Extracts user id from file path
+ $tok = strtok($dir,"/");
+ if ($tok) {
+ $userid = $tok;
+ } else {
+ $tok = "";
+ }
+ //Insert them into backup_files
+ $status = execute_sql("INSERT INTO {$CFG->prefix}backup_files
+ (backup_code, file_type, path, old_id)
+ VALUES
+ ('$backup_unique_code','user','$dir','$userid')",false);
+ }
+
+ //Now execute the select
+ $ids = get_records_sql("SELECT DISTINCT b.path, b.old_id
+ FROM {$CFG->prefix}backup_files b
+ WHERE backup_code = '$backup_unique_code' AND
+ file_type = 'user'");
+ //Gets the user data
+ $info[0][0] = get_string("files");
+ if ($ids) {
+ $info[0][1] = count($ids);
+ } else {
+ $info[0][1] = 0;
+ }
+
+ return $info;
+ }
+
+ //Calculate the number of course files to backup
+ //under $CFG->dataroot/$course, except $CFG->moddata
+ //and put them (their path) in backup_ids
+ //Return an array of info (name,value)
+ function course_files_check_backup($course,$backup_unique_code) {
+
+ global $CFG;
+
+ $rootdir = $CFG->dataroot."/$course";
+ $coursedirs = get_directory_list($rootdir,$CFG->moddata);
+ foreach ($coursedirs as $dir) {
+ //Insert them into backup_files
+ $status = execute_sql("INSERT INTO {$CFG->prefix}backup_files
+ (backup_code, file_type, path)
+ VALUES
+ ('$backup_unique_code','course','$dir')",false);
+ }
+
+ //Now execute the select
+ $ids = get_records_sql("SELECT DISTINCT b.path, b.old_id
+ FROM {$CFG->prefix}backup_files b
+ WHERE backup_code = '$backup_unique_code' AND
+ file_type = 'course'");
+ //Gets the user data
+ $info[0][0] = get_string("files");
+ if ($ids) {
+ $info[0][1] = count($ids);
+ } else {
+ $info[0][1] = 0;
+ }
+
+ return $info;
+ }
+
+
?>