Making a backup of your Linux Operating System is a very simple process that uses tools included in every linux installation.
The first step is to create a location to store the backup. For this article we're going to store the backup on the same hard drive as the installed operating system, but you can attach USB devices like thumb drive and external hard drives and even special storage like iSCSI and NFS mounted device to store the backup.
Once you are logged into the server and at a command line make the directory to store the backup in an organized way such as:
Now we will create a compressed version of the Operating System in one single file (tarball) using the tar command.
For RedHat, CentOS and Fedora or any Operating System based on these linux flavors run the following command:
tar cvpzf /backups/backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backups --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 /
For Debian or Ubuntu run the following command:
tar cvpzf /backups/backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backups --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 /
Once the command completes the tarball will be located at /backups/backup.tgz
***HINT: You can change the name of the tarball file with a date identifier and keep multiple versions or "snapshots" of your server's configuration.
In order to restore your server from the previously created tarball the server must have the same Operating System version loaded on it. This particular method of backup and restore is not meant for bare metal projects that need to restore an Operating System to an empty hard drive. It was actually designed to move a configured Operating System from one hardware platform to another, but also works well for rolling back an operating system to a previous configuration.
Once you have a working Operating System either on a new hardware platform or the same hardware platform move the tarball to the server you want to restore. If you stored the tarball on a USB device or other external storage just reattach the device and mount it. If the tarball is on another linux server use commands like this to copy it to the new server’s hard drive:
scp [email protected]original_server:/backups/backup.tgz /backups
Of course replace "original_server" with the appropriate IP address.
Enter the root users password and the transfer will begin.
Once the transfer has completed run this command to extract the tarball thereby restoring the Operating System that the tarball contains:
tar xvpfz /backups/backup.tgz -C /
Complete the process with a reboot and troubleshoot any errors that may come up.
ServerPronto’s Dedicated Servers are the economical choice for providing an exclusive set of resources solely devoted to your IT needs. With our bare metal servers, you will benefit from:.