Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
code-generic
code-webis-cmd
Commits
92cc79ec
Commit
92cc79ec
authored
Jan 19, 2021
by
Alban Bruder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update cephfs snapshot tool
parent
54f5ab37
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
tools/ceph/fs.sh
tools/ceph/fs.sh
+9
-5
No files found.
tools/ceph/fs.sh
View file @
92cc79ec
...
...
@@ -21,6 +21,7 @@ check_tools "realpath"
### : path : dpath! : .
### : -t : --tag : str : manual : Snapshot tag
### : -n : --num : int :: Number of snapshots with the given tag
### :: --timestamp : str : %Y%m%d_%H%M%S : Timestamp or date format
cmd_snapshot
()
{
ARG_PATH
=
"
$(
realpath
"
$ARG_PATH
"
)
"
...
...
@@ -33,7 +34,7 @@ cmd_snapshot() {
ARG_NUM
=
"-1"
fi
newsnap
=
"
${
ARG_PATH
}
/.snap/
${
ARG_TAG
}
_
$(
date
+
'%Y%m%d_%H%M%S'
)
"
newsnap
=
"
${
ARG_PATH
}
/.snap/
${
ARG_TAG
}
_
$(
date
+
"
$ARG_TIMESTAMP
"
)
"
# Create snapshot
if
[
!
"
$ARG_NUM
"
-eq
0
]
;
then
...
...
@@ -65,9 +66,9 @@ cmd_snapshot() {
### : path : path : .
### : -t : --tag : str :: Snapshot tag
cmd_snapshot_list
()
{
snappattern
=
^
.
snappattern
=
.
if
[[
!
-z
"
$ARG_TAG
"
]]
;
then
snappattern
=
"
${
ARG_TAG
}
_
*_*
"
snappattern
=
"
${
ARG_TAG
}
_"
fi
prefix
=
"
$(
realpath
-m
"
$ARG_PATH
"
)
"
...
...
@@ -76,10 +77,13 @@ cmd_snapshot_list() {
# list snapshots
while
[[
"
$prefix
"
!=
"/"
]]
;
do
ls
-d
-1a
"
${
prefix
}
"
/.snap/
*
2>/dev/null |
while
read
snap
;
do
if
[[
-e
"
$snap
/
$suffix
"
]]
&&
{
[[
-z
"
$ARG_TAG
"
]]
||
[[
"
$(
basename
$snap
)
"
=
~ ^
"
$
ARG_TAG
"
_[0-9]
{
8
}
_[0-9]
{
6
}
$
]]
;
}
;
then
if
[[
"
$(
basename
$snap
)
"
=
~ ^[
a-zA-Z0-9]
*
_[0-9]
{
8
}
_[0-9]
{
6
}
$
]]
;
then
if
[[
-e
"
$snap
/
$suffix
"
]]
&&
{
[[
-z
"
$ARG_TAG
"
]]
||
[[
"
$(
basename
$snap
)
"
=
~ ^
"
$
snappattern
"
]]
;
}
;
then
if
[[
"
$(
basename
$snap
)
"
=
~ ^[
^_]+
_[0-9]
{
8
}
_[0-9]
{
6
}
$
]]
;
then
snap_date
=
"
$(
basename
$snap
|
awk
-F
'_'
'{print substr($2,1,4) "-" substr($2,5,2) "-" substr($2,7,2) " " substr($3,1,2) ":" substr($3,3,2) ":" substr($3,5,2)}'
)
"
snap_tag
=
"
$(
basename
$snap
|
awk
-F
'_'
'{print $1}'
)
"
elif
[[
"
$(
basename
$snap
)
"
=
~ ^[^_]+_[0-9]
{
8
}
$
]]
;
then
snap_date
=
"
$(
basename
$snap
|
awk
-F
'_'
'{print substr($2,1,4) "-" substr($2,5,2) "-" substr($2,7,2)}'
)
00:00:00"
snap_tag
=
"
$(
basename
$snap
|
awk
-F
'_'
'{print $1}'
)
"
else
snap_date
=
"
$(
date
-r
"
$snap
"
"+%Y-%m-%d %H:%M:%S"
)
"
snap_tag
=
"
$(
basename
$snap
)
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment