Unlike any other product of the human activity, you can replicate a program unlimited times; the only breakpoint is the available storage space. Web applications and content management systems are no exception. Given the fact a random incident can waste you days of work, it’s of great importance to know how to backup a website and be able to restore it anytime.
Data Saved Only Once
Is Data You Don’t Care AboutUnknown
Platforms vs Websites
(skip this section if you believe you can tell the difference)
Not everything you see on the web is a website you can backup. In some cases what you see is the page of a blogging platform like wordpress.com, and the infamous blogger.com or a social network platform like Facebook or Twitter. The good news is, you don’t need to keep a backup yourself as an organization or a company is maintaining the platform. They use large arrays of storage devices to store the data in order to keep them safe. The bad news is you don’t actually have control over the platform. You can obtain a copy of your data anytime, yet you can’t physically put your hands on the files of the application. Thus, you’re always dependent on the organization/company which runs the site. But then again, that might be ultra-convenient for someone who doesn’t really care (or need) to have a full-featured site.
The rest of the cases are typically custom websites programmed and designed from scratch or built upon one of the numerous available content management systems like WordPress, Drupal, Joomla, Magento, etc. The modern websites usually implement a number of programming languages and techniques to provide the user with a way to handle the content. In most cases, they use databases to store and manipulate. Databases have a key role in any modern web application.
Typical WordPress Hosting Configuration
In this article, we’ll focus on WordPress as it’s the most popular content management system. The basic requirements for running WordPress are:
- A web server like Apache, Nginx, etc. It’s the system that distributes the files of the installation over the network. It runs on an operating system like Linux, BSD, Windows, etc.
- A relational database like MySQL or MariaDB.
- PHP (a general-purpose that usually stands as a pre-processor of HTML. It is very popular as it allows for complex structural data manipulation).
- A few additional components (like cURL) that provide extra functionality
Sounds a bit complicated? Perhaps, but don’t get frustrated. You only need to collect two “things” to backup a website: the files and a snapshot of the database. The files consist of the content management system itself, the design and functionality elements, and the actual content of the website (media attachments, etc.). The database holds all settings and texts. Both are necessary for keeping a backup of the website. It is important though you keep the copies simultaneously to maintain the consistency of the website.
Like most things in life, you’ve got choices. First, we’ll cover the case of manually keeping a backup of a website and then we’ll check the automatic (aka “blind” way) to do the same thing. For different reasons, both methods can become useful.
How Often Should I Backup My Website?
The more copies you have, the greater the number of restore points will become available. However, the best way to schedule the backups is according to the nature of the project. The recommended frequency varies according to the type of the website and the content update. However, a good practice is to keep long and short term backups. In particular, you can keep a copy every month, every week and in some cases (like when running an e-commerce website) every day. If you are using an automated solution, you can continue working as usual even when the backup process is running in the background. In other cases, you may need to spend a few minutes every time to keep the copies but it really worths every second of it.
Manually Backup A Website (Using The Hosting Panel)
In this case, we’ll review the actions you need to perform to keep and also download copies of the website directly to a local storage device. This way we’ll make sure we have a backup of the website available to restore in another location even in case it has gone offline and you can’t even access the hosting panel and the file manager. This can also work as a first step for migrating the website to another server.
Get the Files
Most hosting plans include access to the main panel where someone can configure the hosting settings. On the panel, you can find a file manager. Look for “Files” or “File Manage and you will be able to review the folders of your account and access the files of the website exactly as if they were on your computer. Additionally, it allows for compressing them into a single package so it’s easier to download and store anywhere.
Depending on the host, you may also grant access to other files like your emails and the configuration of PHP. Make sure you don’t delete any of those files or you will lose important data!
Next, it’s time to make a copy of the files of the website. Locate the public folder (usually titled as “httpdocs” or “public_html”) and compress whatever is in there into a single file. At this point, you need to download this file on your computer. Depending on the number of files included in the archive and the speed of the network, this step may take several minutes but worths waiting. Finally, you will have all the files compressed in a single file on your computer. Consider that, half the job is done.
Get the Database
At this point, all we need to complete the backup is a copy of the database. Let’s go back to the hosting panel, and look for “Databases”; this is the point where we can review/change/add/remove databases. Depending on the type of the hosting panel you may be able to download a copy with a single click or you may need to use phpMyAdmin or a similar program usually installed next to Apache servers for managing databases. Advanced users may as well use the command line for similar tasks.
The first way is as easy as downloading any file from the internet. Just hit the download button and the browser will start downloading the file. Depending on the size of the database you’ll need between a few seconds up to several minutes but eventually, the file will land on your computer. The second way is a bit more complicated; it requires performing a couple of commands but provides you with more information regarding the contents of the database (optional).
By the time you have a copy of the files and a copy of the database on your computer, there is nothing left to do. You can rebuild the website exactly as it was at the moment you created the backup. Note that, the ideal location for keeping the archives are somewhere else but the “container”, the place the website is stored.
Certain hosting panels (like SiteGround) have a dedicated tool for keeping backups. This is convenient if you’re in a hurry and you still need to backup your website manually. What you get is a copy of the database and the files compressed into a single file. Typically, this option is best for when you need to migrate into another server, physical location or domain; you may have to perform a few additional actions though to get the site back into a working condition.
How Do I Restore A Back-Up?
As long as you have a copy of the files and the database you can restore the website to a previous state within a few moments.
- First, you need to upload the files of the installation on the public folder. Using a .zip will significantly decrease the uploading time. Make sure you have removed the remaining content of the folder and then extract the package. Again, you can do that with the hosting panel’s file manager. After a few moments, the original files of the installation should be there.
- Next, go to the hosting panel’s database administration. You need to delete the current database and upload the copy you kept before. You only need to make sure you have assigned the same user with the same privileges. Advanced users can also use phpMyAdmin (we mentioned before) to perform a similar task. Instead of removing the database, you can clear all existing data and import the data from the backup. This inner structure and the actual data, that can be copied between existing databases is usually called SQL dump. That’s because the “image” resembles a “printing” of the visualization of the information (!) that is included in the database.
Additionally, some hosting panels offer a complete website backup/restore option. It will do the job, but usually, they include in the archive more things like emails and settings files you may not need to get your hands on at a particular time.
The key concept behind restoring a backup is to maintain consistency between the files and the database. That means you should always backup/restore the backup archives simultaneously or at least very close together. Else, the integrity of the website may be compromised.
While manual backup is a great solution for a few websites, it might become a burden if you’re maintaining a lot of them. WordPress based websites are so stable, you may keep them running with the exact configuration for years. Eventually, you may come to a point where you may need to manage tens or hundreds of websites. Assuming you have more than ten websites up and running, a manual backup will become a time-spending procedure. Furthermore, keeping track of all installations will be more complicated as they are growing in number.
Thankfully, we can find several solutions for adding an automatic backup to your website. Depending on the project, you can select between free and premium solutions. However, the basic idea behind automatic backups is to have them performed unattended on a given schedule. Whatever solution you choose, you will need to select a destination for the backup files. This can be a folder on the hosting platform, your computer and most likely, in a convenient cloud storage service. Google Drive is probably the most popular one as it’s full-featured and provides plenty of space (15Gb) with a simple sign up. Additionally, it has great uptime (almost 100%).
Our Favorite WordPress Backup Plugins
One solution we have tried and found really convenient is UpdraftPlus. Needless to say, is one of the most popular backup solutions for WordPress. UpdraftPlus provides a simple and straightforward way to schedule and monitor your backups. Furthermore, it allows for selecting between a variety of storage locations. The pro version provides numerous extra features like Multisite and WP-CLI support, package encryption and more. With UpdraftPlus, you don’t need to worry again for your website(s) and focus on creating content or develop new ones.
Another solution you can trust is BackWPup. With a simple but intuitive design, it allows for scheduling and storing backups in numerous locations. Like UpdraftPlus, it has a premium version with extra functionality but you can always start with the free version and upgrade when your project has scaled to the point you need more options.
Other popular solutions: WordPress Backup and Migrate Plugin, All-In-One WP Migration, Duplicator – WordPress Migration plugin. For a greater list, you can search the WordPress plugin repository using the term “backup“.
One Last Question; How Long Should I Keep The Backup Archives?
As long as possible. Keeping only the most recent archives is not exactly the safest method. There have been cases where it wasn’t clear when a problem first appeared and that made harder to identify what caused it in the first place. In other cases, the problem was there for long but none had seen it or even worst, none reported it. Eventually, you may need to restore an older backup to go back to a point where the backup was working great. Also, you may need to use a plugin or a version of the theme that was installed much earlier and probably requires some extra time to locate it on the author’s website. That’s why keeping those archives is really important.
I understand keeping backup files may become slightly cost-effective if you are using online storage but you can always download them on your computer and store them in a hard disk. Given the fact mechanical hard disks are now cheaper than ever, we don’t have any excuses for not keeping our archives stored for as long as we need them.
How to backup a website in a few words:
- You can either manually keep the copies or use a plugin
- Backup frequency depends on the project
- You need to copy the files and the database
- Keep the copies simultaneously or at least very close
- The back-up should be available for restore anytime