Problem
Manual pg_dump works and creates a backup.
The built-in aaPanel cron job shows:
Error: Database backup failed! - False
Then confusingly ends with:
Successful
and no file is created.
Root Cause
In panel_backup_v2.py, function pgsql_backup_database, the backup directory for each database is only created when storage_type != "db".
For a full database backup storage_type == "db", so the folder does not exist and the shell redirection to .../db_name/file.sql.gz fails.
Fix I Applied
I changed the condition so the folder is always created.
Before:
db_backup_dir = os.path.join(pgsql_backup_dir, db_name)
if not os.path.exists(db_backup_dir) and storage_type != "db":
After:
db_backup_dir = os.path.join(pgsql_backup_dir, db_name)
if not os.path.exists(db_backup_dir):
Result
After this change the aaPanel cron backup runs successfully and the file appears under the expected path.
As a temporary workaround, creating the directory manually also works:
mkdir -p /www/backup/database/pgsql/crontab_backup/<DB_NAME>