From patchwork Fri May 21 12:22:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adolf Belka X-Patchwork-Id: 4349 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4Fmm3M3Vtwz3wbl for ; Fri, 21 May 2021 12:23:11 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4Fmm3L1M9zzq5; Fri, 21 May 2021 12:23:10 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Fmm3K74HZz2xfn; Fri, 21 May 2021 12:23:09 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4Fmm3J36WHz2xfn for ; Fri, 21 May 2021 12:23:08 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4Fmm3G58PPzq5; Fri, 21 May 2021 12:23:06 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1621599786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=f/T94qpW7CHGWoxs9PuOkCxlrkymQB0Y4MnObf7KdDo=; b=Ny+XVenINp8ljssZmEi0NPcgjvJkqzYzqWwcEoLt5bg1u96V2OouEasYw7VxFoc8n93S5G Y9qPu3DPf9aldaDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1621599786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=f/T94qpW7CHGWoxs9PuOkCxlrkymQB0Y4MnObf7KdDo=; b=IpVXwm+B6lsGBnDK+dpHhggqxbY3hOy15gbuLKvn41nglDou+6qaDXAn5AzPVqP0r5nLcC pm/rtP6HVYYSmeBzOI42axsn5YLfu+6+jf80pZ0fFh4mGd56vP/XtrNAqB4GZvDm3yDEzk jJG5ueBRgViz3pSfkpIn7rEyAyTazKdXfccB7VyUEBOQ+ktFw5vGCxnrL4wMZr+RIjMAmu EAXbAolqZlMFSJ0UmITY7azM8XxXsrUohbVKEcnygarAOCwDTU5ILMD3+ArY2ri9I0zvUS tJkOc1madujXLUAb+VLg+sqHhikClYFRNx2FVSFnnzZRuhpi1qNItsgcGQaigg== From: Adolf Belka To: development@lists.ipfire.org Subject: [PATCH] backup.pl: Fix #12626 backup/include.user entries will not override backup/exclude Date: Fri, 21 May 2021 14:22:50 +0200 Message-Id: <20210521122250.7788-1-adolf.belka@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" - Current situation is that any restrictions in the exclude file will not be overwritten by the include.user file - For example the global exclude file has *.tmp preventing any tmp files being backed up from the globally included IPFire files If a user has some specific tmp files they want to backup and include them in the include.user file they will not override the global exclude file. - This fix does the backup of the global and user backups as two separate events and then appends them. This means that any tmp files in the include.user file will be backed up. - The backups are created as a global tar file and then have the user tar file appended and then the combined file gzipped and given the .ipf suffix. This has to be done this was as gzipped files can not be appended to each other whereas tar files can. Fixes: 12626 Signed-off-by: Adolf Belka --- config/backup/backup.pl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/config/backup/backup.pl b/config/backup/backup.pl index d2e531252..8dffbf2e1 100644 --- a/config/backup/backup.pl +++ b/config/backup/backup.pl @@ -57,12 +57,21 @@ make_backup() { make_addon_backup "${addon}" done - tar cvzf "${filename}" \ + # Backup using global exclude/include definitions + tar cvf "${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" "/var/ipfire/backup/include.user") \ + $(process_includes "/var/ipfire/backup/include.user") \ "$@" + # gzip the combined global/user backup and use .ipf suffix + gzip --suffix .ipf "${filename}" + return 0 } @@ -206,7 +215,7 @@ main() { local filename="${1}" if [ -z "${filename}" ]; then - filename="/var/ipfire/backup/${NOW}.ipf" + filename="/var/ipfire/backup/${NOW}" fi make_backup "${filename}" $(find_logfiles) @@ -216,7 +225,7 @@ main() { local filename="${1}" if [ -z "${filename}" ]; then - filename="/var/ipfire/backup/${NOW}.ipf" + filename="/var/ipfire/backup/${NOW}" fi make_backup "${filename}"