From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id CD907643D8 for ; Fri, 30 Oct 2020 07:21:25 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C103CF077 for ; Fri, 30 Oct 2020 07:21:25 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 254F8F069 for ; Fri, 30 Oct 2020 07:21:22 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E123845BF0 for ; Fri, 30 Oct 2020 07:21:21 +0100 (CET) Date: Fri, 30 Oct 2020 07:20:46 +0100 (CET) From: Dietmar Maurer To: Stoiko Ivanov , pmg-devel@pve.proxmox.com Message-ID: <484508641.417.1604038846832@webmail.proxmox.com> In-Reply-To: <20201028185432.23067-5-s.ivanov@proxmox.com> References: <20201028185432.23067-1-s.ivanov@proxmox.com> <20201028185432.23067-5-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.4-Rev12 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL 0.014 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [backup.pm, proxmox.com] URIBL_SBL_A 0.1 Contains URL's A record listed in the Spamhaus SBL blocklist [backup.pm] Subject: [pmg-devel] applied: [PATCH pmg-api 02/11] Backup: split backup creation and creating tar X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2020 06:21:25 -0000 applied - see comment inline > On 10/28/2020 7:54 PM Stoiko Ivanov wrote: > > > In preparation for integrating PMG with PBS split the current creation of > a PMG backup into 2 methods: > * create all files in a backup in a target directory > * create a tarball from a backup in a temporary directory > > use the changed method in the backup API call. > > Signed-off-by: Stoiko Ivanov > --- > src/PMG/API2/Backup.pm | 2 +- > src/PMG/Backup.pm | 41 ++++++++++++++++++++++++++++++++--------- > 2 files changed, 33 insertions(+), 10 deletions(-) > > diff --git a/src/PMG/API2/Backup.pm b/src/PMG/API2/Backup.pm > index 0bfcfc9..08c06b5 100644 > --- a/src/PMG/API2/Backup.pm > +++ b/src/PMG/API2/Backup.pm > @@ -131,7 +131,7 @@ __PACKAGE__->register_method ({ > > print "starting backup to: $filename\n"; > > - PMG::Backup::pmg_backup($filename, $param->{statistic}); > + PMG::Backup::pmg_backup_pack($filename, $param->{statistic}); > > print "backup finished\n"; > > diff --git a/src/PMG/Backup.pm b/src/PMG/Backup.pm > index 025bac2..40c41f3 100644 > --- a/src/PMG/Backup.pm > +++ b/src/PMG/Backup.pm > @@ -133,10 +133,11 @@ sub dumpstatdb { > } > > sub pmg_backup { > - my ($filename, $include_statistics) = @_; > + my ($dirname, $include_statistics) = @_; > + > + die "No backupdir provided!\n" if !defined($dirname); > > my $time = time; > - my $dirname = "/tmp/proxbackup_$$.$time"; > my $dbfn = "Proxmox_ruledb.sql"; > my $statfn = "Proxmox_statdb.sql"; > my $tarfn = "config_backup.tar"; > @@ -145,12 +146,7 @@ sub pmg_backup { > > eval { > > - my $targetdir = dirname($filename); > - mkdir $targetdir; # try to create target dir > - -d $targetdir || > - die "unable to access target directory '$targetdir'\n"; > - > - # create a temporary directory > + # create backup directory > mkdir $dirname; seems we do this twice now > > # dump the database first > @@ -197,7 +193,34 @@ sub pmg_backup { > system("cd $dirname; md5sum $tarfn $dbfn $extradb $verfn> $sigfn") == 0 || > die "unable to create backup signature: ERROR"; > > - system("rm -f $filename; tar czf $filename -C $dirname $verfn $sigfn $dbfn $extradb $tarfn") == 0 || > + }; > + my $err = $@; > + > + if ($err) { > + die $err; > + } > +} > + > +sub pmg_backup_pack { > + my ($filename, $include_statistics) = @_; > + > + my $time = time; > + my $dirname = "/tmp/proxbackup_$$.$time"; > + > + eval { > + > + my $targetdir = dirname($filename); > + mkdir $targetdir; # try to create target dir > + -d $targetdir || > + die "unable to access target directory '$targetdir'\n"; > + > + rmtree $dirname; > + # create backup directory > + mkdir $dirname; > + > + pmg_backup($dirname, $include_statistics); > + > + system("rm -f $filename; tar czf $filename --strip-components=1 -C $dirname .") == 0 || > die "unable to create backup archive: ERROR"; > }; > my $err = $@; > -- > 2.20.1 > > > > _______________________________________________ > pmg-devel mailing list > pmg-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel