backup: Create tarball in one pass

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>
This commit is contained in:
Michael Tremer
2021-12-02 12:37:14 +00:00
committed by Peter Müller
parent d9db91609f
commit 51ed815f5e

View 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}"