备份任务测试

This commit is contained in:
曹前明 2022-08-18 16:50:42 +08:00
parent c635b6b54a
commit ea510bee75
2 changed files with 12 additions and 12 deletions

View File

@ -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

View File

@ -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):