Alines Webマガジン

wp configphpbackup

📅 November 6, 2026📖 Verified Publication

Key Takeaways: Securing and Managing wp-config.php Backups

  • Criticality: The wp-config.php file contains your database credentials and security salts; losing it means losing access to your entire WordPress site.
  • The Golden Rule: Never store backups of this file in a publicly accessible directory (e.g., /wp-content/backups/).
  • Best Practice: Use automated off-site backups and version control, rather than manual file copies like wp-config.php.bak.
  • Security Risk: Leaving wp-config.php.old or wp-config.php.bak on your server is a major security vulnerability that attackers scan for.

Why is wp-config.php Backup Management So Critical?

In the WordPress ecosystem, wp-config.php is the heart of your installation. It defines your database name, username, password, host, and the unique authentication keys used to encrypt user cookies. When a server migration goes wrong, a plugin update fails, or a developer accidentally overwrites the file, your site goes offline immediately.

However, the act of backing up this file often introduces a new problem: misconfigured backup files. Many administrators create manual backups by duplicating the file in the same directory, resulting in files like wp-config.php.bak or wp-config.php.old. These files are not protected by the same server-level security rules as the original file, making them easy targets for hackers.

Comparing Backup Strategies for wp-config.php

Choosing the wrong method can either leave you vulnerable to data loss or expose your database credentials to the public internet.

Method Security Risk Reliability Best For
Manual Copy (wp-config.php.bak) High (Publicly accessible) Low (Manual process) Never recommended
Version Control (Git) Medium (If pushed to public repo) High Developers & Local Dev
Off-site Cloud Backup Low (Encrypted) High Production Environments
Server-Level Snapshot Very Low Very High Full Site Recovery

How to Properly Manage wp-config.php Backups

1. The Right Way to Create a Temporary Backup

If you must create a manual backup before making changes, do not leave it in your root directory. Instead, move it to a directory above your public_html folder so it is not accessible via a web browser.

2. Automating Secure Backups

Use a plugin or a server-side cron job that encrypts the file and transmits it to a secure location like AWS S3, Dropbox, or Google Drive. A secure backup should never exist as a plain text file on your web server for longer than necessary.

3. Post-Migration Checklist

  • [ ] Remove any .bak, .old, or .save files from your root directory.
  • [ ] Verify your wp-config.php permissions are set to 440 or 400.
  • [ ] Confirm that your off-site backup actually contains the latest configuration.
  • [ ] Ensure your wp-config.php is not being indexed by search engines.

Frequently Asked Questions

Q: Is it safe to keep wp-config.php.bak in my WordPress root folder?

A: No. Most web servers are configured to execute .php files but may serve other file extensions as plain text. An attacker can simply navigate to yourdomain.com/wp-config.php.bak and download your database credentials instantly.

Q: How do I recover my site if I lost my wp-config.php file?

A: You have three options: 1. Restore from a full server backup (preferred). 2. Recreate the file manually using your database credentials (found in your hosting control panel). 3. Use a fresh WordPress installation and manually re-enter the database details.

Q: Can I move wp-config.php above the public_html folder?

A: Yes. WordPress allows you to place wp-config.php one directory above your web root. This is a highly recommended security practice as it makes the file physically impossible to access via a URL.