Skip to content

Commit 5413c56

Browse files
committed
New timestamp_format "human" with separators to increase human readability
1 parent 18ddc65 commit 5413c56

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

ChangeLog

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
unreleased
2+
* New timestamp_format "human" with separators to increase human readability
3+
14
btrbk-0.32.6
25

36
* Fix backup of unrelated (by parent_uuid) snapshots (close #339).

btrbk

+5-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ my $ipv4_addr_match = qr/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}
6464
my $ipv6_addr_match = qr/[a-fA-F0-9]*:[a-fA-F0-9]*:[a-fA-F0-9:]+/; # simplified (contains at least two colons), matches "::1", "2001:db8::7"
6565
my $host_name_match = qr/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])/;
6666
my $uuid_match = qr/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
67-
my $btrbk_timestamp_match = qr/(?<YYYY>[0-9]{4})(?<MM>[0-9]{2})(?<DD>[0-9]{2})(T(?<hh>[0-9]{2})(?<mm>[0-9]{2})((?<ss>[0-9]{2})(?<zz>(Z|[+-][0-9]{4})))?)?(_(?<NN>[0-9]+))?/; # matches "YYYYMMDD[Thhmm[ss+0000]][_NN]"
67+
my $btrbk_timestamp_match = qr/(?<YYYY>[0-9]{4})-?(?<MM>[0-9]{2})-?(?<DD>[0-9]{2})_?(T?(?<hh>[0-9]{2})-?(?<mm>[0-9]{2})((?<ss>[0-9]{2})(?<zz>(Z|[+-][0-9]{4})))?)?(_(?<NN>[0-9]+))??/; # matches "YYYYMMDD[Thhmm[ss+0000]][_NN]"
6868
my $raw_postfix_match = qr/\.btrfs(\.($compress_format_alt))?(\.(gpg|encrypted))?/; # matches ".btrfs[.gz|.bz2|.xz|...][.gpg|.encrypted]"
6969
my $safe_file_match = qr/[0-9a-zA-Z_@\+\-\.\/]+/; # note: ubuntu uses '@' in the subvolume layout: <https://help.ubuntu.com/community/btrfs>
7070

@@ -82,7 +82,7 @@ my %config_options = (
8282
# NOTE: the parser always maps "no" to undef
8383
# NOTE: keys "volume", "subvolume" and "target" are hardcoded
8484
# NOTE: files "." and "no" map to <undef>
85-
timestamp_format => { default => "long", accept => [qw( short long long-iso )], context => [qw( global volume subvolume )] },
85+
timestamp_format => { default => "long", accept => [qw( short long long-iso human )], context => [qw( global volume subvolume )] },
8686
snapshot_dir => { default => undef, accept_file => { relative => 1, absolute => 1 }, context => [qw( global volume subvolume )] },
8787
snapshot_name => { c_default => 1, accept_file => { name_only => 1 }, context => [qw( subvolume )], deny_glob_context => 1 }, # NOTE: defaults to the subvolume name (hardcoded)
8888
snapshot_create => { default => "always", accept => [qw( no always ondemand onchange )], context => [qw( global volume subvolume )] },
@@ -4834,6 +4834,9 @@ sub timestamp($$;$)
48344834
elsif($format eq "debug-iso") {
48354835
$ts = sprintf('%04u-%02u-%02uT%02u:%02u:%02u', $tm[5] + 1900, $tm[4] + 1, $tm[3], $tm[2], $tm[1], $tm[0]);
48364836
}
4837+
elsif($format eq "human") {
4838+
return sprintf('%04u-%02u-%02u_%02u-%02u', $tm[5] + 1900, $tm[4] + 1, $tm[3], $tm[2], $tm[1]);
4839+
}
48374840
else { die; }
48384841

48394842
if($tm_is_utc) {

doc/btrbk.conf.5.asciidoc

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ otherwise.
9494
9595
=== Basic Options
9696
97-
*timestamp_format* short|long|long-iso::
97+
*timestamp_format* short|long|long-iso|human::
9898
Timestamp format used as postfix for new snapshot subvolume
9999
names. Defaults to ``long''.
100100
+
@@ -105,6 +105,7 @@ endif::backend-docbook,backend-manpage[]
105105
*short*;; +YYYYMMDD[_N]+ (e.g. "20150825", "20150825_1")
106106
*long*;; +YYYYMMDD<T>hhmm[_N]+ (e.g. "20150825T1531")
107107
*long-iso*;; +YYYYMMDD<T>hhmmss&plusmn;hhmm[_N]+ (e.g. "20150825T153123+0200")
108+
*human*;; +YYYY\<\->MM\<\->DD<_>hh\<\->mm[_N]+ (e.g. "2015-08-25_15-31")
108109
--
109110
+
110111
Note that a postfix "_N" is appended to the timestamp if a snapshot or

0 commit comments

Comments
 (0)