
Discovering your WordPress site has been hacked is terrifying. Your heart races, panic sets in, and you’re not sure where to start. This comprehensive guide walks you through recovering from a WordPress hack using your backups, hardening your site to prevent reinfection, and getting back online quickly and safely.
Signs Your WordPress Site Has Been Hacked
Before diving into recovery, confirm you’ve actually been hacked. Common indicators include:
Visual Defacement: Your homepage shows unfamiliar content, messages, or images. Hackers often deface sites to demonstrate their breach.
Malicious Redirects: Visitors report being redirected to spammy websites, pharmaceutical ads, or phishing pages. You might not see redirects yourself (hackers often target only external visitors or search engines).
Google Security Warnings: Google Chrome displays “Deceptive Site Ahead” or “This site may harm your computer” warnings. Google Search Console reports security issues.
Spam Content: Your site suddenly has pages or posts about pharmaceuticals, gambling, or adult content—topics completely unrelated to your site.
Admin Lockout: You can’t log in with your usual credentials. Hackers sometimes change admin passwords to maintain exclusive access.
Unexpected Files: FTP or file manager shows unfamiliar PHP files, especially in uploads directory or root folder.
Database Anomalies: Unknown admin users appear in user lists. Posts or pages you didn’t create show up.
Performance Degradation: Site loads extremely slowly. Server CPU usage spikes. This often indicates cryptocurrency miners or spam bots.
Email Spam: Your hosting provider contacts you about spam being sent from your server.
If you experience any of these symptoms, assume you’ve been compromised and begin recovery immediately.
Immediate Actions: Don’t Panic
When you discover a hack, your first impulse might be to start deleting files or frantically changing passwords. Stop. Take a breath. Follow these immediate steps:
1. Document Everything: Take screenshots of everything abnormal. Capture defacement messages, error messages, unfamiliar files, and suspicious database entries. This documentation helps with forensics, insurance claims, and learning how the breach occurred.
2. Take the Site Offline: Enable WordPress maintenance mode or use your hosting control panel to temporarily disable the site. This prevents further damage, stops malware distribution to visitors, and eliminates liability for serving malicious content. Use a simple maintenance page: “We’re performing scheduled maintenance and will be back shortly.”
3. Notify Your Host: Contact your hosting provider immediately. They can isolate your account to prevent the infection from spreading to other customers, provide server access logs, help identify the attack vector, and sometimes offer security assistance.
4. Don’t Make Changes Yet: Resist the urge to delete files or modify the database before analyzing what happened. Premature changes can: – Destroy forensic evidence – Make identifying the infection source impossible – Accidentally delete legitimate files – Complicate recovery
5. Assemble Your Response Team: Contact your developer, security consultant, or support team. Coordinate recovery efforts.
6. Check Backup Availability: Verify you have backups and can access them. This determines your recovery strategy.
Identifying When Your Site Was Hacked
To restore from a clean backup, you must identify when the infection occurred. Here’s how:
Check File Modification Dates: Use FTP or file manager to sort files by modification date. Look for recently modified core WordPress files, which should rarely change. Suspicious files modified recently might indicate infection timeframe.
Review Server Access Logs: Hosting control panel access logs show when suspicious activity occurred. Look for: – Unusual POST requests to xmlrpc.php – Multiple login attempts – Access to unexpected files – Requests from suspicious IP addresses
Examine Database Recent Changes: Check wp_posts for spam content creation dates. Review wp_users for unauthorized admin accounts and their registration dates.
Google Search Console: If Google flagged your site, check when they first detected the issue. Infection occurred before that date.
Backup Comparison: Download several backups spanning different dates. Check each for infected files. The earliest infected backup helps pinpoint infection timing.
Common Patterns: – Infection often occurs within 48 hours of outdated plugin vulnerability disclosure – Many hacks happen immediately after failed login attempts spike – Infections frequently coincide with theme or plugin updates (compromised updates)
Once you identify the infection date, select a backup from before that time.
Choosing the Right Backup for Restoration
With the infection date identified, select the appropriate backup:
Ideal Backup Characteristics: – Created before infection date (with safety margin) – Recent enough to minimize data loss – Complete and verified (not corrupted) – Accessible and downloadable
Backup Selection Strategy:
Scenario 1: Infection Identified Within 24 Hours Choose yesterday’s backup. Data loss is minimal (typically less than 24 hours).
Scenario 2: Infection Occurred Days Ago Choose the most recent backup before infection. Accept that newer posts, comments, or orders might be lost.
Scenario 3: Uncertain Infection Timeline Start with a backup from 1 week ago. Test it thoroughly. If still infected, go back another week. Continue until you find a clean backup.
Verification: Before committing to restoration, scan the backup for infections. Download the backup and run it through a malware scanner locally or on a staging environment.
Pre-Restore Security Measures
Before restoring, harden your security to prevent immediate reinfection:
Change All Passwords: Update every password associated with your site: – WordPress admin accounts (all users) – Database password (update wp-config.php after change) – FTP/SFTP passwords – Hosting control panel password – Cloud storage passwords (if backups stored there)
Use unique, complex passwords generated by a password manager. 16+ characters, mixed case, numbers, symbols.
Update Database Credentials: After changing the database password, update wp-config.php with the new credentials before restoring. Otherwise, the restored site can’t connect to the database.
Check Hosting Account: Examine your hosting account for: – Unauthorized email accounts – Suspicious cron jobs – Unknown FTP users – Compromised SSH keys
Delete anything suspicious.
Review User Accounts: Before restoring, check your database for unauthorized admin accounts. Note their usernames so you can delete them post-restore if they reappear.
Prepare Security Plugins: Have security plugins ready to install immediately after restoration: Wordfence, Sucuri Security, iThemes Security.
Step-by-Step Restore Process
Now execute the restoration:
Step 1: Create Fresh Server Environment (Recommended) If possible, restore to a clean server environment instead of the infected one. This ensures no residual malware remains. Ask your host to: – Create a fresh server instance – Provision a clean database – Configure DNS to point to the new server after verification
Step 2: Download Clean Backup Download your verified clean backup from cloud storage or local archives.
Step 3: Restore Files – Extract backup files to a secure local directory – Review file structure for anything suspicious – Upload files to your server via SFTP – Set correct file permissions (755 for directories, 644 for files)
Step 4: Restore Database – Create a fresh database (or empty the existing one completely) – Import the backup database SQL file via phpMyAdmin or command line – Verify database import completed without errors
Step 5: Update wp-config.php – Ensure database credentials match your new/changed database password – Update database host if changed – Regenerate authentication keys and salts using https://api.wordpress.org/secret-key/1.1/salt/
Step 6: Verify Site Functionality – Test site loading – Verify admin login works – Check a few posts and pages – Test forms and critical functionality
Step 7: Delete All Admin Users Except Yours – Go to Users > All Users – Delete any suspicious admin accounts identified earlier – Verify legitimate team members still have appropriate access
Step 8: Install Security Plugins Immediately install and configure: – Wordfence Security (malware scanner, firewall) – iThemes Security or Solid Security (hardening features) – Limit Login Attempts (brute force protection)
Step 9: Scan for Residual Infection Run a complete malware scan with Wordfence or Sucuri. If any infections are detected, clean them immediately.
Step 10: Update Everything – Update WordPress core to latest version – Update all plugins to latest versions – Update theme to latest version – Delete unused themes and plugins
Step 11: Harden Security – Disable file editing in WordPress admin (add to wp-config: define(‘DISALLOW_FILE_EDIT’, true);) – Change database table prefix if still using default wp_ – Enable two-factor authentication on admin accounts – Implement strong firewall rules – Hide WordPress version information
Step 12: Test Thoroughly – Browse site extensively – Test all forms and functionality – Verify no security warnings from Google – Check all plugins and features work correctly
Post-Restore Security Hardening Checklist
After successful restoration, implement comprehensive security hardening:
WordPress Security: – [ ] Force SSL for admin (FORCE_SSL_ADMIN in wp-config.php) – [ ] Disable XML-RPC if not needed (common attack vector) – [ ] Change wp-login.php URL using security plugin – [ ] Disable directory browsing (.htaccess rule) – [ ] Remove WordPress version from source – [ ] Disable theme/plugin editor in admin
User Management: – [ ] Enforce strong password policy – [ ] Enable two-factor authentication for all admins – [ ] Remove unused user accounts – [ ] Audit user capabilities (minimum necessary privileges) – [ ] Monitor new user registrations (disable if not needed)
File Security: – [ ] Set correct file permissions (755 directories, 644 files, 600 for wp-config.php) – [ ] Move wp-config.php one level above web root (optional) – [ ] Protect wp-config.php with .htaccess rules – [ ] Disable PHP execution in uploads directory – [ ] Monitor file changes with security plugin
Database Security: – [ ] Change database password – [ ] Use unique database user (not root) – [ ] Grant minimum necessary database privileges – [ ] Change table prefix from default wp_ – [ ] Backup database regularly
Server Security: – [ ] Enable firewall at hosting level – [ ] Disable unnecessary services – [ ] Keep server software updated (PHP, MySQL, etc.) – [ ] Implement SSH key authentication (disable password auth) – [ ] Configure fail2ban or similar intrusion prevention
Monitoring and Maintenance: – [ ] Enable security plugin scanning (daily) – [ ] Configure uptime monitoring – [ ] Set up Google Search Console monitoring – [ ] Enable email alerts for security events – [ ] Schedule weekly security reviews
Backup Strategy: – [ ] Implement automated daily backups – [ ] Verify backups complete successfully – [ ] Store backups offsite (cloud storage) – [ ] Test restore quarterly – [ ] Maintain 30+ days retention
What To Do If All Backups Are Infected
If you discover all available backups contain malware, you have two options:
Option 1: Manual Malware Removal – Use security plugins (Wordfence, Sucuri) to scan and identify infections – Follow plugin removal instructions carefully – Manually delete infected files – Clean infected database entries – This is time-consuming and requires technical expertise
Option 2: Clean WordPress Reinstall – Export content (posts, pages, products) from infected site – Install fresh WordPress – Install clean theme and plugins – Import content – Manually verify imported content is clean – This loses custom configurations but ensures cleanliness
Option 3: Professional Security Services If you’re uncomfortable with manual cleanup, hire professional security services: – Sucuri Security ($199-499 one-time cleanup) – Wordfence Premium Support – Specialist WordPress security companies
Professional cleaners have specialized tools and experience removing persistent infections.
Preventing Reinfection
Cleaning the infection isn’t enough. Prevent future attacks:
Identify the Attack Vector: How did hackers get in? – Outdated plugin vulnerability? – Weak password brute-forced? – Compromised hosting account? – Infected local development machine?
Identifying how they got in prevents repeat attacks. Check server logs, review recently updated plugins, and analyze access patterns.
Close the Vulnerability: – If outdated plugin: Update immediately and enable auto-updates – If weak passwords: Enforce strong passwords and 2FA – If compromised hosting: Change all credentials and enable additional security – If infected local machine: Clean your computer before connecting again
Implement Security Layers: – Web Application Firewall (Cloudflare, Sucuri WAF) – Security plugin with active threat defense – File integrity monitoring – Login attempt limiting – Regular security audits
Maintain Vigilance: – Monitor security notifications weekly – Review user accounts monthly – Audit installed plugins quarterly – Test backups quarterly – Update everything promptly
Security isn’t a one-time task. It’s an ongoing process.
Notifying Users and Stakeholders
After recovery, communicate transparently:
Required Notifications: – Users if passwords were compromised (recommend password change) – Customers if payment information was at risk – Team members about new security procedures
Recommended Notifications: – General audience about temporary service disruption – Business partners about potential email spoofing risk – Search engines to remove security warnings (Google Search Console)
Communication Template: “We recently experienced a security incident affecting our website. We’ve restored service from clean backups and implemented enhanced security measures. As a precaution, we recommend changing your password. No evidence suggests [specific data] was accessed, but we’re notifying you out of transparency. Questions? Contact [support email].”
Transparency builds trust. Attempting to hide the breach damages reputation more than honest communication.
Legal and Compliance Considerations
Depending on your jurisdiction and industry, you may have legal obligations:
GDPR (EU): If personal data may have been accessed, you must report to supervisory authority within 72 hours.
HIPAA (Healthcare): Healthcare providers must report breaches affecting protected health information.
State Breach Notification Laws (US): Many states require notifying affected individuals of data breaches.
PCI-DSS (Payment Cards): Merchants must report compromises to payment brands and acquiring bank.
Consult legal counsel to understand your obligations. Documentation from initial discovery helps demonstrate compliance.
When to Hire Professional Help
Consider professional security services if: – You’re uncomfortable with technical recovery steps – Multiple restoration attempts failed – Reinfection keeps occurring – You need forensic analysis – Compliance requires professional assessment – Your business can’t afford additional downtime
Professional services typically cost $200-$2,000 depending on infection severity. Compare this to lost revenue, reputation damage, and your time value.
Creating an Incident Response Plan
Prevent panic during future incidents with a documented plan:
Incident Response Plan Components: 1. Identification procedures (how to confirm a breach) 2. Immediate response steps (who to contact, what to do first) 3. Recovery procedures (detailed restoration steps) 4. Communication templates (users, customers, authorities) 5. Contact information (host, developer, security pro, legal counsel) 6. Post-incident review process (learning from each incident)
Store this document in multiple locations (password manager, printed copy, team shared drive). When crisis strikes, you’ll have clear guidance instead of panicked guessing.
Conclusion
WordPress hack recovery using backups is straightforward when you have clean backups, take methodical steps, and implement proper post-recovery hardening. The keys are:
- Don’t panic—methodically document and respond
- Identify when infection occurred
- Restore from a clean backup before that date
- Harden security comprehensively
- Prevent reinfection by closing the attack vector
Your backups are your safety net. Regular, tested backups transform devastating hacks into manageable recovery projects. If you don’t have comprehensive backups yet, implement them today—before you need them.
External Links
- WordPress Hacked – Official Guide
- Malware Removal Steps
- Sucuri Hack Recovery Guide
- Google Search Console Security Issues
- OWASP WordPress Security
Call to Action
Don’t wait until you’re hacked! Backup Copilot Pro creates clean recovery points with automated schedules and cloud storage. Recover from any disaster in minutes, not days. Protect your site now!

