Restoring a single file
You can restore a single file from backup without rolling back your entire site. The guide covers finding the file in cPanel backups, extracting it to a safe staging location first, and moving it live only after verification. It also covers restoring database content like WordPress posts when the missing item lives in your database rather than on disk.
You can restore a single file without rolling back the whole site. In cPanel, either use File and Directory Restoration if it is present, or pull the file out of a backup tarball and upload it to a staging folder first. If the missing content is in your database, import only the rows you need into a temporary database with phpMyAdmin, then copy the item into production.
This picks up from you already having access to cPanel for your site or Virtualizor for your VPS, and at least one backup you can access.
Before you start
- Decide what you are putting back. A theme file, image or plugin PHP file lives on disk. A WordPress page or post lives in the database.
- Know where your site files live. On cPanel hosting that is under
public_html/by default. - Have a backup you can get to. For cPanel that might be the Backup or Backup Wizard downloads in your account, or a full cPanel backup tarball you downloaded earlier. For a VPS that might be Virtualizor rescue access to the disk.
- Keep a way back. Before you overwrite anything, make a copy of the current live file in cPanel File Manager. If you delete in File Manager, use its Trash instead of permanent delete so you can restore.
- Risks to avoid:
- cPanel File and Directory Restoration restores in place and overwrites whatever is there. Restoring the wrong date or path can break the live site immediately.
- Importing an SQL dump straight into the production database can drop and recreate tables if the export included those statements. Always import to a temporary database or table first.
- Virtualizor’s VM restore replaces the entire VPS. Use Rescue Mode if you only need one file.
- Extracting to the wrong directory can expose sensitive files or leave the site unchanged. Stage into an empty, clearly named folder first.
Step 1: Identify what you actually need to restore
Be clear on file path and name, or which database record you need.
- Files you might restore from disk:
wp-config.php, a theme template inwp-content/themes/, a plugin file inwp-content/plugins/, an image inwp-content/uploads/. - Content you restore from the database: WordPress pages and posts. These live in the wp_posts table, with related data in wp_postmeta.
If you are not sure which you are missing, check the site’s error messages and your application’s dashboard. For WordPress, a 404 or missing page in the admin likely means database. A fatal PHP error naming a file means disk.
Step 2: Build your safety net
Before you touch backups, safeguard the current state. This gives you a quick undo.
- In cPanel, open File Manager and browse to the live file’s folder.
- Select the live file. Click Copy or Rename. Make a copy with a date tag, for example
filename.php.bak-2026-09-23, in the same folder or in a folder you create calledbackups-do-not-delete. - If the file is missing and you deleted it in File Manager very recently, click the Trash icon in File Manager, locate the file and click Restore to put it back to its original path. Undo: if restoring from Trash did not help, delete the restored copy and continue with the steps below.
Step 3: Choose your route
Pick one path based on what you see in cPanel and how cautious you want to be.
- cPanel File and Directory Restoration: quickest, restores one file or folder in place by date. Only present if your provider enabled it. Use when you intend to overwrite the live file now and you know the exact path and date you need.
- Stage from a backup tarball: safest when you want to review first. Download a backup, extract locally, then upload the specific file into a non-live folder in cPanel and compare before replacing the live file.
Step 4: Restore one file with cPanel File and Directory Restoration (if available)
This interface restores directly to the original path and overwrites any existing file at that path.
- Log in to cPanel for your hosting account.
- Look for File and Directory Restoration. If you do not see it, go to Step 5.
- Browse to the path or enter it. Select the file you want.
- Pick the backup date that contains the version you need. Check dates carefully.
- Click Restore. cPanel will restore that file in place.
Undo: if the result is not what you wanted, either restore the file again from a different date or put your .bak-YYYY-MM-DD copy back by renaming it to the original name.
Step 5: Restore from a cPanel backup tarball into a safe folder, then swap it in
If the File and Directory Restoration screen is not present, or you prefer to review the file before touching live, use this route.
- In cPanel, open Backup or Backup Wizard.
- If you see a Home Directory backup available, download it.
- If you only have a Full Account Backup, download the
.tar.gzfile to your computer. Do not try to restore a full backup through the cPanel interface to get one file. You will extract it locally.
- Extract the
.tar.gzon your computer. Then open the extractedhomedirfolder and find your file underhomedir/public_html/(or the correct subdirectory for your application). Keep the extracted file ready. - Back in cPanel File Manager, create a staging folder that is not part of your live site. A clear choice is
public_html/restore-test/. - Click Upload and upload the extracted file into
public_html/restore-test/. - Verify the content. In File Manager, use View or the Code Editor to check the file’s contents are what you expect. If you uploaded an archive instead, select it and click Extract into the staging folder. Multiple hosts recommend extracting into an empty folder first to avoid mixing files from different versions.
- Compare to the live file. If needed, open both in File Manager’s editor to confirm differences.
- When you are confident, put it live:
- In File Manager, go to the live folder that contains the file.
- Confirm your
.bak-YYYY-MM-DDcopy of the current file exists from Step 2. - Go to
public_html/restore-test/. Select the verified file. Click Move or Copy, and set the destination path to the live folder. Agree to overwrite when asked.
Undo: if the site behaves worse or this was not the right version, rename your .bak-YYYY-MM-DD copy back to the original filename to roll back instantly.
Step 6: Restore a single WordPress page or post from a database backup
Pages and posts are rows in the database, not files on disk. Restoring them needs care so you do not overwrite other content.
- Export a safety copy of the live table:
- Open phpMyAdmin in cPanel and select your site’s database.
- Open the wp_posts table. Click Export, choose a quick export to SQL and download it. Do the same for wp_postmeta. This gives you a fast way to undo accidental changes.
- Create somewhere safe to import the backup:
- In cPanel, open MySQL Databases and create a new, temporary database and a temporary user. Grant that user all privileges on the temporary database.
- Open phpMyAdmin and select the new temporary database.
- Click Import and upload the SQL backup that contains the content you need. This should be a copy taken from before the page or post was deleted or changed.
- Find the rows you need:
- In the temporary database, open the wp_posts table. If your site uses a different prefix, adjust accordingly.
- Use the Search tab to find the post by ID, title or slug (post_name). Note the post’s ID.
- Open wp_postmeta and filter by post_id to gather the related metadata rows.
- Export only the rows you want:
- In wp_posts, tick the checkbox for the row you want, scroll to the bottom and choose Export from the With selected drop-down. Use the Custom export if offered and avoid including destructive statements such as DROP TABLE or CREATE TABLE.
- Repeat for the matching rows in wp_postmeta.
- Import those rows into the live database:
- In phpMyAdmin, switch to the live database, open wp_posts and click Import. Upload the SQL containing the single post row.
- Then open wp_postmeta and import the SQL for the related metadata rows.
- If the post ID you are importing already exists in live, consider changing the ID in the exported SQL before importing, or delete the clashing row first. Be careful and rely on the safety export from step 1 if you need to undo.
- Check the site:
- Load the page on the front end and in the WordPress dashboard. If you use any caching, clear it in your application.
Undo: if you imported the wrong thing, open wp_posts and wp_postmeta in phpMyAdmin, sort by ID or date and delete the rows you added. If in doubt, import the safety export from step 1 back into live to restore the previous state of those tables.
Step 7: On a Hostworld VPS, recover a single file using Virtualizor Rescue Mode
If your site runs on a VPS you manage, do not restore the whole VM to get one file back. Use Virtualizor Rescue Mode to mount the disk and copy out what you need.
- From the Hostworld client area at portal.hostworld.uk, open your VPS in Virtualizor.
- Enable Rescue Mode. Virtualizor will boot the VPS into a temporary rescue OS and let you mount the original disk. This is available for KVM and Xen types.
- Connect to the Rescue console and mount the original disk. Copy the required file to a safe location or download it to your workstation.
- Exit Rescue Mode and boot the VPS normally.
- Upload or copy the file into a non-live folder first on the VPS, verify it, then replace the live file. Keep a copy of the current live file before you overwrite.
Undo: if replacing the live file causes problems, put your .bak-YYYY-MM-DD copy back in place. Only consider a VM-level restore in Virtualizor when you truly want to revert the whole server to an earlier point.
Step 8: Test and clean up
- Load the affected page and any related pages. Check common actions like forms or logins if they relate to the file you restored.
- Leave the
.bak-YYYY-MM-DDfile for a day or two until you are confident. Then delete it in File Manager to tidy up. - Remove the
public_html/restore-test/folder when finished. Use File Manager’s Trash so you can restore it for a short time if needed.
What next
If you are on a VPS and you want to understand more recovery options, see our VPS guides. If you are choosing a virtual server for projects that need file-level recovery options, read about our UK location at Linux VPS.
If you would like us to look at a restore for you, please open a support ticket. Tell us the domain, the exact file path or the database row you need, and the most likely backup date.
Next step: schedule a quick restore test so you know where your backups are and how to pull out one file or one row again.
Common questions
Will restoring a single file in cPanel affect the rest of my site?
No, when you use File and Directory Restoration you choose a specific file or directory. Only that path is restored. The risk is that it overwrites what is currently there immediately, so make a .bak copy first in File Manager for a quick rollback.
I do not see File and Directory Restoration in cPanel. Can I still get one file back?
Yes. Download a Home Directory or Full Account backup, extract it locally, locate the file under homedir/public_html/, upload it into a staging folder in File Manager, verify it, then move it over the live file. Full cPanel backups cannot be restored via the cPanel user interface, so you extract locally and take only the file you need.
Can I import an SQL backup straight into my live database to get a page back?
Do not do that. SQL exports often include DROP TABLE and CREATE TABLE statements that will drop and recreate tables during import, which destroys newer data. Import the backup into a temporary database first, export only the rows you need from wp_posts and wp_postmeta, then import those rows into the live database.
My site runs on a Hostworld VPS. Should I use the Virtualizor restore feature for one file?
No. Virtualizor’s restore rolls the entire VM back to the chosen backup and replaces its current state. Use Rescue Mode instead to mount the disk and copy out the single file you need without touching the rest of the server.
I tried the wrong file version. How do I undo?
Rename your .bak-YYYY-MM-DD copy back to the original filename in File Manager. If you used File and Directory Restoration, run it again and pick a different backup date. For database changes, delete the imported rows in phpMyAdmin and, if needed, import the safety export you took before changing anything.
If you need help at any point, please open a support ticket so we can assist you against your account.