热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何备份您的WordPress网站

ThisarticleispartofaseriescreatedinpartnershipwithSiteGround.Thankyouforsupportingthepartn
How to Backup Your WordPress System

This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible.

本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。

Few people care about backups until it’s too late. The question “do we have backups?” is only raised after a catastrophic loss has occurred. Backups are essential. If you fail to prepare then prepare to fail.

很少有人关心备份,直到为时已晚。 问题“我们有备份吗?” 仅在发生灾难性损失后才提高。 备份至关重要 。 如果准备失败,那就准备失败。

Here are five steps to backup success:

以下是成功备份的五个步骤:

  1. Educate your boss/client

    教育你的老板/客户

    If they understood the technicalities of web development, they wouldn’t need you. Explain the situation in simple monetary terms, e.g. if our server disk crashed today, we could lose everything. It would take M months to rebuild the system at a cost of $X and we could lose $Y in business. A viable backup system would cost $Z to implement and we would be back within N hours. I’m going presume you’ve terrified your boss/client and they’re willing to proceed.

    如果他们了解Web开发的技术,则不需要您。 用简单的货币术语解释这种情况,例如,如果今天我们的服务器磁盘崩溃了,我们可能会损失一切。 重建系统需要M个月的时间,成本为$ X,我们的业务可能会损失$ Y。 一个可行的备份系统的实施成本为$ Z,我们将在N小时内返回。 我假设您吓坏了老板/客户,他们愿意继续。

  2. Identify what you need to backup

    确定您需要备份的内容

    Backing up a WordPress system is a little complex because it depends on specific files and a database. A backup will only be viable if you have up-to-date copies of both.

    备份WordPress系统有点复杂,因为它取决于特定的文件和数据库。 只有同时拥有两个副本,备份才可行。

  3. Implement an appropriate backup solution

    实施适当的备份解决方案

    This will depend on the technologies you’re using and the service you offer. For example, a weekly backup may be suitable for a blog receiving a few updates a month. At worst, you could lose an article or two. A WordPress-powered online shop may need continual backups to ensure customer orders are not be lost.

    这将取决于您使用的技术和所提供的服务。 例如,每周备份可能适合每月接收一些更新的博客。 最糟糕的是,您可能会丢失一两篇文章。 由WordPress驱动的在线商店可能需要连续备份,以确保不会丢失客户订单。

  4. Automate!

    自动化!

    Backups should be taken out of human hands. Consider a system which requires a single click once a day to initiate the backup. You will start with good intentions but it will soon become a chore. What happens when you go on vacation? What if you leave the company? Computers are good at scheduling — let them handle the work.

    备份应该从人手中拿出来。 考虑一个每天需要单击一次以启动备份的系统。 您将以良好的意愿开始,但很快就会成为家务。 你去度假怎么办? 如果你离开公司怎么办? 计算机擅长调度-让它们处理工作。

  5. Verify and test your backup

    验证并测试您的备份

    Your system is only as good as the last successful backup. Ideally, you should automate verification of the backup’s integrity, move backup files off-site, periodically test your restore procedures, and retain previous backups for a reasonable time (three old versions is typical).

    您的系统仅与上次成功备份一样好。 理想情况下,您应该自动验证备份的完整性,将备份文件移到异地,定期测试还原过程,并在合理的时间内保留以前的备份(典型的是三个旧版本)。

You can learn more about backing up your WordPress sites manually and easily in the SitePoint’s course How to Secure Your WordPress Site, which you can preview below. For more on WordPress, check out our comprehensive WordPress course on Building Custom WordPress Themes.

您可以在SitePoint的“ 如何保护WordPress网站”课程中了解有关手动和轻松备份WordPress网站的更多信息,您可以在下面进行预览。 有关WordPress的更多信息,请查看我们有关构建自定义WordPress主题的综合WordPress课程。

Loading the player…
正在加载播放器…

WordPress组件 (WordPress Components)

WordPress components have differing backup requirements.

WordPress组件具有不同的备份要求。

WordPress安装文件 (WordPress Installation Files)

