本文档专注于备份 WordPress 站点的文件部分,区别于数据库备份。它解释了文件备份的范围、重要性,并提供了多种备份方法,包括使用 FTP 程序、主机提供的软件和同步工具。
无具体代码示例,文档主要提供操作步骤。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.
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:
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.
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.