]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
backup: Create tarball in one pass
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 2 Dec 2021 12:37:14 +0000 (12:37 +0000)
committerPeter Müller <peter.mueller@ipfire.org>
Tue, 14 Dec 2021 13:39:21 +0000 (14:39 +0100)
This patch is changing the behaviour of the backup script so that it
creates one tarball and compresses it in one go.

This will save storing the original tarball on disk before compressing
it which on my test system requires significant disk space.

This patch also solves a bug where the backup file included with the ISO
image could not be extracted because it was not gzip-compressed when it
was expected to be.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/backup/backup.pl

index 0b47af2d65418993516a9eab0188741c013e64b2..bed5952def200841fcc574d3fde8126c8b0a1d05 100644 (file)
@@ -58,20 +58,13 @@ make_backup() {
        done
 
        # Backup using global exclude/include definitions
-       tar cvf "${filename}" \
+       tar cvfz "${filename}" \
                --exclude-from="/var/ipfire/backup/exclude" \
-               $(process_includes "/var/ipfire/backup/include") \
-               "$@"
-
-       # Backup using user exclude/include definitions and append to global backup
-       tar rvf "${filename}" \
                --exclude-from="/var/ipfire/backup/exclude.user" \
+               $(process_includes "/var/ipfire/backup/include") \
                $(process_includes "/var/ipfire/backup/include.user") \
                "$@"
 
-       # gzip the combined global/user backup and use .ipf suffix
-       gzip --suffix .ipf "${filename}"
-
        return 0
 }
 
@@ -215,7 +208,7 @@ main() {
                        local filename="${1}"
 
                        if [ -z "${filename}" ]; then
-                               filename="/var/ipfire/backup/${NOW}"
+                               filename="/var/ipfire/backup/${NOW}.ipf"
                        fi
 
                        make_backup "${filename}" $(find_logfiles)
@@ -225,7 +218,7 @@ main() {
                        local filename="${1}"
 
                        if [ -z "${filename}" ]; then
-                               filename="/var/ipfire/backup/${NOW}"
+                               filename="/var/ipfire/backup/${NOW}.ipf"
                        fi
 
                        make_backup "${filename}"