Wednesday, August 22, 2012

How to make a backup in Linux


Many are wondering about how to keep your system settings, and personal data so that then in case of emergency you can easily restore them. As far as I know, with Windows and Mac OS X this is no problem, as a means for pre-installed copy rezervonogo in both operating systems. None of the Linux distributions I've tested I have not seen default tools coming from the system provides this functionality. To be precise, the money to back up in Linux, by default, but not all newcomers are aware of them, much less know how to use these tools.

There are three ways to back up your data and systems in Linux

Use the archiver to create a compressed copy of
Removing the hard disk image
The use of special, additional utilities
I think the first way is the most versatile and is applicable to almost any situation. The advantages of this method is that the backup archive is not too much space and you can choose what to include in the backup, and what to exclude.
For the first method, we need the target system is installed on a partition / hard disk partitions and USB flash drive / DVD drive from the Live system. Such as Live CD from which you set the system. It is noteworthy that also need a partition on which you want to store the data. It also wanted to mount
So assume that the OS is installed on the first partition of the first hard disk (/ dev/sda1). Boot from the Live CD and install this section say in / mnt



sudo mount / dev/sda1 / mnt
Mount the partition on which you want to place a backup

sudo mkdir / backup
sudo mount / dev/sda3 / backup
The Linux command ls-a / mnt will confirm that we have a partition mounted. If you got an error, run cfdisk and find the partition and then mount it as shown above.
Next, go to the directory partitions are mounted to the system and see what directories it will be the backup.

cd / mnt
ls-a
Seeing the list of directories to include the necessary backup.

sudo su
tar-cvjpf / backup/Backup.tar.bz2 bin boot dev etc home lib lib32 lib64 media mnt opt ​​proc root sbin sys tmp usr var
If you have a slightly different set of directories, such as the directory is missing lib32 and lib64, I advise you to just back up all the directories were not created by you. With directories you created, proceed at your discretion. Some guides recommend to exclude from the backup / proc, / dev, / sys, but I taught own experience I would say that it should not do. Backup should be complete and include all system directories. When you mount a directory with virtual file systems such as / proc and / sys their contents will be empty, but it will save you from making them again and assigning them to the correct permissions (rights). The result of these actions will be the appearance in the destination directory / backup archive contains Backup.tar.bz2 backup system that can always be restored.

Restore backup is not too tricky. For a successful recovery, we need all the same Live CD, myself and a number of backup time. Boot from the Live CD and install sections of the already well-known scheme described above. If you do not carry a backup to another hard disk, the existing system needs to be deleted first.

sudo rm-rf / mnt / *
Copy the archive backup to the target partition

sudo su
cp / backup/Backup.tar.bz2 / mnt /
Become our future system backup and Unpack

cd / mnt
tar-xvjpf Backup.tar.bz2
The key is "v" recommend keeping as you can see the errors and the process unpacking. Everything on this backup restore completed.

Move on to another method which is less convenient because of the possibility of large-sized image and inability to throw out of it obviously unnecessary data. Plus as this method is that the image is created is an exact copy of the existing system of repeating, and file systems and the data contained therein. This method is used to defragment the file systems that do not have their own tools for this.
In this method, you need to boot from the Live CD and mount the partition on which we want to store the image. Mount the partition to which we want zabekapit - mount is not necessary! Please pay attention to this. Create an image using the following command

sudo su
dd if = / dev/sda1 bs = 8M of = / backup / Backup.img
If the volume is large, stocking patient and go have tea / coffee or something stronger while you are creating the image. The main thing is not to drink "something stronger" in large quantities before its restoration.
Recovery even easier: You must boot from the Live CD, mount the partition on which is a backup and restore it to the team (as long as the system is still being restored to / dev/sda1. Errors in the best case in danger of losing Pron collection of carefully selected by you for the past few years spent in stage of puberty, and at worst - broken monitor keyboard when you realize what lost:-D).

dd if = / backup / Backup.img bs = 8M of = / dev/sda1
After completing the task, you get an exact copy of the system that was at the time of the backup.

A third way to create / restore backups, I absolutely did not use as unnecessary. I can only assume that by using this method you will not be able to control the content of such software backup and still pull a variety of relationships necessary for its operation. If all of the above did you find difficult, you can try to find yourself in the Google repository ispolzumomogo or distribution of such software. Vskidku can advise Bacula or Amanda

No comments:

Post a Comment