WordPress Site Hacked? How to Restore a Clean Backup Without Reinfecting It

WordPress Site Hacked? How to Restore a Clean Backup Without Reinfecting It
Jim Austin
Jim Austin Content Writer/ Senior Partnerships Engineer
Updated
17.11.2026 General
1 15min.

A hacked WordPress website does not always look hacked. Your homepage may load normally while visitors are redirected to suspicious websites. An unfamiliar administrator account might appear in your dashboard. Or your hosting provider may suspend the site after detecting malware.

When this happens, restoring the latest backup seems like the fastest way to get everything working again.

But restoring a hacked WordPress site without removing the original security weakness can lead to reinfection. Worse, the backup itself might contain malicious files if it was created after the attacker gained access.

The safest recovery process involves more than clicking Restore. You need to preserve evidence, identify the intrusion, choose a trustworthy backup, secure the environment, and verify that the infection is gone before reopening the website.

This guide explains how to do that in seven steps, including what to check if you run WooCommerce.

How to Tell If Your WordPress Site Has Been Hacked

Some WordPress infections are obvious. Others remain hidden for weeks, especially when attackers want to steal information, inject spam pages, or maintain access without attracting attention.

Common warning signs include:

  • Unexpected redirects: Visitors are sent to gambling, phishing, or unrelated websites.
  • Unknown administrator accounts: New users appear with administrator privileges without your approval.
  • Suspicious files: Unfamiliar PHP files show up in wp-content/uploads, plugin directories, or the website root.
  • Browser security warnings: Chrome or other browsers display malware or deceptive-site warnings.
  • Search result changes: Google shows spam pages, unfamiliar titles, or content you never published.
  • Hosting alerts: Your provider reports suspicious processes, excessive resource usage, or malicious files.
  • Unusual website behavior: Pages change unexpectedly, emails are sent without authorization, or plugins reactivate themselves.

Not every symptom proves that your website has been compromised. A failed update can also produce server errors, and legitimate plugins occasionally create unfamiliar files.

However, several warning signs appearing together warrant immediate investigation.

Check the Security Issues section in Google Search Console and review your hosting provider’s security notifications. These can help you understand whether malicious activity has already been detected.

If you suspect a server-level vulnerability, investigate the hosting environment as well as WordPress itself. For example, Patchstack’s October 2026 PHP security alert describes attack indicators associated with critical vulnerabilities in PHP.

Step 1: Preserve a Copy of the Infected Website

Before deleting suspicious files or restoring an older backup, preserve a snapshot of the current website.

This might seem counterintuitive. Why save a copy of something you already know is compromised?

Because the infected version may contain information that helps you understand the attack.

It can preserve:

  • Modified files and potentially malicious scripts.
  • Database changes, including unauthorized accounts.
  • Evidence of when the attacker became active.
  • Posts, orders, or customer records created after your last clean backup.

For a WooCommerce store, that final point is especially important. Restoring an older database can remove legitimate orders placed after the selected restore point.

Ideally, ask your hosting provider or security specialist to create a filesystem and database snapshot, along with copies of relevant server logs.

Keep the infected snapshot isolated. Label it clearly, restrict access, and never confuse it with a clean restore point.

Do not use the infected snapshot to restore a live website without a thorough cleanup.

If customer information may have been exposed, preserve the evidence needed to determine whether incident reporting or notification obligations apply.

Step 2: Contain the Attack and Secure Access

Once you have preserved the necessary evidence, focus on preventing further damage.

If the site is serving malware or redirecting visitors, ask your hosting provider to restrict public access. A maintenance page can help, but it is not sufficient if the attacker retains server access or can bypass WordPress.

Next, review every way someone can access your website.

Access point Recommended action
WordPress administrators Disable unauthorized accounts and reset credentials
Hosting control panel Change passwords and review active sessions
SFTP and SSH Rotate credentials and remove unknown keys
Database Replace potentially exposed credentials
WordPress authentication salts Generate new keys to invalidate sessions
API integrations Revoke and replace exposed tokens
Hosting and CDN accounts Review users, access permissions, and security settings

