Fix backup file moving to handle compressed database backups

- Check for .sql.gz files first, then fallback to .sql
- Also move .backup.json metadata files alongside compressed backups
- Maintains backward compatibility with legacy .sql backups
This commit is contained in:
usmannasir
2025-10-15 00:56:45 +05:00
parent 7864ef63c1
commit 32db00d1ae

View File

@@ -2457,8 +2457,17 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
## This login can be further improved later.
logging.CyberCPLogFileWriter.writeToFile('Failed to create database backup for %s. This could be false positive, moving on.' % (dbName))
command = f'mv /home/cyberpanel/{dbName}.sql {CPHomeStorage}/{dbName}.sql'
ProcessUtilities.executioner(command)
# Move database backup (check for both .sql.gz and .sql)
if os.path.exists(f'/home/cyberpanel/{dbName}.sql.gz'):
command = f'mv /home/cyberpanel/{dbName}.sql.gz {CPHomeStorage}/{dbName}.sql.gz'
ProcessUtilities.executioner(command)
# Also move metadata file if it exists
if os.path.exists(f'/home/cyberpanel/{dbName}.backup.json'):
command = f'mv /home/cyberpanel/{dbName}.backup.json {CPHomeStorage}/{dbName}.backup.json'
ProcessUtilities.executioner(command)
elif os.path.exists(f'/home/cyberpanel/{dbName}.sql'):
command = f'mv /home/cyberpanel/{dbName}.sql {CPHomeStorage}/{dbName}.sql'
ProcessUtilities.executioner(command)
##