You probably downloaded the WordPress installer in an archive from wordpress.org. It includes the following files and folders:

您可能已从wordpress.org的存档中下载了WordPress安装程序。 它包括以下文件和文件夹:

locationdescription
/root PHP, readme and licence files
/wp-admin/the primary WordPress control panel code
/wp-includes/libraries and third-party components
/wp-content/themes, plugins and media files
位置 描述
/ 根PHP,自述文件和许可证文件
/wp-admin/ 主要的WordPress控制面板代码
/wp-includes/ 库和第三方组件
/wp-content/ 主题,插件和媒体文件

You should never need to backup the default WordPress files. Your code (and third-party plugins) should never modify or add files to /wp-admin/ or /wp-includes/. I recommend retaining a copy of the installer but all versions of WordPress can be downloaded from the release archive. Besides, your installation will eventually receive updates so the live version will be different to the one you downloaded.

您永远不需要备份默认的WordPress文件。 您的代码(和第三方插件)绝对不能修改文件或将文件添加到/wp-admin//wp-includes/ 。 我建议保留安装程序的副本,但是可以从发行档案中下载所有版本的WordPress。 此外,您的安装最终将收到更新,因此实时版本将不同于您下载的版本。

根配置文件 (Root Configuration Files)

Several root folder files must be backed-up:

必须备份几个根文件夹文件:

  • wp-config.php — this contains settings including the database connection strings

    wp-config.php它包含设置,包括数据库连接字符串

  • .htaccess — the server configuration file

    .htaccess服务器配置文件

  • webmaster tool identification files such as googleCODE.html and BingSiteAuth.xml

    网站站长工具标识文件,例如google CODE .htmlBingSiteAuth.xml

  • any other files you’ve added

    您添加的任何其他文件

In general, you can backup these files once after your installation is complete. However, be wary of themes and plugins which make further changes to the configuration.

通常,安装完成后,您可以备份这些文件一次。 但是,请注意主题和插件,它们会进一步更改配置。

wp-content文件 (wp-content files)

The /wp-content/ folder contains all themes, plugins and media assets such as uploaded images. This folder must be backed-up but it will depend on your development process.

/wp-content/文件夹包含所有主题,插件和媒体资产,例如上载的图像。 必须备份此文件夹,但这取决于您的开发过程。

If you are developing your own custom theme and plugins, it’s beneficial to use a source control system such as Git and create a central repository on GitHub, BitBucket or a similar provider. The source is replicated by these services and on all developer machines; it’s difficult to lose anything so a backup of the /wp-content/themes/ and /wp-content/plugins/ folders may not be absolutely necessary.

如果您正在开发自己的自定义主题和插件,则使用诸如Git之类的源代码控制系统并在GitHub , BitBucket或类似的提供程序上创建中央存储库是有益的。 这些服务在所有开发人员机器上复制源。 丢失任何东西/wp-content/themes/困难,因此不一定绝对需要备份/wp-content/themes//wp-content/plugins/文件夹。

However, I suspect most WordPress sites use a combination of third-party themes and plugins with a few custom modifications. In addition, media files are contained in /wp-content/uploads/ or the /wp-content/blogs.dir/ folder on multi-site installations. Therefore, it’s normally easiest to backup everything in the /wp-content/ folder.

但是,我怀疑大多数WordPress网站都结合了第三方主题和带有少量自定义修改的插件。 此外,在多站点安装中,媒体文件包含在/wp-content/uploads//wp-content/blogs.dir/文件夹中。 因此,通常最简单的方法是备份/wp-content/文件夹中的所有/wp-content/

The frequency of backups will depend on your update activities. Once every few days is probably adequate for many sites but it may need to be more often when editors regularly add content and images.

备份的频率将取决于您的更新活动。 每隔几天一次对于许多站点可能就足够了,但是当编辑人员定期添加内容和图像时,可能需要更频繁一些。

WordPress数据库 (The WordPress Database)

The database contains all page content, historic revisions, media references, site configurations, theme options, plugin activations, user accounts and more. It’s imperative to backup the database frequently — perhaps once a day for a general blog or every hour for an ecommerce system.

