Issue
I'm trying to restore a database that has already been uploaded to my server using the cPanel API. I followed the documentation provided at href="https://api.docs.cpanel.net/openapi/cpanel/operation/restore_databases/" rel="nofollow noreferrer">cPanel API - Restore Databases to implement this functionality.
According to the documentation, the backup
parameter should be formatted as follows:
backup=home/user/user_db1.sql.gz
In my case, the path to the backup file is:
backup=home2/user5/dbbk.sql.gz
However, when I attempt to restore the database using this path, I receive the following error message:
{"metadata":{},"messages":null,"status":0,"warnings":null,"errors":["The system could not locate the file: dbbk.sql.gz"]}
I've also tried the following variations of the path, but the error persists:
/mnt/home2/user5/dbbk.sql.gz
user5/dbbk.sql.gz
dbbk.sql.gz
It seems like the API is not recognizing the path to the backup file correctly. Has anyone encountered a similar issue or have suggestions on how to correctly specify the path to the backup file for restoration using the cPanel API?
Solution
I think you send your request in wrong way.
Unfortunately cPanel docs are very confusing and many users have problem with that. in your case it use wrong examples.
for backup path you must start the path with /
and also send your request in multipart/form-data
schema.
try this curl request:
curl --location 'https://example.com:2083/cpsessxxx/execute/Backup/restore_databases' \ --header 'Authorization: Basic xxx' \ --form 'backup="/home2/user5/dbbk.sql.gz"' \ --form 'timeout="0"' \ --form 'verbose="0"'
repalce
example.com:2083/cpsessxxx
with your real server urlreplace
Basic xxx
with your base64 encoded username:pass
Answered By - Mahdi Akrami Answer Checked By - Clifford M. (WPSolving Volunteer)