_("Your account"))); dual_begin(array()); print("
" . _("You have not authenticated yourself to the system yet with your") . " " . _("username") . " " . _("and") . " " . _("password") . ". " . _("You will not be able to use this section of the website without authenticating yourself first. So, please continue and login using the form on the right hand side.") . "
\n"); dual_middle(array()); show_account_details(array()); dual_end(array()); generic_footer(array()); flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); exit; } $volumes_id = array(); $volumes_name = array(); $volumes_mountpoint = array(); $volumes_vg = array(); $volumes_fstype = array(); function volumes_startelement($parser, $name, $attrs) { global $volumes_id, $volumes_name, $volumes_mountpoint, $volumes_vg, $volumes_fstype; if ($name == "VOLUME") { array_push($volumes_id, $attrs["ID"]); array_push($volumes_name, $attrs["NAME"]); array_push($volumes_mountpoint, $attrs["MOUNTPOINT"]); array_push($volumes_vg, $attrs["VG"]); array_push($volumes_fstype, $attrs["FSTYPE"]); } } function volumes_endelement($parser, $name) { } $volumes_parser = xml_parser_create(); xml_set_element_handler($volumes_parser, "volumes_startelement", "volumes_endelement"); $volumes_fp = fopen("/opt/openfiler/etc/volumes.xml", "r"); while ($volumes_data = fread($volumes_fp, 4096)) xml_parse($volumes_parser, $volumes_data, feof($volumes_fp)); fclose($volumes_fp); xml_parser_free($volumes_parser); $snapshots_id = array(); $snapshots_lvname = array(); $snapshots_vgname = array(); $snapshots_shared = array(); $snapshots_rotateid = array(); function snapshots_startelement($parser, $name, $attrs) { global $snapshots_id, $snapshots_lvname, $snapshots_vgname, $snapshots_shared, $snapshots_rotateid; if ($name == "SNAPSHOT") { array_push($snapshots_id, $attrs["ID"]); array_push($snapshots_lvname, $attrs["LVNAME"]); array_push($snapshots_vgname, $attrs["VGNAME"]); array_push($snapshots_shared, $attrs["SHARED"]); array_push($snapshots_rotateid, $attrs["ROTATEID"]); } } function snapshots_endelement($parser, $name) { } $snapshots_parser = xml_parser_create(); xml_set_element_handler($snapshots_parser, "snapshots_startelement", "snapshots_endelement"); $snapshots_fp = fopen("/opt/openfiler/etc/snapshots.xml", "r"); while ($snapshots_data = fread($snapshots_fp, 4096)) xml_parse($snapshots_parser, $snapshots_data, feof($snapshots_fp)); fclose($snapshots_fp); xml_parser_free($snapshots_parser); $fstabp = popen("/usr/bin/sudo /bin/cat /etc/fstab", "r"); $i = 0; while (!feof($fstabp)) { $j = 0; $fstabstr = trim(fgets($fstabp, 4096)); if (strlen($fstabstr) <= 0) continue; if (substr($fstabstr, 0, 1) == "#") continue; $foo = explode(" ", $fstabstr); foreach ($foo as $fresultitem) { $fresultitem = trim($fresultitem); if (strlen($fresultitem) > 0) { $fstab[$i][$j] = $fresultitem; $j++; } } $i++; } $fstabcount = $i; pclose($fstabp); $vgname = "openfiler"; if ($HTTP_POST_VARS["snapaction"] == "takesnapshot") { if ((!is_valid_foldername($snapname)) || (substr(strtolower($snapname), 0, 5) == "sched") || (!is_numeric($snapsize))) { flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume)); exit; } $snapname = strtolower($snapname); $mountpath = "/mnt/snapshots/" . $vgname . "/" . $volume . "/" . $snapname; if ((!is_dir($mountpath)) && (!is_file($mountpath))) { $fstype = ""; for ($fsj = 0; $fsj < count($volumes_id); $fsj++) { if (($vgname == $volumes_vg[$fsj]) && ($volume == $volumes_id[$fsj])) { $fstype = $volumes_fstype[$fsj]; break; } } $fs = 0; $fsfound = false; for ($fsi = 0; $fsi < count($fs_info); $fsi++) { if ($fs_info[$fsi]["type"] == $fstype) { $fs = $fsi; $fsfound = true; break; } } if ($fsfound == false) $fs = 0; if ($fstype == "xfs") exec("/usr/bin/sudo /usr/sbin/xfs_freeze -f /dev/" . escapeshellarg($vgname) . "/" . escapeshellarg($volume)); exec("/usr/bin/sudo /sbin/lvm lvcreate -s -L " . escapeshellarg($snapsize) . " -n of.snapshot." . escapeshellarg($volume) . "." . escapeshellarg($snapname) . " /dev/openfiler/" . escapeshellarg($volume)); if ($fstype == "xfs") exec("/usr/bin/sudo /usr/sbin/xfs_freeze -u /dev/" . escapeshellarg($vgname) . "/" . escapeshellarg($volume)); $lvp = popen("/usr/bin/sudo /sbin/lvm lvdisplay -c /dev/" . $vgname . "/of.snapshot." . escapeshellarg($volume) . "." . escapeshellarg($snapname), "r"); $i = 0; while (!feof($lvp)) $lvds[$i++] = fgets($lvp, 4096); pclose($lvp); $lvinfo = explode(":", trim($lvds[0], " ")); if ($lvinfo[0] == ("/dev/" . $vgname . "/of.snapshot." . $volume . "." . $snapname)) { array_push($snapshots_id, $snapname); array_push($snapshots_lvname, $volume); array_push($snapshots_vgname, $vgname); array_push($snapshots_shared, $snapshare); array_push($snapshots_rotateid, 0); $snapshotsp = popen("/usr/bin/sudo /usr/bin/tee /opt/openfiler/etc/snapshots.xml", "w"); fputs($snapshotsp, "\n"); fputs($snapshotsp, "Welcome Administrator. The following are various system information and preferences, arranged into tabs. Please click on a tab to open up that category.
List of existing snapshots for volume \"" . $volume . "\"\n"); $snapshots_found = false; for ($i = 0; $i < count($snapshots_lvname); $i++) if (($snapshots_lvname[$i] == $volume) && ($snapshots_vgname[$i] == "openfiler")) { $snapshots_found = true; break; } if ($snapshots_found) { print("\n"); } else { print("No snapshots were found.
\n"); } ?>
Snapshots work using the copy-on-write method.
Use the following form to take a snapshot of the supplied size
for the volume. Once the amount of updates to the volume since the snapshot was
taken crosses the size of the snapshot, the volume will become read-only until
more space is allocated to the snapshot. So please allocate enough space to it.
The snapshot name must be specified like a UNIX filename without its path.
">Snapshot name | " align="center">Size in MB | " align="center">Share contents? | " align="center">Apply |
" align="center"> | " align="center"> | " align="center"> | " align="center"> |