mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-03 10:50:20 +00:00
backups: Dump manifests file and include it in backup
Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
parent
616af37407
commit
d76322a362
@ -19,6 +19,7 @@ FreedomBox app to manage backup archives.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@ -37,6 +38,8 @@ description = [_('Backups allows creating and managing backup archives.'), ]
|
||||
|
||||
service = None
|
||||
|
||||
MANIFESTS_FOLDER = '/var/lib/plinth/backups-manifests/'
|
||||
|
||||
|
||||
def init():
|
||||
"""Intialize the module."""
|
||||
@ -70,7 +73,16 @@ def get_archive(name):
|
||||
|
||||
def _backup_handler(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.append(manifest_path)
|
||||
actions.superuser_run('backups',
|
||||
['create', '--name', packet.label, '--path'] + paths)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user