]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - config/backup/backup.pl
backup: Create tarball in one pass
[ipfire-2.x.git] / config / backup / backup.pl
index 3accbcfff852fd5a422f3f9c4c1a14a4c9cc57f8..bed5952def200841fcc574d3fde8126c8b0a1d05 100644 (file)
@@ -57,10 +57,12 @@ make_backup() {
                make_addon_backup "${addon}"
        done
 
-       tar cvzf "${filename}" \
+       # Backup using global exclude/include definitions
+       tar cvfz "${filename}" \
                --exclude-from="/var/ipfire/backup/exclude" \
                --exclude-from="/var/ipfire/backup/exclude.user" \
-               $(process_includes "/var/ipfire/backup/include" "/var/ipfire/backup/include.user") \
+               $(process_includes "/var/ipfire/backup/include") \
+               $(process_includes "/var/ipfire/backup/include.user") \
                "$@"
 
        return 0
@@ -71,6 +73,22 @@ restore_backup() {
 
        tar xvzpf "${filename}" -C /
 
+       # Restart syslogd, httpd and suricata in case we've just loaded old logs
+       apachectl -k graceful
+       /bin/kill -HUP `cat /var/run/suricata.pid 2> /dev/null` 2> /dev/null
+       /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null
+
+       # remove wrong vnstat tag file
+       rm -f /var/log/vnstat/tag
+
+       # create dhcpcd user
+       groupadd -g 52 dhcpcd
+       useradd -c 'dhcpcd privsep user'        \
+               -d /run/dhcpcd/chroot           \
+               -g dhcpcd                       \
+               -s /bin/false                   \
+               -u 52 dhcpcd
+
        # Run converters
 
        # Outgoing Firewall
@@ -123,12 +141,30 @@ restore_backup() {
                rm -rf "/var/ipfire/portfw"
        fi
 
+       # Convert location
+       convert-to-location
+
        # Reload firewall
        firewallctrl
 
        # Convert old OpenVPN CCD files (CN change, Core Update 75)
        convert-ovpn
 
+       # Snort to suricata converter.
+       if [ -d "/var/ipfire/snort" ]; then
+               # Run converter
+               convert-snort
+
+               # Remove old configuration directory.
+               rm -rf "/var/ipfire/snort"
+       fi
+
+       # Convert DNS settings
+       convert-dns-settings
+
+       # move nobeeps if exist
+       [ -e "/var/ipfire/ppp/nobeeps" ] && mv /var/ipfire/ppp/nobeeps /var/ipfire/red/nobeeps
+
        return 0
 }
 
@@ -167,20 +203,35 @@ main() {
        local command="${1}"
        shift
 
-       # Desired backup filename
-       local filename="/var/ipfire/backup/${NOW}.ipf"
-
        case "${command}" in
                include)
+                       local filename="${1}"
+
+                       if [ -z "${filename}" ]; then
+                               filename="/var/ipfire/backup/${NOW}.ipf"
+                       fi
+
                        make_backup "${filename}" $(find_logfiles)
                        ;;
 
                exclude)
+                       local filename="${1}"
+
+                       if [ -z "${filename}" ]; then
+                               filename="/var/ipfire/backup/${NOW}.ipf"
+                       fi
+
                        make_backup "${filename}"
                        ;;
 
                restore)
-                       restore_backup "/tmp/restore.ipf"
+                       local filename="${1}"
+
+                       if [ -z "${filename}" ]; then
+                               filename="/tmp/restore.ipf"
+                       fi
+
+                       restore_backup "${filename}"
                        ;;
 
                addonbackup)
@@ -192,6 +243,9 @@ main() {
                        ;;
 
                iso)
+                       # Desired backup filename
+                       local filename="/var/ipfire/backup/${NOW}.ipf"
+
                        if make_backup "${filename}"; then
                                /usr/local/bin/backupiso "${NOW}" &
                        fi