In: Computer Science
How do I create a backup and restore strategy for a web site and the database for the site?
Before answering hoe to create a backup for your website you should be aware of why do you need to create a website backup always:
1.Lets suppose one morning you woke up and saw that your website has been deleted by your web host by mistake. This is the reason that we should back up our websites as this is our responsibility to protect our website, not of web hosts.
2.By doing a backup of our website we are also protecting our websites from viruses and other malware attacks because web hosts do not keep scanning your website against viruses and other harmful malware.
3. It gives a mental peace when we know that our website is backed up and safe in case of any crash.
Strategy to the backup website and its database
1. Manual Backup
In the manual backup, we mostly do backup in our local machine only. We just save all files of our website as well as its database in our local machine. It is a very low-cost method to backup a website.
The main disadvantage of this method is that it takes a lot of time to download all files and database of a website as well as we have to make our own logics to save it in our machine so that we can easily access and manage them.and also download all updates as well when our website or database is updated.
2. By Using CPanel backups
We can use the Cpanel backup option also to backup our website as well as the database. There is a backup icon present in Cpanel from where we can simply click on the generate backup button and enter our email id. We will receive a mail when our backup is ready and then we can download it and keep in multiple hard drives or any storage media.
The main disadvantage of this method is that we have to download all updates on our website when our website or database is updated every time.
3. Backup in Cloud
This is the most efficient way of backup od any website as well as its database. Many Cloud storage providers such as AWS(Amazon Web Services). Google Cloud Platform and Microsoft Azure are there which provide website backup facilities on their cloud at a reasonable cost and guarantee us for protection of our website as well as its data from any virus or malware attack. This method of website backup should always be used.
4. Using Rsync
This method of website and its database backup is also very efficient. Rsync is simply a software which copies all files from one server to another server. It copies all files of the website to another server where we want a backup.
It also backs up the database of our website. It uses the MYSQL database for backup of database. It simply runs a script known as mysqldump which creates a backup for the database of our website.
Rsync is more effective when the second server is Linux because just by typing a simple command it automatically creates all backup of the websites along with its database as MYSQL is by default installed in Linux.