generated from NethServer/ns8-kickstart
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7b2de9
commit 20ff8ae
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
imageroot/actions/list-backup-contents/50list_backup_contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# | ||
# Copyright (C) 2024 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
import json | ||
import sys | ||
import os | ||
import subprocess | ||
|
||
request = json.load(sys.stdin) | ||
|
||
|
||
backup_id = request['backup'] | ||
folders = [] | ||
|
||
restic_cmd = ["restic-wrapper", "--backup=" + str(backup_id), "dump", request["snapshot"], "/state/maildir-dump.lst"] | ||
|
||
with subprocess.Popen(restic_cmd, stdout=subprocess.PIPE, stderr=sys.stderr, text=True) as vproc: | ||
|
||
while True: | ||
line = vproc.stdout.readline() | ||
if not line: | ||
break | ||
fields = line.rstrip().split("\t") | ||
if fields[0] == request["user"]: | ||
folders.append(fields[1]) | ||
|
||
folders.sort() | ||
|
||
json.dump({ | ||
"backup": request['backup'], | ||
"snapshot": request['snapshot'], | ||
"user": request['user'], | ||
"folders": folders, | ||
}, fp=sys.stdout) |