该数据库包含所有页面内容,历史修订,媒体参考,站点配置,主题选项,插件激活,用户帐户等。 必须经常备份数据库-可能是一般博客每天一次或电子商务系统每小时一次。

Be wary that databases can become huge which slows the backup process.

请注意,数据库可能会变得庞大,从而减慢了备份过程。

手动备份 (Manual Backup)

If you don’t have a backup, do it now! I recommend taking a manual backup every so often even if you’ve implemented an automated system — you can never have too many.

如果您没有备份,请立即执行! 我建议即使已经实施了自动化系统, 也应经常进行一次手动备份- 您永远不能拥有太多备份。

Hosts such as SiteGround provide systems like cPanel which allow you to backup all files, databases and settings. Search for backup or the backup wizard and follow the steps. These generally create a file which can be restored in the same system.

诸如SiteGround之类的主机提供了诸如cPanel之类的系统,该系统使您可以备份所有文件,数据库和设置。 搜索备份备份向导,然后执行以下步骤。 这些通常会创建一个可以在同一系统中还原的文件。

If you prefer a more hands-on approach:

如果您更喜欢动手做方法:

  1. Download the root configuration and /wp-content/ files using FTP, SCP, wget or any other tool you have to hand.

    使用FTP, SCP , wget或您必须使用的任何其他工具下载根配置和/wp-content/文件。

  2. Download a shapshot of the database which contains the SQL commands to recreate tables and populate the data.

    下载包含SQL命令的数据库快照,以重新创建表并填充数据。

Most hosts provide SQL tools such as phpMyAdmin or Adminer or you can install them yourself on any hosting which supports PHP. To log in, you will require:

大多数主机都提供SQL工具,例如phpMyAdmin或Adminer,或者您可以将它们自己安装在任何支持PHP的主机上。 要登录,您将需要:

  • the host name — it’s normally localhost but check the DB_HOST setting in wp-config.php

    主机名-通常是localhost但请检查wp-config.phpDB_HOST设置

  • the database name — see DB_NAME in wp-config.php

    数据库名称-请参阅wp-config.php DB_NAME

  • a database user’s name — see DB_USER in wp-config.php, and

    数据库用户名—请参阅wp-config.php DB_USER ,以及

  • the database user’s password — see DB_PASSWORD in wp-config.php.

    数据库用户的密码-请参阅wp-config.php DB_PASSWORD

You should see many tables such as wp_posts, wp_users and wp_comments once you have connected successfully. (Note the table prefix is set by $table_prefix in wp-config.php and may not always be wp_.)

成功连接后,您应该看到许多表,例如wp_posts , wp_userswp_comments(请注意,表前缀由wp-config.php$table_prefix设置,可能并不总是wp_ 。)

Look for an option such as dump, export or backup. Ensure every table (with drop and create) and all data is selected before downloading the SQL file.

查找诸如转储 , 导出备份之类的选项。 在下载SQL文件之前,请确保已选择每个表(带有drop和create)以及所有数据。

Command line ninjas with SSH access can backup a database using the mysqldump command:

具有SSH访问权限的命令行忍者可以使用mysqldump命令备份数据库:

mysqldump --host=hostname --user=dbuser --password=dbpass --add-drop-table --result-file=backup.sql dbname

where hostname, dbname, dbuser and dbpass are the credentials we specified above. A full backup will be output to the backup.sql file in the current folder which can be downloaded.

其中hostname , dbname , dbuserdbpass是我们上面指定的凭据。 完整备份将输出到当前文件夹中的backup.sql文件中,可以下载该文件。

Restoring your manual backup is matter of uploading the files to the correct location and importing the MySQL data using a SQL tool or the command:

恢复手动备份只需将文件上传到正确的位置,然后使用SQL工具或以下命令导入MySQL数据即可:

mysql --host=hostname --user=dbuser --password=dbpass dbname

All manual backup processes can be automated using tools such as cron which can also be controlled via cPanel.

可以使用诸如cron之类的工具来自动执行所有手动备份过程,这些工具也可以通过cPanel进行控制。

