]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - config/backup/backup.pl
Fixes for 'backup.pl' (Bug #11816)
[people/pmueller/ipfire-2.x.git] / config / backup / backup.pl
index 4ad7363fbb6e4369da2f106b30d0be75c3ce5677..ce16e7f42fcc1d5fd4a3341b95414a8382f87014 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+# Copyright (C) 2007-2014  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -46,7 +46,7 @@ if (($ARGV[0] eq 'include') || ($ARGV[0] eq 'iso')) {
   print DATEI @include;
   print "/var/log/messages";
   close(DATEI);
-  system("tar -cvzf /var/ipfire/backup/$Jahr$Monat$Monatstag-$Stunden$Minuten.ipf --files-from='/tmp/include' --exclude-from='/var/ipfire/backup/exclude' --files-from='/var/ipfire/backup/include.user' --exclude-from='/var/ipfire/backup/exclude.user'");
+  system("tar -cvzf /var/ipfire/backup/$Jahr$Monat$Monatstag-$Stunden$Minuten.ipf --exclude-from='/var/ipfire/backup/exclude' --exclude-from='/var/ipfire/backup/exclude.user' --files-from='/tmp/include' --files-from='/var/ipfire/backup/include.user'");
   system("rm /tmp/include");
   if ($ARGV[0] eq 'iso') {
        system("/usr/local/bin/backupiso $Jahr$Monat$Monatstag-$Stunden$Minuten &");
@@ -57,7 +57,7 @@ elsif ($ARGV[0] eq 'exclude') {
   open(DATEI, ">/tmp/include") || die "Could not save temp include file";
   print DATEI @include;
   close(DATEI);
-  system("tar -cvzf /var/ipfire/backup/$Jahr$Monat$Monatstag-$Stunden$Minuten.ipf --files-from='/tmp/include' --exclude-from='/var/ipfire/backup/exclude' --files-from='/var/ipfire/backup/include.user' --exclude-from='/var/ipfire/backup/exclude.user'");
+  system("tar -cvzf /var/ipfire/backup/$Jahr$Monat$Monatstag-$Stunden$Minuten.ipf --exclude-from='/var/ipfire/backup/exclude' --exclude-from='/var/ipfire/backup/exclude.user' --files-from='/tmp/include' --files-from='/var/ipfire/backup/include.user'");
   system("rm /tmp/include");
 }
 elsif ($ARGV[0] eq 'restore') {
@@ -66,62 +66,68 @@ elsif ($ARGV[0] eq 'restore') {
   system("/usr/sbin/ovpn-ccd-convert");
   #OUTGOINGFW CONVERTER
   if( -d "${General::swroot}/outgoing"){
-         if( -f "${General::swroot}/forward/config" ){ 
-                 unlink("${General::swroot}/forward/config");
-                 system("touch ${General::swroot}/forward/config"); 
-                 chown 99,99,"${General::swroot}/forward/config";
+         if( -f "${General::swroot}/firewall/config" ){
+                 unlink("${General::swroot}/firewall/config");
+                 system("touch ${General::swroot}/firewall/config");
+                 chown 99,99,"${General::swroot}/firewall/config";
          }
-         if( -f "${General::swroot}/forward/outgoing" ){
-                 unlink("${General::swroot}/forward/outgoing");
-                 system("touch ${General::swroot}/forward/outgoing");
-                 chown 99,99,"${General::swroot}/forward/outgoing";
+         if( -f "${General::swroot}/firewall/outgoing" ){
+                 unlink("${General::swroot}/firewall/outgoing");
+                 system("touch ${General::swroot}/firewall/outgoing");
+                 chown 99,99,"${General::swroot}/firewall/outgoing";
          }
-         unlink("${General::swroot}/fwhosts/*");
+         unlink("${General::swroot}/fwhosts/customgroups");
+         unlink("${General::swroot}/fwhosts/customhosts");
+         unlink("${General::swroot}/fwhosts/customgroups");
+         unlink("${General::swroot}/fwhosts/customnetworks");
+         unlink("${General::swroot}/fwhosts/customservicegrp");
+         unlink("${General::swroot}/fwhosts/customnetworks");
          system("touch ${General::swroot}/fwhosts/customgroups");
          system("touch ${General::swroot}/fwhosts/customhosts");
          system("touch ${General::swroot}/fwhosts/customnetworks");
          system("touch ${General::swroot}/fwhosts/customservicegrp");
-         system("touch ${General::swroot}/fwhosts/customservices");
-         chown 99,99,"${General::swroot}/fwhosts/*";
          #START CONVERTER "OUTGOINGFW"
          system("/usr/sbin/convert-outgoingfw");
+         chown 99,99,"${General::swroot}/fwhosts/customgroups";
+         chown 99,99,"${General::swroot}/fwhosts/customhosts";
+         chown 99,99,"${General::swroot}/fwhosts/customnetworks";
+         chown 99,99,"${General::swroot}/fwhosts/customservicegrp";
+         #START CONVERTER "OUTGOINGFW"
          rmtree("${General::swroot}/outgoing");
   }
   #XTACCESS CONVERTER
   if( -d "${General::swroot}/xtaccess"){
-         if( -f "${General::swroot}/forward/input" ){
-                 unlink("${General::swroot}/forward/input");
-                 system("touch ${General::swroot}/forward/input");
-                 chown 99,99,"${General::swroot}/forward/input";
+         if( -f "${General::swroot}/firewall/input" ){
+                 unlink("${General::swroot}/firewall/input");
+                 system("touch ${General::swroot}/firewall/input");
          }
          #START CONVERTER "XTACCESS"
          system("/usr/sbin/convert-xtaccess");
+         chown 99,99,"${General::swroot}/firewall/input";
          rmtree("${General::swroot}/xtaccess");
   }
   #DMZ-HOLES CONVERTER
-  if( -d "${General::swroot}/dmz-holes"){
-         if( -f "${General::swroot}/forward/dmz" ){
-                 unlink("${General::swroot}/forward/dmz");
-                 system("touch ${General::swroot}/forward/dmz");
-                 chown 99,99,"${General::swroot}/forward/dmz";
+  if( -d "${General::swroot}/dmzholes" || -d "${General::swroot}/portfw"){
+         if( -f "${General::swroot}/firewall/config" ){
+                 unlink("${General::swroot}/firewall/config");
+                 system("touch ${General::swroot}/firewall/config");
          }
          #START CONVERTER "DMZ-HOLES"
          system("/usr/sbin/convert-dmz");
-         rmtree("${General::swroot}/xtaccess");
+         chown 99,99,"${General::swroot}/firewall/config";
+         rmtree("${General::swroot}/dmzholes");
   }
   #PORTFORWARD CONVERTER
   if( -d "${General::swroot}/portfw"){
-         if( -f "${General::swroot}/forward/nat" ){
-                 unlink("${General::swroot}/forward/nat");
-                 system("touch ${General::swroot}/forward/nat");
-                 chown 99,99,"${General::swroot}/forward/nat";
-         }
-         #START CONVERTER "PORTFW"
-         system("/usr/sbin/convert-portfw");
-         rmtree("${General::swroot}/portfw");
+       #START CONVERTER "PORTFW"
+       system("/usr/sbin/convert-portfw");
+       rmtree("${General::swroot}/portfw");
   }
-  system("/usr/local/bin/forwardfwctrl");
- }
+  system("/usr/local/bin/firewallctrl");
+
+  # Convert old OpenVPN CCD files (CN change, core 75).
+  system("/usr/local/bin/convert-ovpn");
+}
 elsif ($ARGV[0] eq 'restoreaddon') {
   if ( -e "/tmp/$ARGV[1]" ){system("mv /tmp/$ARGV[1] /var/ipfire/backup/addons/backup/$ARGV[1]");}
   system("cd / && tar -xvz -p -f /var/ipfire/backup/addons/backup/$ARGV[1]");
@@ -152,14 +158,12 @@ sub createinclude(){
   open(DATEI, "<${General::swroot}/backup/include") || die "Can not open include file";
   my @Zeilen = <DATEI>;
   close(DATEI);
-  
+
   foreach (@Zeilen){
-  if ( $_ =~ /\*/){
-    my @files = `ls $_`;
+    chomp($_);
+    my @files = `find $_ -maxdepth 0 2>/dev/null`;
     foreach (@files){
       push(@include,$_);
-     }
-   }
-  else {push(@include,$_);}
+    }
   }
 }