Make these changes from a trusted device. If your computer has malware that captures passwords, newly created credentials may be compromised immediately.

For WordPress, the authentication keys and salts are defined in wp-config.php. Replacing them invalidates existing WordPress login sessions.

If you change the database user’s password, remember to update the corresponding credentials in wp-config.php as well.

These initial changes help contain the incident, but they are not necessarily permanent. If you later restore an older database, some WordPress password hashes and access settings may revert to their previous state.

Plan a final credential rotation after the clean restore is complete.

Step 3: Find a Backup From Before the Infection

Choosing the right backup is one of the most important parts of WordPress malware recovery.

The newest backup is not automatically the safest.

Imagine your website was compromised on October 10, but the first visible warning appeared on October 25. A backup created on October 24 may still contain the attacker’s files.

Restoring it would simply bring the infection back.

How to estimate when the hack started

Look for evidence that helps establish a timeline:

  • Creation dates of unfamiliar administrator accounts.
  • Unexplained modifications to WordPress core, theme, or plugin files.
  • Suspicious access-log entries and server errors.
  • Dates when unknown files first appeared.
  • Unexpected changes to database content.
  • Security alerts from your hosting provider or monitoring tools.

File modification timestamps can offer useful clues, but they are not definitive evidence. Attackers may manipulate timestamps, and legitimate updates can change thousands of files at once.

If possible, compare several restore points in an isolated staging environment.

Choose the most recent backup that you have reasonable evidence was created before the compromise. If none can be trusted, consider rebuilding WordPress from verified software packages and recovering clean content selectively.

Why backup retention matters

An infection discovered weeks after the initial intrusion requires older recovery points.

For example, BackupWP currently offers the following backup retention periods:

BackupWP plan Retention Backup schedule
Free 7 days See current plan details
Starter 30 days Daily
Professional 90 days Twice daily
WooCommerce 365 days Real-time backups

Longer retention provides more opportunities to find a copy from before the attack, although it does not guarantee that any particular backup is clean.

Backup frequency and retention solve different problems. Frequent backups reduce potential data loss, while longer retention helps you recover from incidents that went unnoticed.

Our guide on how often to back up your WordPress site explains how to choose a schedule based on website activity and recovery requirements.

Step 4: Remove the Vulnerability Before Restoring

A clean backup will not protect your site if you restore it into the same vulnerable environment.

Suppose an outdated plugin allowed the attacker to upload malicious files. Restoring yesterday’s backup might remove the files, but if the same vulnerable plugin is restored and left exposed, the attacker can exploit it again.

The same principle applies to compromised hosting credentials, malicious server configuration, or unpatched PHP vulnerabilities.

Before reopening the website, determine how the attacker may have gained access and address the underlying problem.

Depending on the incident, this could involve:

  • Patching the hosting environment and PHP installation.
  • Replacing vulnerable or abandoned plugins.
  • Updating WordPress core and themes.
  • Removing unauthorized accounts and credentials.
  • Reviewing file permissions and server configuration.
  • Rebuilding the website on a clean hosting environment.

A fresh server or clean hosting account is often preferable when you cannot establish the integrity of the original environment.

Do not assume that updating plugins after restoring an old backup is sufficient. If malicious code can execute during restoration, the website may be compromised again before updates are completed.

Instead, prepare a secure recovery environment, replace vulnerable software with trusted versions, and keep the site inaccessible to the public while you work.

Step 5: Restore the Clean Backup in a Secure Environment

Once you have selected a suitable restore point and prepared the environment, you can begin restoring the website.

Whenever possible, use a staging environment or a clean server rather than immediately overwriting the compromised production website.

A complete WordPress restoration generally requires two components:

  1. Website files: WordPress core, themes, plugins, uploads, and configuration files.
  2. Database: Posts, pages, users, settings, metadata, and other information WordPress needs to operate.

