mirror of https://github.com/jimsalterjrs/sanoid
full flexibility for naming template
This commit is contained in:
parent
acbf5daa43
commit
b50e55c17a
12
sanoid
12
sanoid
|
|
@ -607,7 +607,10 @@ sub take_snapshots {
|
|||
|
||||
foreach my $type (@types) {
|
||||
my $sortable = strftime($config{$dataset}{'datestamp_format'}, localtime($datestamp{'unix_time'}));
|
||||
my $snapname = "$config{$dataset}{'prefix'}_${sortable}_$type";
|
||||
my $snapname = $config{$dataset}{'snapname_format'};
|
||||
$snapname =~ s/IDENTIFIER/$config{$dataset}{'identifier'}/g;
|
||||
$snapname =~ s/DATE/$sortable/g;
|
||||
$snapname =~ s/TYPE/$type/g;
|
||||
push(@snapshots, $snapname);
|
||||
}
|
||||
|
||||
|
|
@ -889,12 +892,13 @@ sub getsnaps {
|
|||
}
|
||||
|
||||
foreach my $snap (@rawsnaps) {
|
||||
my ($fs,$snapname,$snapdate) = ($snap =~ m/(.*)\@(.*ly)\t*creation\t*(\d*)/);
|
||||
my ($fs,$snapname,$snapdate) = ($snap =~ m/(.*)\@(.*?)\t*creation\t*(\d*)/);
|
||||
|
||||
# avoid pissing off use warnings
|
||||
if (defined $snapname) {
|
||||
my ($snaptype) = ($snapname =~ m/.*_(\w*ly)/);
|
||||
if ($snapname =~ /^$config{$fs}{'prefix'}/) {
|
||||
if ($snapname =~ /$config{$fs}{'identifier'}/) {
|
||||
my @types = qw(yearly monthly weekly daily hourly frequently);
|
||||
my ($snaptype) = grep { $snapname =~ /$_/ } @types;
|
||||
$snaps{$fs}{$snapname}{'ctime'}=$snapdate;
|
||||
$snaps{$fs}{$snapname}{'type'}=$snaptype;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,8 @@ yearly_crit = 0
|
|||
capacity_warn = 80
|
||||
capacity_crit = 95
|
||||
|
||||
# snapshot name formats can be overridden to some extent
|
||||
prefix = autosnap
|
||||
# snapshot name formats can be overridden
|
||||
identifier = autosnap
|
||||
# strftime-style format string
|
||||
datestamp_format = %Y-%m-%d_%H:%M:%S
|
||||
snapname_format = IDENTIFIER_DATE_TYPE
|
||||
|
|
|
|||
Loading…
Reference in New Issue