备份插件 (Backup Plugins)

Fortunately, there are dozens of WordPress backup plugins to choose from which can automate your process and export backups to an off-site data store. The most popular include:

幸运的是, 有数十个WordPress备份插件可供选择,它们可以自动执行流程并将备份导出到异地数据存储。 最受欢迎的包括:

喷气背包 (Jetpack)

The closest option to an official plugin, Jetpack provides a range of SEO, security and site management features which include real-time backups to unlimited storage space on the professional paid plan.

官方插件最接近的选项是Jetpack,它提供了一系列SEO,安全性和站点管理功能,其中包括实时备份到专业付费计划中无限的存储空间。

UdraftPlus (UdraftPlus)

One of the highest-ranking backup plugins with more than one million active installations, UdraftPlus schedules and stores backups on remote systems such as Dropbox, Google Drive, OneDrive, Amazon S3, or your own server.

UdraftPlus是级别最高的备份插件之一,具有超过一百万的活动安装,它可以计划备份并将备份存储在Dropbox,Google Drive,OneDrive,Amazon S3或您自己的服务器等远程系统上。

备份WordPress (BackUpWordPress)

A simple plugin which backs up your database and files on a schedule to suit your requirements. The commercial edition enables off-site cloud storage backups.

一个简单的插件,可以根据您的计划备份您的数据库和文件。 商业版支持异地云存储备份。

后退WPup (BackWPup)

The free edition of BackWPup allows you to backup your files and database to a variety of your own and third-party storage spaces. The commercial editon provides scheduling, differential backup and automatic updates.

BackWPup的免费版本使您可以将文件和数据库备份到各种自己的存储空间和第三方存储空间。 商业版本提供调度,差异备份和自动更新。

复印机 (Duplicator)

Duplicator is often used for migration and cloning but also provides manual backup and restore facilities. The commercial edition supports scheduling and cloud backups.

复制器通常用于迁移和克隆,但也提供手动备份和还原功能。 商业版支持计划和云备份。

XCloner (XCloner)

An open source plugin which provides a range of scheduling and cloud storage options.

一个开源插件,提供一系列计划和云存储选项。

备份服务 (Backup Services)

Alternatively, you can choose a third-party service to manage your WordPress backups. Hosts such as SiteGround are the best place to start; they can implement backup options for all hosting plans. SiteGround even has an in-house backup service that automatically saves the latest 30 copies of your site and lets you restore the one you need on demand.

或者,您可以选择第三方服务来管理WordPress备份。 像SiteGround这样的主机是最好的起点。 他们可以为所有托管计划实施备份选项。 SiteGround甚至具有内部备份服务,该服务可自动保存您网站的最新30个副本,并允许您按需还原所需的副本。

Further services include:

其他服务包括:

VaultPress (VaultPress)

VaultPress uses Jetpack to store daily or real-time automated backups off-site as well as scanning for malicious software, spammer attacks and hosting failures. Plans start from $3.50 per month.

VaultPress使用Jetpack在站点外存储每日或实时自动备份,以及扫描恶意软件,垃圾邮件发送者攻击和托管故障。 计划每月3.50美元起。

WP时间胶囊 (WP Time Capsule)

WP Time Capsule takes incremental backups; only changed files and data are backed-up so the process is considerably faster than those which backup everything. An automatic backup is taken prior to every WordPress update. The Lite plan costs nothing for daily backups and 15-day restore points.

WP Time Capsule进行增量备份; 仅备份已更改的文件和数据,因此该过程比备份所有文件和数据的过程要快得多。 在每次WordPress更新之前都会进行一次自动备份。 Lite计划的每日备份和15天还原点不花任何费用。

管理WP (Manage WP)

Manage WP has facilities to help you manage multiple WordPress installations. Premium plans start from $2 per website per month and include an incremental backup which can be scheduled to every hour. Further features include performance monitoring, security checks, analytics and reporting.

Manage WP具有帮助您管理多个WordPress安装的功能。 高级计划的费用为每个网站每月2美元,其中包括可以安排到每小时的增量备份。 其他功能包括性能监视,安全检查,分析和报告。