Restoring only one component may leave the website incomplete or inconsistent.

Our guide to restoring WordPress from a backup explains the available methods, including manual restoration and backup plugins.

Restore files and database together

Ensure that the files and database belong to a compatible restore point.

If you restore database content from one date and plugin files from another, you may encounter missing data, broken functionality, or incompatible database structures.

For complicated recoveries, replacing WordPress core and plugins with freshly downloaded, verified copies can be safer than trusting every executable file in an old archive.

Avoid copying unverified PHP files back into the new environment.

Apply updates before making the site public

After restoring, check that WordPress core, plugins, themes, and the underlying server software are secure and compatible.

Remove unused extensions rather than merely deactivating them.

Once the environment is verified, rotate credentials again, review administrator permissions, and regenerate WordPress authentication salts.

At this stage, the goal is not simply to make the website load. It is to ensure that the restored installation no longer provides the attacker with the same access.

Step 6: Check for Malware and Hidden Backdoors

A successful restore does not automatically mean the website is clean.

Some malicious files can exist outside the directories included in your backup. Other infections may persist in database content, scheduled tasks, server configuration, or external accounts.

Before reopening the website, work through the following checklist.

What to inspect What to look for
WordPress users Unknown administrators or unexpected privilege changes
wp-config.php Suspicious code, unfamiliar includes, or altered credentials
.htaccess and server rules Unauthorized redirects or unusual access rules
wp-content/uploads Unexpected executable files, particularly PHP scripts
wp-content/mu-plugins Unrecognized automatically loaded plugins
Plugins and themes Modified files, abandoned software, or suspicious additions
WordPress database Injected scripts, spam links, and unexpected options
Scheduled tasks Cron jobs that recreate malicious files
Server directories Backdoors outside the normal WordPress installation
CDN and DNS settings Unauthorized routing, redirects, or configuration changes

Pay special attention to the database

Not all WordPress malware is stored in PHP files.

Attackers can inject JavaScript into posts, widgets, theme settings, or database options. These changes may survive a file-only cleanup.

A database backup is therefore essential for recovery, but restoring a compromised database can also bring malicious content back.

For a closer explanation of what WordPress stores in its database and how to preserve it, see our guide to backing up a WordPress database safely.

Compare backup versions

When several restore points are available, file comparisons can help identify unexpected changes.

BackupWP’s Professional and WooCommerce plans include a File Diff Viewer, which allows users to examine differences between backup versions.

This can make suspicious additions or modifications easier to investigate, particularly when the website contains thousands of files.

However, file comparisons are investigative aids rather than malware detection guarantees. A malicious file that existed in every retained backup may not appear as a recent change.

For serious incidents, use professional malware scanning and independent security checks before declaring the environment clean.

Step 7: Reopen the Website and Monitor for Reinfection

Once the restored site has passed your checks, you can prepare to return it to normal operation.

Before disabling maintenance mode, test essential functionality:

  • Administrator and customer login.
  • Contact forms and transactional emails.
  • Internal navigation and redirects.
  • Plugin functionality and scheduled tasks.
  • Checkout and payment processing, if applicable.
  • Important pages and database-driven content.

After reopening, monitor security logs, file changes, and unexpected account activity.

Pay particular attention to repeated suspicious requests or files that reappear after deletion. These may indicate a remaining backdoor or an unresolved vulnerability.

What if Google flagged your website?

Open Google Search Console and navigate to the Security Issues report.

If Google identified malware, phishing, or another security problem, follow its instructions for resolving the issue and requesting a review.

Only submit the request after the problem has been addressed across the affected website.

Keep in mind that a successful cleanup does not necessarily remove browser warnings or restore search visibility immediately.

What if your hosting provider suspended the account?

Contact your provider and ask what evidence is required before the site can be reinstated.

Depending on the host, this may include confirmation that malicious files were removed, vulnerable software was updated, and compromised credentials were replaced.