如何恢复WordPress备份?升级后数据丢失,如何回滚至旧版本?
Hey there, I’ve dealt with this exact WordPress rollback headache a few times, so let’s walk through this step by step to get your site back to its pre-upgrade state.
1. First, Diagnose Why cPanel Backup Restore Failed
Before jumping into manual recovery, let’s figure out why the automated restore didn’t work—this prevents repeat issues:
- Check backup integrity: Download your cPanel full backup to your local machine, then try extracting it with a tool like 7-Zip or WinRAR. If you get corruption errors, the backup itself was broken (maybe a partial backup due to server timeouts). Check if cPanel has older backups available.
- Verify server disk space: Head to cPanel’s Disk Usage tool—if your server is low on space, the restore process will fail mid-way. Clear unused files or upgrade your plan if needed.
- Check file permissions: Sometimes incorrect permissions on your
public_htmlfolder block the restore. In cPanel’s File Manager, right-clickpublic_htmland set permissions to755(folders) and644for files.
2. Manual Recovery of cPanel Backup (Since Automated Failed)
cPanel’s automated restore can be finicky, so manual recovery is more reliable. Split this into two parts: files and database.
2.1 Restore Website Files
- First, safeguard your current (broken) site: In cPanel File Manager, navigate to
public_html, select all files/folders, click Compress to create a backup zip—this lets you revert if something goes wrong. - Delete all existing files in
public_html(keep the zip backup you just created, though). - Download your cPanel full backup locally, extract it, and locate the
public_htmlfolder inside the backup. - Upload all contents of this backup’s
public_htmlto your server’spublic_htmldirectory. Use FTP (like FileZilla) for large files—it’s more stable than cPanel’s built-in uploader. - After uploading, double-check permissions: Set folders to
755, files to644, andwp-config.phpto600for extra security.
2.2 Restore Database
- Log into cPanel’s
phpMyAdmintool. - Locate your WordPress database (you can find its name in
wp-config.phpunder theDB_NAMEvariable). - Backup the current broken database: Select the database, click Export to save a copy locally—just in case.
- Delete all tables in the current database, or delete the database entirely and create a new one with the same name (make sure the database user has full privileges, which you can check in cPanel’s MySQL Databases tool).
- From your extracted cPanel backup, find the database backup file (usually a
.sqlor.sql.gzfile in themysqlfolder, named after your database). - In phpMyAdmin, select the empty database, click Import, choose the backup file, and click Go. Wait for the import to finish (large databases may take a few minutes).
- Confirm
wp-config.phphas the correct database credentials (DB_NAME,DB_USER,DB_PASSWORD,DB_HOST)—match these to the ones in cPanel’s MySQL Databases tool.
3. Roll Back to the Old WordPress Version
If your restored backup already includes the pre-upgrade WordPress core, you’re done here. But if you accidentally re-upgraded after restoring, follow these steps:
- Download the exact WordPress version you had before the failed upgrade from the official WordPress old version archive (access this via WordPress’s official resources).
- Extract the zip file locally, then delete the
wp-contentfolder inside the extracted files—this avoids overwriting your restored themes, plugins, and media. - Upload the remaining files/folders (
wp-admin,wp-includes, and all root.phpfiles exceptwp-config.php) to your server’spublic_htmldirectory, overwriting the existing files. - Log into your WordPress admin dashboard, confirm the version is correct, then disable all plugins and re-enable them one by one to catch any compatibility issues with the old core version.
4. Prevent This From Happening Again
- Double backup before upgrades: Always take both a cPanel full backup AND a WordPress-specific backup (using a plugin like UpdraftPlus) before touching core versions.
- Test upgrades in a staging environment: Most hosting providers offer staging sites—clone your live site there, test the upgrade, and fix any issues before applying to production.
- Disable plugins pre-upgrade: Plugins are the #1 cause of upgrade failures. Disable all plugins, run the upgrade, then re-enable them one by one.
内容的提问来源于stack exchange,提问作者Manar S. Bedor
相关产品推荐
相关产品推荐

