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 13B167B146 for ; Tue, 11 May 2021 15:00:34 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 05B1022324 for ; Tue, 11 May 2021 15:00:04 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 58F1B22301 for ; Tue, 11 May 2021 15:00:01 +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 30E7642E6E for ; Tue, 11 May 2021 15:00:01 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Tue, 11 May 2021 14:59:55 +0200 Message-Id: <20210511125955.25105-7-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210511125955.25105-1-f.ebner@proxmox.com> References: <20210511125955.25105-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.002 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH zsync 6/6] fix #3351: allow keeping a different number of snapshots on source and destination X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 13:00:34 -0000 by introducing a new dest-maxsnap parameter which can be used to override maxsnap for the destination side. This is useful for backups, as one can potentially save a lot of space on the source side (or the destination side if one can come up with a use case for that) by keeping fewer snapshots around. Signed-off-by: Fabian Ebner --- pve-zsync | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/pve-zsync b/pve-zsync index 1213361..39ead0d 100755 --- a/pve-zsync +++ b/pve-zsync @@ -244,6 +244,7 @@ sub parse_argv { verbose => undef, limit => undef, maxsnap => undef, + dest_maxsnap => undef, name => undef, skip => undef, method => undef, @@ -261,6 +262,7 @@ sub parse_argv { 'verbose' => \$param->{verbose}, 'limit=i' => \$param->{limit}, 'maxsnap=i' => \$param->{maxsnap}, + 'dest-maxsnap=i' => \$param->{dest_maxsnap}, 'name=s' => \$param->{name}, 'skip' => \$param->{skip}, 'method=s' => \$param->{method}, @@ -336,6 +338,7 @@ sub param_to_job { $job->{method} = "ssh" if !$job->{method}; $job->{limit} = $param->{limit}; $job->{maxsnap} = $param->{maxsnap}; + $job->{dest_maxsnap} = $param->{dest_maxsnap}; $job->{source} = $param->{source}; $job->{source_user} = $param->{source_user}; $job->{dest_user} = $param->{dest_user}; @@ -460,6 +463,7 @@ sub format_job { $text .= " root"; $text .= " $PROGNAME sync --source $job->{source} --dest $job->{dest}"; $text .= " --name $job->{name} --maxsnap $job->{maxsnap}"; + $text .= " --dest-maxsnap $job->{dest_maxsnap}" if defined($job->{dest_maxsnap}); $text .= " --limit $job->{limit}" if $job->{limit}; $text .= " --method $job->{method}"; $text .= " --verbose" if $job->{verbose}; @@ -681,20 +685,31 @@ sub sync { ($dest->{old_snap}, $dest->{last_snap}) = snapshot_get( $dest_dataset, - $param->{maxsnap}, + $param->{dest_maxsnap} // $param->{maxsnap}, $param->{name}, $dest->{ip}, $param->{dest_user}, ); + ($source->{old_snap}) = snapshot_get( + $source->{all}, + $param->{maxsnap}, + $param->{name}, + $source->{ip}, + $param->{source_user}, + ); + prepare_prepended_target($source, $dest, $param->{dest_user}) if defined($dest->{prepend}); snapshot_add($source, $dest, $param->{name}, $date, $param->{source_user}, $param->{dest_user}); send_image($source, $dest, $param); - for my $old_snap (@{$dest->{old_snap}}) { + for my $old_snap (@{$source->{old_snap}}) { snapshot_destroy($source->{all}, $old_snap, $source->{ip}, $param->{source_user}); + } + + for my $old_snap (@{$dest->{old_snap}}) { snapshot_destroy($dest_dataset, $old_snap, $dest->{ip}, $param->{dest_user}); } }; @@ -1157,6 +1172,9 @@ $PROGNAME create --dest --source [OPTIONS] The number of snapshots to keep until older ones are erased. The default is 1, use 0 for unlimited. + --dest-maxsnap integer + Override maxsnap for the destination dataset. + --name string The name of the sync job, if not set it is default @@ -1197,6 +1215,9 @@ $PROGNAME sync --dest --source [OPTIONS]\n The number of snapshots to keep until older ones are erased. The default is 1, use 0 for unlimited. + --dest-maxsnap integer + Override maxsnap for the destination dataset. + --name string The name of the sync job, if not set it is 'default'. It is only necessary if scheduler allready contains this source. -- 2.20.1