今天备份! (Backup Today!)

WordPress backups can be more complex than other software but the range of tools, plugins and services simplify the process. If you don’t have a backup procedure, take a snapshot now and investigate the options. Every minute you delay increases the risk of catastrophic failure.

WordPress备份可能比其他软件更复杂,但是一系列工具,插件和服务简化了该过程。 如果没有备份过程,请立即拍摄快照并研究选项。 您延迟的每一分钟都会增加灾难性故障的风险。

翻译自: https://www.sitepoint.com/backup-wordpress-site/




推荐阅读
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 本文讨论了在Windows 8上安装gvim中插件时出现的错误加载问题。作者将EasyMotion插件放在了正确的位置,但加载时却出现了错误。作者提供了下载链接和之前放置插件的位置,并列出了出现的错误信息。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • Android Studio Bumblebee | 2021.1.1(大黄蜂版本使用介绍)
    本文介绍了Android Studio Bumblebee | 2021.1.1(大黄蜂版本)的使用方法和相关知识,包括Gradle的介绍、设备管理器的配置、无线调试、新版本问题等内容。同时还提供了更新版本的下载地址和启动页面截图。 ... [详细]
  • 本文介绍了为什么要使用多进程处理TCP服务端,多进程的好处包括可靠性高和处理大量数据时速度快。然而,多进程不能共享进程空间,因此有一些变量不能共享。文章还提供了使用多进程实现TCP服务端的代码,并对代码进行了详细注释。 ... [详细]
  • 拥抱Android Design Support Library新变化(导航视图、悬浮ActionBar)
    转载请注明明桑AndroidAndroid5.0Loollipop作为Android最重要的版本之一,为我们带来了全新的界面风格和设计语言。看起来很受欢迎࿰ ... [详细]
  • 本文讨论了在openwrt-17.01版本中,mt7628设备上初始化启动时eth0的mac地址总是随机生成的问题。每次随机生成的eth0的mac地址都会写到/sys/class/net/eth0/address目录下,而openwrt-17.01原版的SDK会根据随机生成的eth0的mac地址再生成eth0.1、eth0.2等,生成后的mac地址会保存在/etc/config/network下。 ... [详细]
  • 本文介绍了多因子选股模型在实际中的构建步骤,包括风险源分析、因子筛选和体系构建,并进行了模拟实证回测。在风险源分析中,从宏观、行业、公司和特殊因素四个角度分析了影响资产价格的因素。具体包括宏观经济运行和宏经济政策对证券市场的影响,以及行业类型、行业生命周期和行业政策对股票价格的影响。 ... [详细]
  • 本文介绍了Hyperledger Fabric外部链码构建与运行的相关知识,包括在Hyperledger Fabric 2.0版本之前链码构建和运行的困难性,外部构建模式的实现原理以及外部构建和运行API的使用方法。通过本文的介绍,读者可以了解到如何利用外部构建和运行的方式来实现链码的构建和运行,并且不再受限于特定的语言和部署环境。 ... [详细]
  • 本文介绍了计算机网络的定义和通信流程,包括客户端编译文件、二进制转换、三层路由设备等。同时,还介绍了计算机网络中常用的关键词,如MAC地址和IP地址。 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • Linux如何安装Mongodb的详细步骤和注意事项
    本文介绍了Linux如何安装Mongodb的详细步骤和注意事项,同时介绍了Mongodb的特点和优势。Mongodb是一个开源的数据库,适用于各种规模的企业和各类应用程序。它具有灵活的数据模式和高性能的数据读写操作,能够提高企业的敏捷性和可扩展性。文章还提供了Mongodb的下载安装包地址。 ... [详细]
  • 本文介绍了在Linux下安装和配置Kafka的方法,包括安装JDK、下载和解压Kafka、配置Kafka的参数,以及配置Kafka的日志目录、服务器IP和日志存放路径等。同时还提供了单机配置部署的方法和zookeeper地址和端口的配置。通过实操成功的案例,帮助读者快速完成Kafka的安装和配置。 ... [详细]
author-avatar
badmouse1000001
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有