mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-07 08:31:06 +00:00
Added backup creation message
This commit is contained in:
parent
a86f2fe2bb
commit
a1e6c77cc1
|
@ -2,6 +2,7 @@
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask_restful import Resource
|
from flask_restful import Resource
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import threading
|
||||||
|
|
||||||
from selfprivacy_api.resources.services import api
|
from selfprivacy_api.resources.services import api
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ class ListAllBackups(Resource):
|
||||||
|
|
||||||
|
|
||||||
# Create a new restic backup
|
# Create a new restic backup
|
||||||
class CreateBackup(Resource):
|
class AsyncCreateBackup(Resource, threading.Thread):
|
||||||
def put(self):
|
def put(self):
|
||||||
backupCommand = """
|
backupCommand = """
|
||||||
restic -r b2:{0}:/sfbackup --verbose backup /var --password-file /var/lib/restic/rpass
|
restic -r b2:{0}:/sfbackup --verbose backup /var --password-file /var/lib/restic/rpass
|
||||||
|
@ -39,8 +40,6 @@ class CreateBackup(Resource):
|
||||||
backupCommand, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
backupCommand, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||||
)
|
)
|
||||||
|
|
||||||
commandOutput = backupProcessDescriptor.communicate()[0]
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"status": 0,
|
"status": 0,
|
||||||
"message": "Backup creation has started",
|
"message": "Backup creation has started",
|
||||||
|
@ -48,4 +47,4 @@ class CreateBackup(Resource):
|
||||||
|
|
||||||
|
|
||||||
api.add_resource(ListAllBackups, "/restic/backup/list")
|
api.add_resource(ListAllBackups, "/restic/backup/list")
|
||||||
api.add_resource(CreateBackup, "/restic/backup/create")
|
api.add_resource(AsyncCreateBackup, "/restic/backup/create")
|
||||||
|
|
Loading…
Reference in a new issue