Quick Image/Restore a Linux Installation
I have been dealing with a lot of image creation and restoration lately and that's when I came across an article to restore a backup in a certain format at one of our cloud providers. The article can be found here. Now one part of the problem was resolved i.e. restoring server backups from the cloud.
The other problem started when requests started coming in to create such backups at our other providers so as to be able to restore them later. Then one fine morning the cloud provider supporting the backup mentioned suddenly drops it in favor of OVF.
I then went ahead and created a simple set of commands to create a backup of a Linux installation and use the steps in the article above to restore it.
A few things before I start.
Restore a backup.
The other problem started when requests started coming in to create such backups at our other providers so as to be able to restore them later. Then one fine morning the cloud provider supporting the backup mentioned suddenly drops it in favor of OVF.
I then went ahead and created a simple set of commands to create a backup of a Linux installation and use the steps in the article above to restore it.
A few things before I start.
- The backup/restore will work only for same flavor of Linux. Do not restore a Debian on a CentOS system.
- The kernel versions should match, due to possible better features at boot level.
And here we go.
Taking a backup.
Login into your Linux instance using the root account. If you do not have root privileges login using a restricted account which has sudo permissions. Change to super user mode using "sudo su".
Create a folder under / called "image".
Now execute the following commands.
cd /image
tar -zcvpf image.tar.gz --directory=/ --exclude=dev --exclude=proc --exclude=sys --exclude=image .
The last command will create a tar ball named image.tar.gz under /image which contains the entire installation except the folders /dev, /proc, /sys, /image. These are system specific folders and should not be copied. The image folder should also not be considered else you would be including a copy of the tar ball in the image.
Restore a backup.
Now to restore this image to a different Linux server, browse to the link below and follow the instructions.
Have a nice day.
Comments