mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
backups: When restoring, only list apps included in backup
Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
1 parent
2a9a220770
commit
481a299250
4 files changed
+60
-4
No files matched your search
@@ -25,6 +25,7 @@ import glob
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import tarfile
|
||||
|
||||
REPOSITORY = '/var/lib/freedombox/borgbackup'
|
||||
|
||||
@@ -62,6 +63,12 @@ def parse_arguments():
|
||||
list_exports.add_argument('--location', required=True,
|
||||
help='location to check')
|
||||
|
||||
get_export_apps = subparsers.add_parser(
|
||||
'get-export-apps',
|
||||
help='Get list of apps included in exported archive file')
|
||||
get_export_apps.add_argument(
|
||||
'--filename', help='Tarball file name', required=True)
|
||||
|
||||
restore = subparsers.add_parser(
|
||||
'restore', help='Restore files from an exported archive')
|
||||
restore.add_argument('--filename', help='Tarball file name', required=True)
|
||||
@@ -144,6 +151,23 @@ def subcommand_list_exports(arguments):
|
||||
print(json.dumps(exports))
|
||||
|
||||
|
||||
def subcommand_get_export_apps(arguments):
|
||||
"""Get list of apps included in exported archive file."""
|
||||
manifest = None
|
||||
with tarfile.open(arguments.filename) as t:
|
||||
filenames = t.getnames()
|
||||
for name in filenames:
|
||||
if 'var/lib/plinth/backups-manifests/' in name \
|
||||
and name.endswith('.json'):
|
||||
manifest_data = t.extractfile(name).read()
|
||||
manifest = json.loads(manifest_data)
|
||||
break
|
||||
|
||||
if manifest:
|
||||
for app in manifest:
|
||||
print(app['name'])
|
||||
|
||||
|
||||
def subcommand_restore(arguments):
|
||||
"""Restore files from an exported archive."""
|
||||
prev_dir = os.getcwd()
|
||||
|
||||
Reference in new issue
Block a user