mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-02-18 16:36:27 +00:00
Update flask_server.py
This commit is contained in:
@@ -5671,28 +5671,16 @@ def api_create_backup(vmid):
|
|||||||
cmd.extend(['--pbs-change-detection-mode', pbs_change_detection])
|
cmd.extend(['--pbs-change-detection-mode', pbs_change_detection])
|
||||||
|
|
||||||
# Execute vzdump - it will create a Proxmox task automatically
|
# Execute vzdump - it will create a Proxmox task automatically
|
||||||
# Using Popen to not block and let vzdump manage the task
|
# Run in background using shell
|
||||||
process = subprocess.Popen(
|
cmd_str = ' '.join(cmd)
|
||||||
cmd,
|
subprocess.Popen(
|
||||||
stdout=subprocess.PIPE,
|
cmd_str,
|
||||||
stderr=subprocess.PIPE,
|
shell=True,
|
||||||
start_new_session=True # Detach from parent process
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
start_new_session=True
|
||||||
)
|
)
|
||||||
|
|
||||||
# Give it a moment to start and check if it failed immediately
|
|
||||||
import time
|
|
||||||
time.sleep(0.5)
|
|
||||||
|
|
||||||
# Check if process failed immediately
|
|
||||||
poll_result = process.poll()
|
|
||||||
if poll_result is not None and poll_result != 0:
|
|
||||||
_, stderr = process.communicate(timeout=5)
|
|
||||||
return jsonify({
|
|
||||||
'success': False,
|
|
||||||
'error': f'Backup failed to start: {stderr.decode() if stderr else "Unknown error"}',
|
|
||||||
'command': ' '.join(cmd)
|
|
||||||
}), 500
|
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'success': True,
|
'success': True,
|
||||||
'message': f'Backup task started for {vm_type.upper()} {vmid}',
|
'message': f'Backup task started for {vm_type.upper()} {vmid}',
|
||||||
@@ -5703,8 +5691,6 @@ def api_create_backup(vmid):
|
|||||||
'notes': notes
|
'notes': notes
|
||||||
})
|
})
|
||||||
|
|
||||||
except subprocess.TimeoutExpired:
|
|
||||||
return jsonify({'error': 'Backup command timed out'}), 500
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({'error': str(e)}), 500
|
return jsonify({'error': str(e)}), 500
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user