There is no doubt that backing up the site and the data hosted on the site is one of the most important issues that the project owner must resolve in the first place and at the very beginning of the journey. And besides, you need not only to know how to back up your site, but you should always keep your focus on whatever level of automation is used to create and move archives to the vaults.
For those who doubt such a question, we can advise you to search for articles on request “How I lost the site.” Numerous stories from various blogs about how, in an instant, a beautiful, untwisted site turned into a “zilch” almost before the owner’s eyes, which could not be restored without a backup, eloquently indicate the above statements.
How to backup site?
WHAT SHOULD BE STORED IN BACKUP COPIES?
For the site uses a variety of files that are located in a special directory on the server host. Such files are the code of pages (HTML or PHP files), images, code of various scripts, style sets and so on. It is necessary to make a backup archive of the file structure of the site. And depending on the regularity of updating data in files, backup copying must be done according to a certain schedule. We will look at it later.
If the site is built on any CMS, then the content for its pages is stored in a database. And the database also needs to be saved according to the same plan. In addition, there may be several such databases if any plugins use their own repositories.
WHEN DO I NEED TO MAKE BACKUP COPIES?
The ideal option is to make backup copies every day and keep them all. But practically no one can go to such waste of disk space.
Therefore, usually the site backup scheme is based on a replacement scheme. That is, you make backup copies of your data every day. But keep not all copies, but only for the last few days. For example, in the last decade or week. A new backup is placed in the repository, and the oldest is deleted. That is, in fact, you can restore your site to any of the last 10 or 7 days. To expand the possibilities of recovery, once in the selected period, the oldest copy is not deleted, but saved as a decade or weekly. The storage of such ten-day copies can also be organized according to the substitution pattern. Thus, you will extend the recovery period of your site. You will have the opportunity to recover not only in the last 7 or 10 days, but also at the time when there are backup copies, that is, in 20, 30, 40 days.
Under this scheme, you can make reservations for any period. You get the opportunity to restore the site and optimize the size of the storage for backup data.
Too long periods of storage is also not worth choosing. On actively developing sites, the current data structure may differ significantly from the state three months ago.
HOW TO BACK UP?
Many hosters offer automatic backups. In the control panel, you can configure how and when backups will be performed. And on some hosting backup is performed regardless of user settings on a regular basis. Data recovery in this variant is performed at the request of the user to the support service.
But even on such a hosting one should not relax and hope for the automation of servers. Why? First, the storage of copies has a limited period. And you need to find out for what period the backup copies of the data and the directory structure are stored. Secondly, backups can be stored in the same disk space as your site. That is, the cost of its maintenance will fall on your shoulders. It also turns out the situation with the storage of all the eggs in one basket – it may happen that the host server will be unavailable along with the site and backup copies.
Therefore, backups must be done independently and stored backups in another location.
For automatic backup, there are many different plugins. They can be used for sites built on CMS, as well as for static sites. Moreover, a number of plug-ins retain copies in the now popular cloud storages, thus solving the issue of separation of the location of data.
Well, in the most extreme case, you can always make an archive copy of the file structure using the file manager from the control panel or transfer the site directory to your local computer using the FTP client. For databases, almost every hoster has tools like PHPMyAdmin, which allow you to import data into archive files manually.
It is also important to take into account the naming of files. The name must contain at least the date of creation of the archive and a note that it contains a database or directory of the site. Otherwise, after a month in the stressful situation of restoring your offspring, it will be very difficult to figure out what contains a file called mysitearchive.gzip.
Developing a system to make a backup site may seem boring and unnecessary. But she is like a seat belt in a car. And you realize the value of such entities only at the moment of their use, when they save life, time and health.