Deleted a File by Mistake? How to Get It Back from File Manager Trash or a Backup

Deleted a file by mistake? Don't panic, and don't start uploading replacements yet. Depending on how the file was deleted, you can often get it back in a minute from cPanel File Manager's Trash, and if not, from one of your automatic backups. This guide explains how to restore a deleted file from File Manager Trash or a backup, how to tell which applies to you, and how to avoid losing files in the future.

First: how was the file deleted?

Where you should look depends on how the file disappeared:

How it was deletedWhere to get it back
cPanel File Manager, using Delete (normal)File Manager Trash -- see below. Fastest option.
File Manager with Skip the trash and permanently delete the files tickedA JetBackup 5 backup only
An FTP program such as FileZilla or WinSCPA JetBackup 5 backup only
The command line (rm over SSH or in Terminal)A JetBackup 5 backup only
WordPress (Media Library, deleting a plugin or theme)A JetBackup 5 backup, or a WP Toolkit backup if you made one
File Manager's Empty TrashA JetBackup 5 backup only
Overwritten, not deleted (you uploaded or saved over it)A JetBackup 5 backup only -- the Trash doesn't keep old versions of files

Only File Manager uses the Trash. Everything else deletes files immediately and permanently, and the only way back is a backup.

Act quickly. The Trash keeps files until it's emptied, but backups roll over: we keep the last 7, taken three times a week, so about two weeks of history. A file deleted three weeks ago is no longer in any backup.

How deleting works in cPanel File Manager

When you select files in Files > File Manager and click Delete, a confirmation window opens listing what will be removed. It has one important checkbox:

  • Unticked (the default): clicking Confirm moves the files to the Trash. They disappear from their folder, but you can restore them.
  • Ticked -- Skip the trash and permanently delete the files: the files are deleted straight away. File Manager can't bring them back.

Leave that box unticked unless you're certain, for example when clearing out a large backup archive you've already downloaded.

Behind the scenes, the Trash is a hidden folder called .trash in your home directory (/home/username/.trash). File Manager keeps track of where each file came from so it can put it back.

How to restore a file from File Manager Trash

  1. Log in to cPanel (from the client area: Services > My Services, choose your plan, then Log in to cPanel).
  2. Go to Files > File Manager.
  3. Click View Trash in the toolbar at the top. The file list now shows what's in the Trash.
  4. Find the file or folder you want. If there are a lot of items, sort by the Last Modified column or use the search box.
  5. Click the item once to select it (hold Ctrl, or Command on a Mac, to select several).
  6. Click Restore in the toolbar, then confirm.
  7. The item is moved back to the folder it was deleted from. Open that folder and check it's there.

If you deleted a whole folder, restore the folder itself rather than individual files inside it -- that puts everything back in its original structure in one step.

Before restoring, check whether a new file with the same name has since been created in the original folder (for example, if you already re-uploaded a replacement). If so, rename or move the new one first so the two don't clash, then compare them once the original is back.

After restoring

  • Load the affected page of your website in a private browser window.
  • If the page is cached, clear your browser cache and purge LiteSpeed Cache if you use it.
  • If the restored file gives a "403 Forbidden" error, check its permissions are 644 (files) or 755 (folders).

The Trash uses your disk space

Files in the Trash haven't really gone anywhere, so they still count towards your account's disk space. If you delete a large backup zip to free up room and your disk usage doesn't drop, it's sitting in the Trash.

To free the space for good:

  1. In File Manager, click View Trash.
  2. Check there's nothing in it you might still need.
  3. Click Empty Trash and confirm.

Emptying the Trash is permanent. If you only want to get rid of certain items, restore anything you want to keep first, then empty it.

If you use SSH, you can see how much space the Trash is using with du -sh ~/.trash.

How to get a file back from a backup (JetBackup 5)

If the file isn't in the Trash, restore it from our automatic backups. You can do this yourself in cPanel under Files > JetBackup 5, choosing just the file or folder you need rather than restoring the whole account. Our separate guide walks through every step: How to Restore a File or Folder with JetBackup 5.

