Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
5ea501d2
Commit
5ea501d2
authored
7 years ago
by
Florent Thiery
Browse files
Options
Downloads
Patches
Plain Diff
rewrite local backup check, refs
#21677
parent
3a70e20e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_backup.py
+22
-25
22 additions, 25 deletions
tests/test_backup.py
with
22 additions
and
25 deletions
tests/test_backup.py
+
22
−
25
View file @
5ea501d2
...
@@ -67,40 +67,37 @@ def test_backup_space(server):
...
@@ -67,40 +67,37 @@ def test_backup_space(server):
return
False
return
False
def
check_local_backup
(
path
,
descend
=
True
):
def
check_local_backup
(
path
):
all_ok
=
True
all_ok
=
True
for
d
in
os
.
listdir
(
path
):
backup_folder
=
os
.
path
.
dirname
(
path
)
subd
=
os
.
path
.
join
(
path
,
d
)
latest
=
os
.
path
.
join
(
backup_folder
,
'
latest
'
)
if
os
.
path
.
isdir
(
subd
):
if
os
.
path
.
exists
(
latest
):
latest
=
os
.
path
.
join
(
subd
,
'
latest
'
)
mtime
=
os
.
path
.
getmtime
(
latest
)
print
(
'
Checking %s
'
%
latest
)
d
=
datetime
.
fromtimestamp
(
mtime
)
if
os
.
path
.
exists
(
latest
):
now
=
datetime
.
now
()
mtime
=
os
.
path
.
getmtime
(
latest
)
diff_seconds
=
(
now
-
d
).
total_seconds
()
d
=
datetime
.
fromtimestamp
(
mtime
)
if
diff_seconds
>
25
*
3600
:
now
=
datetime
.
now
()
print
(
'
Backup %s is older than a day
'
%
backup_folder
)
diff_seconds
=
(
now
-
d
).
total_seconds
()
all_ok
=
False
if
diff_seconds
>
25
*
3600
:
print
(
'
Backup %s is older than a day
'
%
subd
)
all_ok
=
False
else
:
print
(
'
Backup %s is fine
'
%
subd
)
else
:
else
:
if
descend
:
print
(
'
Backup %s is fine
'
%
backup_folder
)
for
dd
in
os
.
listdir
(
subd
):
elif
os
.
path
.
exists
(
os
.
path
.
join
(
backup_folder
,
'
backup.inprogress
'
)):
subsubd
=
os
.
path
.
join
(
subd
,
dd
)
print
(
'
Backup %s still running
'
%
backup_folder
)
if
os
.
path
.
isdir
(
subsubd
):
all_ok
=
False
all_ok
=
min
(
all_ok
,
check_local_backup
(
subsubd
,
descend
=
False
))
else
:
print
(
'
Backup %s is not working
'
%
latest
)
all_ok
=
False
return
all_ok
return
all_ok
def
check_local_backups
(
paths
):
def
check_local_backups
(
paths
):
all_ok
=
True
all_ok
=
True
blacklist
=
(
'
lost+found
'
)
folders
=
paths
.
split
(
'
,
'
)
folders
=
paths
.
split
(
'
,
'
)
for
f
in
folders
:
for
f
in
folders
:
if
f
not
in
blacklist
:
cmd
=
"
find %s -maxdepth 4 -name backup.marker
"
%
f
print
(
'
Checking top folder %s
'
%
f
)
status
,
out
=
subprocess
.
getstatusoutput
(
cmd
)
all_ok
=
min
(
check_local_backup
(
f
),
all_ok
)
for
bf
in
out
.
split
(
'
\n
'
):
all_ok
=
min
(
check_local_backup
(
bf
),
all_ok
)
return
all_ok
return
all_ok
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment