备份任务测试
This commit is contained in:
parent
c635b6b54a
commit
ea510bee75
|
@ -19,7 +19,8 @@ def backup_database():
|
|||
BACKUP_PATH + '/database',
|
||||
name)
|
||||
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||
return completed
|
||||
if completed.returncode != 0:
|
||||
return completed.stderr
|
||||
|
||||
|
||||
@shared_task
|
||||
|
@ -49,4 +50,5 @@ def reload_server_only():
|
|||
def backup_media():
|
||||
command = 'bash {}/backup_media.sh'.format(SH_PATH)
|
||||
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||
return completed
|
||||
if completed.returncode != 0:
|
||||
return completed.stderr
|
||||
|
|
|
@ -80,11 +80,10 @@ class BackupDatabase(APIView):
|
|||
|
||||
备份数据库到指定位置
|
||||
"""
|
||||
completed = backup_database()
|
||||
if completed.returncode == 0:
|
||||
return Response()
|
||||
else:
|
||||
raise APIException(completed.stdout)
|
||||
err_str = backup_database()
|
||||
if err_str:
|
||||
raise APIException(err_str)
|
||||
return Response()
|
||||
|
||||
|
||||
class BackupMedia(APIView):
|
||||
|
@ -96,11 +95,10 @@ class BackupMedia(APIView):
|
|||
|
||||
备份资源到指定位置
|
||||
"""
|
||||
completed = backup_media()
|
||||
if completed.returncode == 0:
|
||||
return Response()
|
||||
else:
|
||||
raise APIException(completed.stdout)
|
||||
err_str = backup_database()
|
||||
if err_str:
|
||||
raise APIException(err_str)
|
||||
return Response()
|
||||
|
||||
|
||||
class TestViewSet(CustomGenericViewSet):
|
||||
|
|
Loading…
Reference in New Issue