Backup and recovery describes the process of creating and storing copies of data that can be used to protect organizations against data loss.
Similarly, Recovery from a backup typically involves restoring the data to the original location, or to an alternate location where it can be used in place of the lost or damaged data.
rsync is a protocol built for Unix-like systems that provides unbelievable versatility for backing up and synchronizing data.
It can be used locally to back up files to different directories or can be configured to sync across the Internet to other hosts.
In this context, we shall look into the steps to perform backup and restore files on Linux.
The Benefits of performing Backups and restore tasks in Linux?
Nowadays, server intrusion has become rampant and hackers are attacking millions of website every day. Therefore it is best to perform a regular backup of your server at least once or twice a month at intervals so that in the case where your data is compromised, you can quickly restore your website and Linux server without facing too much downtime.
Operating System Backup Process
Making a backup of your server should not be a difficult task to complete. Internal system tools in Linux have such features inbuilt in them.
I will take you through the steps in doing a backup process on a Linux Server.
Firstly, you have to create a unique location where you want the backup to stay in your server. You can also use an external Disk as a medium of storage of your backup if this will be preferred by you.
To make a directory , lets say "backup_directory" dedicated for the backup files, use the command below;
Next, we will create a compressed form of the Operating system file referred to "tarball".
To do is in CentOS, RedHat and Fedora, use the command below;
tar cvpzf /backup_directory/backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup_directory --exclude=/dev --exclude=/sys --exclude=/boot/grub --exclude=/boot/grub2 --exclude=/etc/fstab --exclude=/etc/sysconfig/network-scripts/ --exclude=/etc/udev/rules.d/70-persistent-net.rules /
As for Debian or Ubuntu Distribution, use the command below;
tar cvpzf /backup_directory/backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup_directory --exclude=/dev --exclude=/sys --exclude=/boot/grub --exclude=/boot/grub2 --exclude=/etc/fstab --exclude=/etc/network/interfaces --exclude=/etc/udev/rules.d/70-persistent-net.rules /
The backup process might take some few minutes or hours to be completed successfully depending on the size of your Data and files on your server.
Therefore, patience is needed here.
As soon as the process is completed, the tarball file will be generated in /backup_directory/backup.tgz
The name can be modified as per the time you made the backup to enable you identity such backup files easily when you want to make a subsequent backup.
Restoring your Server's Operating System from your Backup
Restoring your server is necessary especially when you want to restore the Operating System of your server back to its previous state. As previously noted, during the backup process you can decide to save the Backup files in an external disk or on the same server.
To restore the backup on a new server, do the following;
Create a new directory by using the command below;
Next, use the command below to copy the backup file to the operating system;
scp root@old_server:/backup_directory/backup.tgz /backup_restore
Where "old_server" should be replaced by your old server ip address.
To complete the restoration process, use the command below;
tar xvpfz /backup_restore/backup.tgz -C /
This process will restore the backup to the server.
Finally, do a "reboot" of the server.
Doing a backup of your server could be strange when you are not good with the Linux environment. Our Server Experts offer OS system Backups services.