Changed the way command passed to the Flask endpoint

pull/2/head
Illia Chub 2021-10-27 12:24:46 +03:00
parent 376e38942b
commit 956336da4b
1 changed files with 6 additions and 4 deletions

10
main.py
View File

@ -493,10 +493,12 @@ def ListAllBackups():
@app.route("/services/restic/backup/create", methods=["PUT"])
def CreateSingleBackup():
backupProcessDescriptor = subprocess.Popen(["restic", "-r", "b2:" +
request.headers.get("X-Repository-Name") + ":/sfbackup", "--verbose", "backup", "/var",
"--password-file", "/var/lib/restic/rpass"
])
backupCommand = '''
restic -r b2:{}:/sfbackup --verbose backup /var --password-file /var/lib/restic/rpass
'''.format(request.headers.get("X-Repository-Name"))
backupProcessDescriptor = subprocess.Popen(backupCommand, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
backupProcessDescriptor.communicate()[0]