A few things to keep in mind when you choose a backup:

  • Pick a date when the file existed. That means a backup taken after the file was created or last changed, and before it was deleted.
  • Files that lived only between two backups can't be recovered. If you created a file on Monday and deleted it on Tuesday, and no backup ran in between, it was never backed up.
  • Restoring a single file doesn't affect anything else. The rest of your site stays exactly as it is now.
  • If you're not sure of the date, download the file from JetBackup first and compare it with what you expect before restoring it to your live site.

When it isn't really a file

Some things that look like files are actually stored in your database:

  • WordPress posts and pages -- check Posts > Trash or Pages > Trash in WordPress first. WordPress keeps trashed items for 30 days by default.
  • WordPress settings, menus, orders and form entries -- these live in the database. Restoring the database from an earlier date brings them back, but also undoes every change made since. See the database restore guide below.
  • Email messages -- look in the mailbox's own Trash or Deleted Items folder in webmail first, then see the email restore guide below.

How to avoid losing files in the future

  • Leave "Skip the trash" unticked in File Manager unless you really mean it.
  • Rename instead of deleting when you're not sure. Renaming old-page.html to old-page.html.bak takes it off your site but keeps it one click away.
  • Copy before you edit. Before changing .htaccess, wp-config.php or a theme file, use File Manager's Copy to make a duplicate, or download it.
  • Make a backup before big changes. In WP Toolkit (Domains > WordPress Management) you can back up a WordPress site in a few clicks before updates or redesigns.
  • Keep your own copy. Our backups cover about two weeks. Download a full copy of your site now and then and keep it on your computer or cloud storage.
  • Be careful with FTP and SSH. There's no Trash there. In FileZilla, check which side of the window you're working on before pressing Delete. On the command line, run pwd and ls before any rm.
  • Empty the Trash deliberately, not as a habit -- it's your safety net.

Troubleshooting

View Trash is empty

The file wasn't deleted through File Manager's Trash -- it was removed by FTP, SSH, WordPress, a plugin, with "Skip the trash" ticked, or the Trash has been emptied. Restore it from JetBackup 5 instead.

The file isn't in any backup

Either it was created and deleted between backups, or it was deleted more than about two weeks ago. Check any copies you have yourself: your computer, the original download, your web designer, or an email attachment. Unfortunately a file that's in neither the Trash nor a backup can't be recovered from the server.

My disk is still full after deleting files

The deleted files are in the Trash. Click View Trash, then Empty Trash. Disk usage figures in cPanel can take a little while to update.

Restore put the file back but the site is still broken

Other files may have been deleted at the same time. Check the Trash for anything else from the same folder and time, and look at the site's error_log for "No such file or directory" messages naming what's still missing.

Common questions

How long do files stay in the Trash?

Until you empty it. That's why it's worth checking the Trash now and then -- it can quietly fill up your disk space.

Can support restore a file for me?

Yes, if it's in a backup -- open a ticket with the full path of the file and roughly when it was deleted. But restoring it yourself with JetBackup 5 is usually quicker.

Can I see the .trash folder directly?

It's a hidden folder in your home directory. You can show it in File Manager by turning on hidden files, but use View Trash and Restore rather than moving files out by hand, so they go back to the right place.

Related guides

Still stuck? Open a support ticket and the Instant Access Internet Services team will help.

Ultrafast LiteSpeed hosting from InstantAccess.net: free SSL, free backups, cPanel included, no contracts. Check out our $10/month hosting.
  • restore deleted file cpanel, cpanel file manager trash, view trash restore cpanel, skip the trash permanently delete, recover deleted website file, empty trash disk space cpanel, jetbackup restore deleted file
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Show Hidden Files (.htaccess) in cPanel File Manager

If you are looking for your .htaccess file and it isn't there, it's almost certainly just hidden....

How to Use cPanel File Manager to Manage Your Website Files

cPanel File Manager lets you work with your website files right in your web browser -- no FTP...

How to Edit a File in cPanel File Manager

Instant Access Internet Services customers can edit a file in cPanel File Manager right in the...

How to Upload and Extract a ZIP File in cPanel

The fastest way to put a whole website or a folder full of files on yInstant Access Internet...

How to Compress and Download a Folder in cPanel

cPanel File Manager can download single files, but not whole folders. The trick is to compress...