How to back up a hacked WordPress site before you clean it
Copy the infected files and database to an isolated, read-only location before you delete or overwrite anything, so you can find the backdoor and prove what was injected. Do this before running a scanner or restoring a clean backup.
Key takeaways
- Copy the infected files and database to an isolated, read-only location before you delete or overwrite anything, so you can find the backdoor and prove what was injected.
- A scanner only removes what it recognises; the backdoor that re-infects the site is usually not in its list.
- Without the copy, you cannot tell a clean restore from a restore that still carries the backdoor.
Why you back up before you clean
A scanner only removes what it recognises; the backdoor that re-infects the site is usually not in its list. The forensic copy is your evidence: it shows which files were added, when, and what the attacker changed in the database. Without the copy, you cannot tell a clean restore from a restore that still carries the backdoor. The copy also protects you if the host or a plugin wipes files during cleanup.
Isolate the site before you copy anything
Put the site in maintenance mode or take it offline so visitors and the attacker stop touching files while you work. Block the attacker's IP at the host firewall or .htaccess if you can identify it from the logs. Disable auto-updates and any third-party plugin that writes to the filesystem during the copy. Do not log in from a machine that may be compromised; use a clean device and a fresh session.
Copy the files to an isolated, read-only location
Download the full site (wp-content, wp-includes, wp-admin, and root files) as a single archive from the host file manager or via SFTP. Check the site's total size in the host's file manager or disk-usage report, then make sure the destination has enough free space for the archive plus a safety margin. Keep the archive name and timestamp so you can match it to the host's file-change logs.
Snapshot the database before you touch it
Export the full database (all tables, not just options) using phpMyAdmin, the host's database tool, or wp-cli. Save the SQL dump to the same isolated, read-only location as the file archive.

Use the copy to find the backdoor
Search the database dump for injected rows in options, posts, and users (e.g. unexpected redirects, admin accounts, or encoded payloads). Check the file timestamps in the archive against the host's access logs to narrow when the backdoor was placed. Record every suspicious file and row in a plain list; this is the scope you hand to a fixer or use to verify your own cleanup. For a deeper walkthrough of locating the injected code, see How to find the backdoor in a hacked WordPress site.
What the free tools and paid services actually cover
WordPress.com provides active protection against hacks and spam, including backups and malware removal, on every paid plan [1], but that applies to WordPress.com-hosted sites, not a self-hosted install. SiteMedic Rescue Toolkit is a free WordPress.org plugin for diagnostics, but it runs on the live site and does not create an isolated forensic copy. Managed hosting and maintenance services vary in what they include; verify whether your specific plan covers a forensic backup step before relying on it. A free malware scanner on the live site only finds known signatures; the backdoor that causes re-infection is typically custom and not in any signature list.
Harden against re-infection after cleanup
Change every password (admin, database, FTP, host panel) and rotate any API keys or secrets stored in the site. Remove or replace the vulnerable plugin or theme that was the entry point; go to the plugin's official WordPress.org page and check for a security update, or remove the plugin if no update exists. Enable two-factor authentication on all admin accounts and restrict wp-login.php by IP if feasible. Set up a scheduled, isolated backup (files and database) so the next incident starts with a clean copy, not a forensic scramble. For the full cleanup sequence, see How to recover a hacked WordPress site in 7 steps. The WordPress Hack Recovery Guide pack bundles these steps into a checklist you can follow during an incident.
Frequently asked questions
Why should I back up a hacked site before cleaning it?
You back it up so you can find the backdoor and prove what was injected.
Sources
Related on this site
- How to recover a hacked WordPress site in 7 steps
- How to clean a hacked WordPress database
- How to check if your WordPress site is hacked before you pay an agency
- Website hack downtime cost calculator – free calculator
This article was drafted with AI assistance and checked before publication.
Free calculator: Website hack downtime cost calculator
The full guide: WordPress Hack Recovery Checklist
