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
1905e3b7
Commit
1905e3b7
authored
7 years ago
by
Florent Thiery
Browse files
Options
Downloads
Patches
Plain Diff
support local folder for backups checking, refs
#21677
parent
3c4458bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
global-conf.sh
+3
-1
3 additions, 1 deletion
global-conf.sh
tests/test_backup.py
+33
-0
33 additions, 0 deletions
tests/test_backup.py
with
36 additions
and
1 deletion
global-conf.sh
+
3
−
1
View file @
1905e3b7
...
...
@@ -108,8 +108,10 @@ BURP_MAIL_DEST='sysadmin@ubicast.eu'
BURP_CLIENT_NAME
=
BURP_CLIENT_MAIL_DEST
=
'sysadmin@ubicast.eu'
# -- tmbackup
# -- tmbackup
.sh --
BACKUP_SERVER
=
''
# CSV separated
LOCAL_BACKUP_FOLDERS
=
'/backup'
# -- FTP --
# move uploaded files into hotfolder
...
...
This diff is collapsed.
Click to expand it.
tests/test_backup.py
+
33
−
0
View file @
1905e3b7
...
...
@@ -67,11 +67,42 @@ def test_backup_space(server):
return
False
def
check_local_backup
(
path
):
for
d
in
os
.
listdir
(
path
):
subd
=
os
.
path
.
join
(
path
,
d
)
latest
=
os
.
path
.
join
(
subd
,
'
latest
'
)
if
os
.
exists
(
latest
):
mtime
=
os
.
path
.
getmtime
(
latest
)
d
=
datetime
.
fromtimestamp
(
mtime
)
now
=
datetime
.
now
()
diff_seconds
=
(
now
-
d
).
total_seconds
()
if
diff_seconds
>
25
*
3600
:
print
(
'
Backup %s is older than a day
'
%
subd
)
return
False
else
:
print
(
'
Backup %s is fine
'
%
subd
)
return
True
else
:
print
(
'
Backup %s is not okay (no %s file)
'
%
(
subd
,
latest
))
return
False
def
check_local_backups
(
paths
):
all_ok
=
True
blacklist
=
(
'
lost+found
'
)
folders
=
paths
.
split
(
'
,
'
)
for
f
in
folders
:
if
f
not
in
blacklist
:
all_ok
=
min
(
check_local_backup
(
f
),
all_ok
)
return
all_ok
os
.
chdir
(
os
.
path
.
dirname
(
__file__
))
if
os
.
path
.
isfile
(
'
../utils.py
'
):
es_utils
=
imp
.
load_source
(
'
es_utils
'
,
'
../utils.py
'
)
conf
=
es_utils
.
load_conf
()
BACKUP_SERVER
=
conf
.
get
(
'
BACKUP_SERVER
'
)
LOCAL_BACKUP_FOLDERS
=
conf
.
get
(
'
LOCAL_BACKUP_FOLDERS
'
)
if
BACKUP_SERVER
:
if
not
test_ssh
(
BACKUP_SERVER
):
print
(
'
Failed to ssh into backup server
'
)
...
...
@@ -84,6 +115,8 @@ if os.path.isfile('../utils.py'):
sys
.
exit
(
1
)
else
:
sys
.
exit
(
0
)
elif
LOCAL_BACKUP_FOLDERS
:
sys
.
exit
(
check_local_backups
(
LOCAL_BACKUP_FOLDERS
))
else
:
print
(
'
No BACKUP_SERVER defined in config, untestable
'
)
sys
.
exit
(
2
)
...
...
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