From b753fe0f921c682542fb3aafd388e67a5cc32727 Mon Sep 17 00:00:00 2001 From: mcrane Date: Sat, 14 Mar 2009 22:52:14 -0600 Subject: Add new package to backup and restore files and directories --- config/backup/backup.tmp | 309 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 309 insertions(+) create mode 100644 config/backup/backup.tmp (limited to 'config/backup/backup.tmp') diff --git a/config/backup/backup.tmp b/config/backup/backup.tmp new file mode 100644 index 00000000..6ce7a3ae --- /dev/null +++ b/config/backup/backup.tmp @@ -0,0 +1,309 @@ + 0) { + $backup_cmd = 'tar --create --verbose --gzip --file '.$tmp.$filename.' --directory / '; + foreach ($a_backup as $ent) { + if ($ent['enabled'] =="true"){ + //htmlspecialchars($ent['name']); + //htmlspecialchars($ent['path']); + //htmlspecialchars($ent['description']); + $backup_cmd .= htmlspecialchars($ent['path']).' '; + + } + $i++; + } + //echo $backup_cmd; //exit; + system($backup_cmd); + } + + session_cache_limiter('public'); + $fd = fopen($tmp.$filename, "rb"); + header("Content-Type: binary/octet-stream"); + header("Content-Length: " . filesize($tmp.$filename)); + header('Content-Disposition: attachment; filename="'.$filename.'"'); + fpassthru($fd); + exit; + } +} + +if ($_GET['a'] == "other") { + if ($_GET['t'] == "restore") { + $tmp = '/tmp/'; + $filename = 'pfsense.bak.tgz'; + + //extract the tgz file + if (file_exists('/tmp/'.$filename)) { + //echo "The file $filename exists"; + system('cd /; tar xvpfz /tmp/'.$filename.' '); + header( 'Location: backup.php?savemsg=Backup+has+been+restored.' ) ; + } + else { + header( 'Location: backup.php?savemsg=Restore+failed.+Backup+file+not+found.' ) ; + } + + exit; + } +} + +if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) { + $filename = 'pfsense.bak.tgz'; + move_uploaded_file($_FILES['ulfile']['tmp_name'], "/tmp/" . $filename); + $savemsg = "Uploaded file to /tmp/" . htmlentities($_FILES['ulfile']['name']); + system('cd /; tar xvpfz /tmp/'.$filename.' '); +} + + +include("head.inc"); + +?> + + + + +

Backup: Files & Directories

+ + + +
+ + +
+ +
+ + + + \n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
+ + + + + +
+

+ Use this to tool to backup files and directories. The following directories + are recommended for backup. + + + + +
pfSense Config/conf
RRD Graph Data Files/var/db/rrd
+

+
+ +
+
+ +
+ +
+ + + + + + + + + +
Upload and Restore
Use this to upload and restore your backup file.File to upload: + + + +
+
+
+
+ + + +\n"; + echo "
\n"; + echo "Backup / Restore
\n"; + echo "The 'backup' button will tar gzip the directories that are listed below to /tmp/pfsense.bak.tgz it then presents a file to download. \n"; + echo "If the backup file does not exist in /tmp/pfsense.bak.tgz then the 'restore' button will be hidden. \n"; + echo "

\n"; + echo "
\n"; + echo " \n"; + if (file_exists('/tmp/pfsense.bak.tgz')) { + echo " \n"; + } + echo "
\n"; + echo "

\n\n"; + + +echo "
\n"; + + +if ($config_change == 1) { + write_config(); + $config_change = 0; +} + +//if ($savemsg) print_info_box($savemsg); +//if (file_exists($d_hostsdirty_path)): echo"

"; +//print_info_box_np("This is an info box."); +//echo"
"; +//endif; + +?> + + + + + + + + + + + 0) { + + foreach ($a_backup as $ent) { + + ?> + + + + + + + + + + + + + + + + + + +
NameEnabledDescription + + + + + + +
+ +
+   + +   + +   + + + + + + +
+
+ + + + + +
+
+ +

+ + +
+
+
+
+
+
+
+
+ + + + + +
+ + + + + -- cgit v1.2.3 From e71f29843a079db4b5ca9f6636342c69ab1a22c8 Mon Sep 17 00:00:00 2001 From: mcrane Date: Tue, 17 Mar 2009 13:42:09 -0600 Subject: Backup package example pfsense conf path changed to /cf/conf --- config/backup/backup.tmp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/backup/backup.tmp') diff --git a/config/backup/backup.tmp b/config/backup/backup.tmp index 6ce7a3ae..86d645d0 100644 --- a/config/backup/backup.tmp +++ b/config/backup/backup.tmp @@ -144,7 +144,7 @@ if ($_GET["savemsg"]) { are recommended for backup. - +
pfSense Config/conf
pfSense Config/cf/conf
RRD Graph Data Files/var/db/rrd

-- cgit v1.2.3