Home / Fix guides / Website security

How to remove exposed backup files from a web server

Delete the backup files from your public web folder, move future backups somewhere that is not reachable by web address, and change any passwords the backups contained. Then test the old file addresses to confirm they now return an error.

A backup file is a copy of your website or database, such as backup.zip, db.sql or wp-config.php.bak. When one of these sits inside the folder your web server publishes, anyone who guesses or finds the address can download it. No hacking is needed, just a web browser.

What the problem looks like

You usually do not see it as a visitor. The site works normally. The problem is a file sitting in the public folder (often called public_html, httpdocs, www or wwwroot) that should not be there.

Common examples:

  • Full site archives: backup.zip, site.tar.gz, public_html.zip, www.zip
  • Database dumps: db.sql, database.sql, dump.sql
  • Renamed config or code files: wp-config.php.bak, wp-config.php.old, config.php~, index.php.orig
  • Editor leftovers: .swp files or copies with -copy or a date in the name

They usually appear after someone makes a quick copy before an update, runs a manual export and forgets it, or a backup plugin or hosting tool writes into a folder that is reachable from the web.

Why it matters

The risk is bigger than the file name suggests. A site archive contains your source code and often your configuration. A database dump can contain customer names, emails, order details and password hashes. A renamed config file such as wp-config.php.bak is the worst case: the web server no longer treats it as PHP, so it sends the raw text, including database passwords and secret keys.

For a business this means:

  • Security: attackers and automated bots routinely request common backup names on every site they find.
  • Privacy and trust: if customer data leaks, you may have legal duties to report it, and customers lose confidence.
  • Search: a large archive that gets crawled and indexed can show up in search results, and it wastes crawl attention.
  • Cost: large files downloaded repeatedly can use up your bandwidth.

How to check if your site has it

These free checks take a few minutes.

  1. Look at your files. Log in to your hosting control panel or SFTP and open the public folder. Sort by file type or size and look for archives, .sql files and anything ending in .bak, .old, .orig, .save or ~. Turn on hidden files if your tool has that option.
  2. Try the likely addresses. In a browser, try https://yourdomain.com/backup.zip, /db.sql, /wp-config.php.bak and similar. A download starting or text appearing means it is exposed. A 403 or 404 page is what you want.
  3. Use the command line if you are comfortable. Run curl -I https://yourdomain.com/backup.zip. A first line showing a 200 status (for example HTTP/1.1 200 OK or HTTP/2 200) with a large Content-Length means the file is public. Be aware that some sites show a friendly error page but still answer 200, so open the file or check the size if in doubt.
  4. Search engines. Searching site:yourdomain.com ext:zip OR ext:sql OR ext:bak shows files that have already been indexed. No results does not prove you are safe.
  5. Check for folder listings. If a folder shows a plain list of files when you open it in a browser, everything inside is easy to find. See directory listing enabled.

How to fix it

Do these in order. The order matters.

  1. Download a copy for yourself if you still need it, then delete the file from the public folder. Deleting is the real fix.
  2. Treat the contents as leaked. If the file held a database or config, change the database password, update it in your site config, and replace secret keys or API keys. In WordPress, also reset admin passwords and regenerate the salts in wp-config.php. Check your access logs if you can to see whether the file was downloaded.
  3. Move backups out of the web root. Store them in a folder above the public folder, in off-site storage, or with your host's backup tool.
  4. Add a safety net that blocks risky file types. This does not replace deleting, but it protects you if a file slips through later.

On Apache (in .htaccess or the site config), a rule like this denies those extensions:

<FilesMatch "\.(bak|old|orig|save|sql|swp)$">
  Require all denied
</FilesMatch>

On nginx, add this inside the server block and reload nginx:

location ~* \.(bak|old|orig|save|sql|swp)$ {
  deny all;
}

Be careful about blocking .zip or .gz across the whole site, because you may offer legitimate downloads. Which Apache version you have affects the syntax, so check with your host if the rule causes an error.

Common platforms

  • WordPress: use your host's file manager or SFTP and check wp-content and the site root. Some backup plugins write archives into a folder under wp-content (UpdraftPlus uses wp-content/updraft by default), so check your plugin's storage setting and send backups to remote storage instead. Step by step: WordPress guide.
  • cPanel: open File Manager, choose the public_html folder, enable Show Hidden Files in Settings, and delete the leftovers. Backups made with cPanel's own tool normally go to your home folder, which is not public. Step by step: cPanel guide.
  • Plesk: open Files and look in httpdocs. Menu names vary by version.
  • IIS: the web root is often under C:\inetpub\wwwroot, but yours may differ. Request Filtering can deny file extensions.
  • SiteGround: the File Manager is usually under Site Tools, in the Site section.

If your host runs the web server for you, ask their support to confirm nothing else is exposed.

How to confirm the fix worked

Repeat the checks above. Request each old address in a private browser window and confirm you get a 403 or 404, not a download. Run curl -I again for the same addresses. If the file was indexed by a search engine, the result will drop out after the page is recrawled. You can speed this up with the removal tools in Google Search Console, if you have it set up.

Also confirm the new password or key works and the site still loads, since changing credentials can break a site if one place was missed.

How to stop it coming back

  • Never create backups or test copies inside the public folder. Use a name and place that is not web reachable.
  • Do not edit live files by saving copies like index.php.bak. Use staging or version control.
  • Send automated backups to storage outside the site, and check where your backup plugin saves by default.
  • Keep the safety net rule from the fix section in place.
  • Scan regularly. SiteMonday's week 2 OpenVAS security scan looks for this kind of exposure and reports it in a ranked fix list, after you prove you own the site. It finds and explains the problem, and removing the files is up to you or your developer.
  • Related leaks are worth checking at the same time, such as an exposed .git folder.

Step by step for your platform

Questions

Can someone really find my backup file without a link?

Yes. Bots try common names like `backup.zip` and `db.sql` on huge numbers of sites automatically, so an unlinked file is not hidden.

Is renaming the backup file enough?

No. A different name only makes it slightly harder to guess. Delete the file from the public folder or move it out of the web root.

Do I need to change passwords if I delete the file?

If the backup contained a database or a config file, yes. You cannot know whether someone downloaded it earlier, so change the database password and any keys it held.

Are backups made by my hosting company exposed?

Usually not, because host backup tools store copies outside your public folder. The risk comes from archives or dumps you or a plugin saved inside it.

Will blocking file types in .htaccess or nginx fix the problem on its own?

It stops downloads of those types, but the file still sits on the server. Use the block as a safety net and still delete or move the file.

How quickly should I act?

As soon as you find one, because bots may already have it. Remove the file first, then change any credentials it contained.

Related problems