]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
backup: Don't restore excluded files
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Mar 2022 10:29:23 +0000 (10:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Mar 2022 10:37:00 +0000 (10:37 +0000)
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 <michael.tremer@ipfire.org>
config/backup/backup.pl
src/installer/hw.c

index 768b3550886c0e433e1dcb417d8827b05063f222..f015902db87e10f5cb881ee02131dd4745cddf9c 100644 (file)
@@ -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
index 17e0bbb01ef35fddff59cc787a1c1881331b72fb..5cba2a261a81c55aafdb7d5eb696a6111f2c4e73 100644 (file)
@@ -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)