From: Michael Tremer Date: Fri, 4 Mar 2022 10:29:23 +0000 (+0000) Subject: backup: Don't restore excluded files X-Git-Tag: v2.27-core164~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3f8e70f6b34ee085cb0a5ad22792e521cd867c1c;p=ipfire-2.x.git backup: Don't restore excluded files Sometimes, we restore a backup that has been created earlier before exclude files have been changed. To avoid overwriting those files, we will consider the exlude list upon restore. Signed-off-by: Michael Tremer --- diff --git a/config/backup/backup.pl b/config/backup/backup.pl index 768b355088..f015902db8 100644 --- a/config/backup/backup.pl +++ b/config/backup/backup.pl @@ -72,7 +72,9 @@ restore_backup() { local filename="${1}" # Extract backup - if ! tar xvzpf "${filename}" -C /; then + if ! tar xvzpf "${filename}" -C / \ + --exclude-from="/var/ipfire/backup/exclude" \ + --exclude-from="/var/ipfire/backup/exclude.user"; then echo "Could not extract backup" >&2 return 1 fi diff --git a/src/installer/hw.c b/src/installer/hw.c index 17e0bbb01e..5cba2a261a 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1204,7 +1204,9 @@ char* hw_find_backup_file(const char* output, const char* search_path) { int hw_restore_backup(const char* output, const char* backup_path, const char* destination) { char command[STRING_SIZE]; - snprintf(command, sizeof(command), "/bin/tar xzpf %s -C %s", backup_path, destination); + snprintf(command, sizeof(command), "/bin/tar xzpf %s -C %s " + "--exclude-from=%s/var/ipfire/backup/exclude --exclude-from=%s/var/ipfire/backup/exclude.user", + backup_path, destination, destination, destination); int rc = mysystem(output, command); if (rc)