Commit 8c706b8a authored by James Valleroy's avatar James Valleroy

backups: Dump manifests file and include it in backup

Signed-off-by: James Valleroy's avatarJames Valleroy <jvalleroy@mailbox.org>
parent e736d471
...@@ -19,6 +19,7 @@ FreedomBox app to manage backup archives. ...@@ -19,6 +19,7 @@ FreedomBox app to manage backup archives.
""" """
import json import json
import os
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
...@@ -37,6 +38,8 @@ description = [_('Backups allows creating and managing backup archives.'), ] ...@@ -37,6 +38,8 @@ description = [_('Backups allows creating and managing backup archives.'), ]
service = None service = None
MANIFESTS_FOLDER = '/var/lib/plinth/backups-manifests/'
def init(): def init():
"""Intialize the module.""" """Intialize the module."""
...@@ -70,7 +73,16 @@ def get_archive(name): ...@@ -70,7 +73,16 @@ def get_archive(name):
def _backup_handler(packet): def _backup_handler(packet):
"""Performs backup operation on packet.""" """Performs backup operation on packet."""
if not os.path.exists(MANIFESTS_FOLDER):
os.makedirs(MANIFESTS_FOLDER)
manifest_path = MANIFESTS_FOLDER + packet.label + '.json'
manifests = {x[0]: x[2] for x in packet.manifests}
with open(manifest_path, 'w') as manifest_file:
json.dump(manifests, manifest_file)
paths = packet.directories + packet.files paths = packet.directories + packet.files
paths.append(manifest_path)
actions.superuser_run('backups', actions.superuser_run('backups',
['create', '--name', packet.label, '--path'] + paths) ['create', '--name', packet.label, '--path'] + paths)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment