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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id AFBEA60E1F for ; Mon, 19 Oct 2020 21:02:24 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 871BF2F161 for ; Mon, 19 Oct 2020 21:02:24 +0200 (CEST) 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 863EE2F134 for ; Mon, 19 Oct 2020 21:02:23 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 51E3145E32 for ; Mon, 19 Oct 2020 21:02:23 +0200 (CEST) From: Stoiko Ivanov To: pmg-devel@lists.proxmox.com Date: Mon, 19 Oct 2020 21:02:04 +0200 Message-Id: <20201019190209.11495-8-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201019190209.11495-1-s.ivanov@proxmox.com> References: <20201019190209.11495-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.045 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 Subject: [pmg-devel] [RFC pmg-api 07/12] PBSTools: add methods for managing backups 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: Mon, 19 Oct 2020 19:02:24 -0000 * creating/restoring/forgetting/listing backups Signed-off-by: Stoiko Ivanov --- src/PMG/PBSTools.pm | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/PMG/PBSTools.pm b/src/PMG/PBSTools.pm index e2a2b60..9efb2ce 100644 --- a/src/PMG/PBSTools.pm +++ b/src/PMG/PBSTools.pm @@ -213,6 +213,68 @@ sub print_snapshot { return "${storeid}:${volname}"; } +sub get_snapshots { + my ($scfg, $remote) = @_; + + return run_client_cmd($scfg, $remote, "snapshots"); +} + +sub backup_tree { + my ($scfg, $remote, $opts) = @_; + + my $type = delete $opts->{type}; + die "backup-type not provided\n" if !defined($type); + my $id = delete $opts->{id}; + die "backup-id not provided\n" if !defined($id); + my $root = delete $opts->{root}; + die "root dir not provided\n" if !defined($root); + my $pxarname = delete $opts->{pxarname}; + die "archive name not provided\n" if !defined($pxarname); + my $time = delete $opts->{time}; + + my $param = []; + + push @$param, "$pxarname.pxar:$root"; + push @$param, '--backup-type', $type; + push @$param, '--backup-id', $id; + push @$param, '--backup-time', $time if defined($time); + + return run_raw_client_cmd($scfg, $remote, 'backup', $param, %$opts); +} + +sub restore_pxar { + my ($scfg, $remote, $opts) = @_; + + my $snapshot = delete $opts->{snapshot}; + die "snapshot not provided\n" if !defined($snapshot); + my $pxarname = delete $opts->{pxarname}; + die "archive name not provided\n" if !defined($pxarname); + my $target = delete $opts->{target}; + die "restore-target not provided\n" if !defined($target); + #my $time = delete $opts->{time}; + + my $param = []; + + push @$param, "$snapshot"; + push @$param, "$pxarname.pxar"; + push @$param, "$target"; + push @$param, "--allow-existing-dirs", 0; + + return run_raw_client_cmd($scfg, $remote, 'restore', $param, %$opts); +} + +sub forget_snapshot { + my ($scfg, $remote, $snapshot) = @_; + + die "snapshot not provided\n" if !defined($snapshot); + + my $param = []; + + push @$param, "$snapshot"; + + return run_raw_client_cmd($scfg, $remote, 'forget', $param); +} + sub status { my ($class, $storeid, $scfg) = @_; -- 2.20.1