From 31806ea4ef87516dd4978c62359323da64f60189 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 8 Aug 2015 16:33:08 +0200 Subject: backup package - cleanup round two backup.xml - Removed self-referencing additional_files_needed - Fix copyright header - Remove pointless/unused tags - Remove WTF copy/paste code coming from god knows where - Removed no-op duplicated and fix the url in the other one - Fix files permissions --- config/backup/backup.xml | 55 ++++++++++++------------------------------------ 1 file changed, 14 insertions(+), 41 deletions(-) diff --git a/config/backup/backup.xml b/config/backup/backup.xml index f9cf36b9..18fbb0ed 100644 --- a/config/backup/backup.xml +++ b/config/backup/backup.xml @@ -1,21 +1,24 @@ - - + + - +/* ====================================================================================== */ + ]]> Backup - Describe your package requirements here - Currently there are no FAQ items provided. Backup Settings - 0.1.8 + 0.1.9 Settings /usr/local/pkg/backup.inc @@ -53,53 +55,24 @@ - Settings - /pkg_edit.php?xml=backup.xml&id=0 - - - - Settings - /packages/backup.php + Backup + /packages/backup/backup.php installedpackages->package->$packagename->configuration->backup /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/backup/backup.xml - - - /usr/local/pkg/ - 0755 https://packages.pfsense.org/packages/config/backup/backup.inc /usr/local/www/packages/backup/ - 0755 https://packages.pfsense.org/packages/config/backup/backup.php /usr/local/www/packages/backup/ - 0755 https://packages.pfsense.org/packages/config/backup/backup_edit.php - - - Example Variable One - var1 - Enter the variable one here. - input - - - Example Variable Two - var1 - Enter the variable one here. - input - - - - backup_sync_package(); -- cgit v1.2.3 From 44099a6a6bb014811c0f2e30d243c036c1c8cdfb Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 8 Aug 2015 16:40:06 +0200 Subject: backup package - cleanup round two - Fix copyright header - Removed unused byte_convert() function - Rename Get backup_sync_package_php() to backup_sync_package() and get rid of the original backup_sync_package() which only called the other one. --- config/backup/backup.inc | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/config/backup/backup.inc b/config/backup/backup.inc index e395756a..1a5eeab1 100644 --- a/config/backup/backup.inc +++ b/config/backup/backup.inc @@ -1,14 +1,11 @@ 10^x|1024->2^x] - $s = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); - $e = floor(log($bytes, $convention)); - return round($bytes/pow($convention, $e), 2) . ' ' . $s[$e]; - } -} - -function backup_sync_package_php() { - +function backup_sync_package() { global $config; if ($config['installedpackages']['backup']['config'] != "") { conf_mount_rw(); @@ -65,26 +46,12 @@ function backup_sync_package_php() { } } -function backup_sync_package() { - global $config; - backup_sync_package_php(); -} - - function backup_install_command() { - - global $config; conf_mount_rw(); - - //create the backup directory - if (!is_dir('/root/backup/')) { - @mkdir("/root/backup/"); - } - + // Create the backup directory + safe_mkdir("/root/backup/"); backup_sync_package(); - conf_mount_ro(); - } ?> -- cgit v1.2.3 From fc07dc3a9de4b65e66e050063f2780d13b077cb4 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 8 Aug 2015 23:13:13 +0200 Subject: backup package - cleanup round two - Clean up obvious leftover crap - XHTML valid code - Add the configured backup path to the displayed table --- config/backup/backup.php | 170 +++++++++++++++++++++-------------------------- 1 file changed, 75 insertions(+), 95 deletions(-) diff --git a/config/backup/backup.php b/config/backup/backup.php index d4debcd3..8f4dbf9c 100644 --- a/config/backup/backup.php +++ b/config/backup/backup.php @@ -1,8 +1,9 @@ 0) { - $backup_cmd = 'tar --create --verbose --gzip --file '.$tmp.$filename.' --directory / '; + /* Do NOT remove the trailing space after / from $backup_cmd below!!! */ + $backup_cmd = "/usr/bin/tar --create --verbose --gzip --file {$backup_path} --directory / "; foreach ($a_backup as $ent) { if ($ent['enabled'] == "true") { - //htmlspecialchars($ent['name']); - //htmlspecialchars($ent['path']); - //htmlspecialchars($ent['description']); - $backup_cmd .= htmlspecialchars($ent['path']).' '; + $backup_cmd .= htmlspecialchars($ent['path']) . ' '; } $i++; } - //echo $backup_cmd; //exit; system($backup_cmd); } session_cache_limiter('public'); - $fd = fopen($tmp.$filename, "rb"); + $fd = fopen("{$backup_path}", "rb"); + header("Content-Type: application/force-download"); header("Content-Type: binary/octet-stream"); - header("Content-Length: " . filesize($tmp.$filename)); - header('Content-Disposition: attachment; filename="' . $filename . '"'); + header("Content-Type: application/download"); + header("Content-Description: File Transfer"); + header('Content-Disposition: attachment; filename="' . $backup_filename . '"'); + header("Cache-Control: no-cache, must-revalidate"); + header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); + header("Content-Length: " . filesize($backup_path)); fpassthru($fd); conf_mount_ro(); @@ -83,17 +85,13 @@ if ($_GET['a'] == "download") { if ($_GET['a'] == "other") { if ($_GET['t'] == "restore") { - conf_mount_rw(); - $tmp = '/root/backup/'; - $filename = 'pfsense.bak.tgz'; - - //extract the tgz file - if (file_exists('/root/backup/'.$filename)) { - //echo "The file $filename exists"; - system('cd /; tar xvpfz /root/backup/'.$filename.' '); - header( 'Location: backup.php?savemsg=Backup+has+been+restored.' ) ; + // Extract the tgz file + if (file_exists($backup_path)) { + conf_mount_rw(); + system("/usr/bin/tar -xpzC / -f {$backup_path}"); + header("Location: backup.php?savemsg=Backup+has+been+restored."); } else { - header( 'Location: backup.php?savemsg=Restore+failed.+Backup+file+not+found.' ) ; + header("Location: backup.php?savemsg=Restore+failed.+Backup+file+not+found."); } conf_mount_ro(); exit; @@ -102,21 +100,20 @@ if ($_GET['a'] == "other") { if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) { conf_mount_rw(); - $filename = 'pfsense.bak.tgz'; - move_uploaded_file($_FILES['ulfile']['tmp_name'], "/root/backup/" . $filename); - $savemsg = "Uploaded file to /root/backup/" . htmlentities($_FILES['ulfile']['name']); - system('cd /; tar xvpfz /root/backup/'.$filename.' '); + move_uploaded_file($_FILES['ulfile']['tmp_name'], "{$backup_path}"); + $savemsg = "Uploaded file to {$backup_dir}" . htmlentities($_FILES['ulfile']['name']); + system("/usr/bin/tar -xpzC / -f {$backup_path}"); conf_mount_ro(); } +$pgtitle = "Backup: Files & Directories"; include("head.inc"); ?> - -

Backup: Files & Directories

+ - -

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

@@ -161,73 +154,65 @@ if ($_GET["savemsg"]) {
- -
- + +
Upload and Restore
Use this to upload and restore your backup file. File to upload: - + - +


-
+ + + + + + +
+ Backup / Restore
+ The 'Backup' button compresses the directories that are listed below to /root/backup/pfsense.bak.tgz; after that it presents the file for download.
+ If the backup file does not exist in /root/backup/pfsense.bak.tgz then the 'Restore' button will be hidden.


+
+ + \n"; + } + ?> +
+

-\n"; - echo "\n"; - echo "\n"; - echo "Backup / Restore
\n"; - echo "The 'backup' button will tar gzip the directories that are listed below to /root/backup/pfsense.bak.tgz it then presents a file to download. \n"; - echo "If the backup file does not exist in /root/backup/pfsense.bak.tgz then the 'restore' button will be hidden. \n"; - echo "

\n"; - echo "\n"; - echo "\n"; - echo " \n"; - if (file_exists('/root/backup/pfsense.bak.tgz')) { - echo " \n"; - } - echo "\n"; - echo "\n"; - echo "\n"; - echo "

\n\n"; - - -echo "
\n"; + +"; -//print_info_box_np("This is an info box."); -//echo"
"; -//endif; - ?> - - + + + @@ -245,17 +230,20 @@ if ($config_change == 1) { + - @@ -267,12 +255,12 @@ if ($config_change == 1) { ?> - + @@ -283,17 +271,9 @@ if ($config_change == 1) {
NameEnabledNamePathEnabled Description - +
  +   +   -   +   + - - + +
- +
-
-
-
-
-
-
-
-
-
+
-- cgit v1.2.3 From 074a64e004046d6c2fa2379be5852dd291e6251c Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 8 Aug 2015 23:14:58 +0200 Subject: backup package - cleanup round two - Clean up obvious leftover crap - XHTML valid code --- config/backup/backup_edit.php | 81 +++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 50 deletions(-) diff --git a/config/backup/backup_edit.php b/config/backup/backup_edit.php index fbaa9096..63b1d52a 100755 --- a/config/backup/backup_edit.php +++ b/config/backup/backup_edit.php @@ -1,9 +1,9 @@ - - - -

Backup: Edit

- - -
@@ -124,16 +122,6 @@ function show_advanced_config() {
- -
@@ -142,67 +130,60 @@ function show_advanced_config() {
Name - +
Path - +
Enabled \n"; - echo " \n"; + echo "\n"; + echo "\t\t\t\t\t\t\t\n"; ?>
Description - -
Enter the description here.
+
+ Enter the description here.
  - +   - +
- -
-
-
-
-
-
-
-- cgit v1.2.3 From 82f66a92d43c78f7523ca959fcee96fb2c9e1d20 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 8 Aug 2015 23:17:27 +0200 Subject: Bump backup package version --- pkg_config.10.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 7c9ce26c..1fc4e4d2 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -363,7 +363,7 @@ Tool to Backup and Restore files and directories. System https://packages.pfsense.org/packages/config/backup/backup.xml - 0.1.8 + 0.1.9 Beta 2.2 markjcrane@gmail.com -- cgit v1.2.3