Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mailinabox
Commits
ba9065ca
Commit
ba9065ca
authored
Jul 27, 2015
by
Leo Koppelkamm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't write collection_status output to file but parse it directly
parent
e6938020
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
backup.py
management/backup.py
+13
-13
No files found.
management/backup.py
View file @
ba9065ca
...
...
@@ -46,7 +46,7 @@ def backup_status(env):
if
rd
.
days
>
1
:
return
"
%
d days,
%
d hours"
%
(
rd
.
days
,
rd
.
hours
)
if
rd
.
days
==
1
:
return
"
%
d day,
%
d hours"
%
(
rd
.
days
,
rd
.
hours
)
return
"
%
d hours,
%
d minutes"
%
(
rd
.
hours
,
rd
.
minutes
)
def
parse_line
(
line
):
keys
=
line
.
strip
()
.
split
()
date
=
dateutil
.
parser
.
parse
(
keys
[
1
])
...
...
@@ -57,28 +57,28 @@ def backup_status(env):
"full"
:
keys
[
0
]
==
"full"
,
"size"
:
int
(
keys
[
2
])
*
250
*
1000000
,
}
#
Write duplicity status to file
shell
(
'check_call
'
,
[
#
Get duplicity collection status
collection_status
=
shell
(
'check_output
'
,
[
"/usr/bin/duplicity"
,
"collection-status"
,
"--archive-dir"
,
backup_cache_dir
,
"--log-file"
,
os
.
path
.
join
(
backup_root
,
"duplicity_status"
),
"--gpg-options"
,
"--cipher-algo=AES256"
,
"--log-fd"
,
"1"
,
config
[
"target"
],
],
get_env
())
# Split multi line string into list
collection_status
=
collection_status
.
split
(
'
\n
'
)
# Parse backup data from status file
with
open
(
os
.
path
.
join
(
backup_root
,
"duplicity_status"
),
'r'
)
as
status_file
:
for
line
in
status_file
:
if
line
.
startswith
(
" full"
)
or
line
.
startswith
(
" inc"
):
backup
=
parse_line
(
line
)
backups
[
backup
[
"date"
]]
=
backup
# Remove status file
os
.
remove
(
os
.
path
.
join
(
backup_root
,
"duplicity_status"
))
for
line
in
collection_status
:
if
line
.
startswith
(
" full"
)
or
line
.
startswith
(
" inc"
):
backup
=
parse_line
(
line
)
backups
[
backup
[
"date"
]]
=
backup
# Ensure the rows are sorted reverse chronologically.
# This is relied on by should_force_full() and the next step.
backups
=
sorted
(
backups
.
values
(),
key
=
lambda
b
:
b
[
"date"
],
reverse
=
True
)
...
...
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