Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Oleg Borisenko
tapebackup
Commits
1ca9b293
Commit
1ca9b293
authored
Sep 03, 2021
by
Oleg Borisenko
Browse files
Fixed dumb error on target addition; adapted queue forming for ztron naming
parent
35ae8ad2
Changes
3
Hide whitespace changes
Inline
Side-by-side
tapebackup/scripts/backup_daemon.py
View file @
1ca9b293
...
...
@@ -5,6 +5,7 @@ import logging
import
signal
import
os
import
re
import
redis
import
sys
import
time
...
...
@@ -55,7 +56,7 @@ def form_wgs_queue(files_to_backup, free_space):
# 7 or more should never happen. If it goes there, maybe it would be safer to drop just one file.
# important: since target is scanned in lexicographical order and we order by ID, previous file
# should always contain at least previous level of current file.
if
current_file_folder_level
<=
4
:
if
current_file_folder_level
<=
4
and
not
re
.
match
(
r
'\w+_L01'
,
current_file_folder
)
:
if
current_file_folder_level
==
prev_file_folder_level
:
# getting rid of all files from that level
queue_size
-=
i
.
fsize
files_to_exclude_from_queue
+=
1
...
...
@@ -63,7 +64,8 @@ def form_wgs_queue(files_to_backup, free_space):
raise
Exception
(
"Error forming the batch, level %d"
%
current_file_folder_level
)
return
wgs_queue
[:
len
(
wgs_queue
)
-
files_to_exclude_from_queue
],
queue_size
elif
current_file_folder_level
==
5
:
elif
current_file_folder_level
==
5
\
or
(
current_file_folder_level
==
4
and
re
.
match
(
r
'\w+_L01'
,
current_file_folder
)):
# comparing "grandparents" to iterate to previous sequencing proc id
if
os
.
path
.
dirname
(
current_file_folder
)
==
os
.
path
.
dirname
(
os
.
path
.
dirname
(
i
.
relative_path
)):
queue_size
-=
i
.
fsize
...
...
tapebackup/views/default.py
View file @
1ca9b293
...
...
@@ -122,7 +122,7 @@ def add_backup_target_post(request):
try
:
unique_label
=
request
.
POST
.
get
(
"unique_label"
)
fullpath
=
request
.
POST
.
get
(
"fullpath"
)
rescan_interval
=
request
.
POST
.
get
(
"rescan_interval"
)
rescan_interval
=
int
(
request
.
POST
.
get
(
"rescan_interval"
)
)
kind
=
request
.
POST
.
get
(
"kind"
)
if
not
unique_label
or
not
fullpath
or
not
rescan_interval
or
not
kind
:
raise
HTTPException
(
"All parameters are obligatory"
)
...
...
@@ -130,7 +130,8 @@ def add_backup_target_post(request):
json
=
{
"unique_label"
:
unique_label
,
"fullpath"
:
fullpath
,
"rescan_interval"
:
rescan_interval
*
1440
,
"kind"
:
kind
})
"kind"
:
kind
,
"enabled"
:
True
})
res
=
request
.
invoke_subrequest
(
subreq
,
use_tweens
=
True
).
json
next_url
=
request
.
route_url
(
'targets'
,
_query
=
((
'result'
,
'Backup target %s successfully added'
%
(
unique_label
)),
...
...
tapebackup/views/target_crud.py
View file @
1ca9b293
...
...
@@ -17,7 +17,7 @@ from .. import utils
@
view_config
(
route_name
=
'add_backup_target'
,
renderer
=
'json'
,
request_method
=
'POST'
)
def
add_backup_target
(
request
):
try
:
target_props
=
dict
((
k
,
request
.
json_body
[
k
])
for
k
in
(
'unique_label'
,
'kind'
,
'enabled'
,
'ignore_filter'
,
target_props
=
dict
((
k
,
request
.
json_body
[
k
])
for
k
in
(
'unique_label'
,
'kind'
,
'enabled'
,
'rescan_interval'
,
'fullpath'
))
# removing trailing slash since it's very important for logics later
target_props
[
'fullpath'
]
=
os
.
path
.
normpath
(
target_props
[
'fullpath'
])
...
...
@@ -60,7 +60,10 @@ def list_backup_targets(request):
target_to_ret
[
'files_count'
]
=
files_on_target
files_size_on_target
=
request
.
dbsession
.
query
(
func
.
sum
(
models
.
FileToBackup
.
fsize
).
cast
(
BIGINT
)).
filter
(
target
.
unique_label
==
models
.
file_to_backup
.
FileToBackup
.
target_unique_label
).
scalar
()
target_to_ret
[
'files_size_on_target_gb'
]
=
round
(
files_size_on_target
/
(
1024
**
3
),
2
)
if
files_size_on_target
:
target_to_ret
[
'files_size_on_target_gb'
]
=
round
(
files_size_on_target
/
(
1024
**
3
),
2
)
else
:
target_to_ret
[
'files_size_on_target_gb'
]
=
'unknown'
target_to_return
.
append
(
target_to_ret
)
return
target_to_return
except
SQLAlchemyError
as
e
:
...
...
Write
Preview
Supports
Markdown
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