高级管理文档

备份您的 WordPress 文件

💡 云策文档标注

概述

本文档专注于备份 WordPress 站点的文件部分,区别于数据库备份。它解释了文件备份的范围、重要性,并提供了多种备份方法,包括使用 FTP 程序、主机提供的软件和同步工具。

关键要点

  • WordPress 备份包括数据库和文件两部分,本文仅讨论文件备份。
  • 文件备份通常不包含数据库,数据库需单独备份,但导出文件可存储在一起。
  • 需要备份的文件包括 WordPress 核心安装、插件、主题、图像、代码文件、.htaccess 文件等。
  • 重点备份 wp-content 目录(包含用户生成内容)和 wp-config.php 文件(包含连接详情)。
  • 推荐使用 FTP 程序下载文件到本地,或利用主机提供的备份软件。
  • 同步工具如 WinSCP 可帮助保持服务器和本地文件的镜像更新。
  • 备份时可忽略 WordPress 核心文件,因为它们可从官方下载包中替换。

代码示例

无具体代码示例,文档主要提供操作步骤。

注意事项

  • 备份文件时,确保包含所有子目录和 .htaccess 文件。
  • 虽然大多数主机提供服务器备份,但建议用户自行备份文件以增加安全性。
  • 使用同步工具时,注意设置正确的方向(如从主机复制到本地)和同步模式。

📄 原文内容

Backing Up Your WordPress Files

There are two parts to backing up your WordPress site: Database and Files.

This page talks about Files only; if you need to back up your WordPress database, see the Backing Up Your Database.

Does backing up files also back up the database?

Usually no. Your WordPress files live in your WordPress directory on the web server, but the database is stored in a separate database system (typically MySQL/MariaDB) outside the WordPress directory.

If you export your database to a .sql/.gz/.bz2 file, that export file is a file — you can store it alongside your file backups (for example in the same folder or zip) so it stays with the matching file backup. Restoring still requires importing that file back into the database.

Your WordPress site consists of the following files:

  • WordPress Core Installation
  • WordPress Plugins
  • WordPress Themes
  • Images and Files
  • Javascripts, PHP scripts, and other code files
  • Additional Files and Static Web Pages

Everything that has anything to do with the look and feel of your site is in a file somewhere and needs to be backed up. Additionally, you must back up all of your files in your WordPress directory (including subdirectories) and your .htaccess file.

While most hosts back up the entire server, including your site, it is better that you back up your own files. The easiest method is to use an FTP program to download all of your WordPress files from your host to your local computer.

By default, the files in the directory called wp-content are your own user-generated content, such as edited themes, new plugins, and uploaded files. Pay particular attention to backing up this area, along with your wp-config.php, which contains your connection details.

The remaining files are mostly the WordPress Core files, which are supplied by the WordPress download zip file.

Please read Backing Up Your WordPress Site for further information.

Other ways to backup your files include:

Website Host Provided Backup Software

Most website hosts provide software to back up your site. Check with your host to find out what services and programs they provide.

Create Syncs With Your Site

WinSCP and other programs allow you to synchronize with your website to keep a mirror copy of the content on your server and hard drive updated. It saves time and makes sure you have the latest files in both places.

Synchronize your files in WinScp

  1. Log in to your ftp server normally using WinScp.
  2. Press the “Synchronize” button. Remote directory will automatically be set to the current ftp directory (often your root directory). Local directory would be set to the local directory as it was when you pressed Synchronize. You may want to change this to some other directory on your computer. Direction should be set to “local” to copy files FROM your web host TO your machine. Synchronization Mode would be set to Synchronize files.
  3. Click “OK” to show a summary of actions.
  4. Click “OK” again to complete the synchronization.

Copy Your Files to Your Desktop

Using FTP Clients or UNIX Shell Skills you can copy the files to a folder on your computer. Once there, you can zip or compress them into a zip file to save space, allowing you to keep several versions.

Normally, there would be no need to copy the WordPress core files, as you can replace them from a fresh download of the WordPress zip file. The important files to back up would be your wp-config.php file, which contains your settings and your wp-content directory (plus its contents) which contains all your theme and plugin files.