1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-22 02:17:26 +00:00

Don't write collection_status output to file but parse it directly

This commit is contained in:
Leo Koppelkamm 2015-07-27 22:30:22 +02:00
parent e693802091
commit ba9065cada

View File

@ -58,26 +58,26 @@ def backup_status(env):
"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())
# 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
# Split multi line string into list
collection_status = collection_status.split('\n')
# Remove status file
os.remove(os.path.join(backup_root, "duplicity_status"))
# Parse backup data from status file
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.