In some previous articles, I have repeatedly mentioned often will engage in a Linux system crashes, the backup system is a thing can not be ignored. Because of their superiority Linux systems, backup and restore the system is relatively easy. Mainly in the following areas:
All Linux systems in the form of a file exist, so the backup is a direct copy files; hard disk partition also as a file, so you can directly clone hard drive data.
Linux system comes with many useful tools, such as tar, dd, rsync, etc., backup and restore system does not need to buy or download third-party software.
Linux system in run-time files on its hard disk can be overwritten, so no additional time to restore the system's boot disk. (Of course, the system is completely unable to start this case to hang or require additional boot disk.)
Backup Strategies There are many Linux systems, such as using the dd command to directly clone the hard disk partition:
sudo dd if = / dev / sda1 of = / dev / sdb1
Alternatively, use tar files on the hard disk packing:
sudo tar cvpzf backup.tgz --exclude = / proc --exclude = / mnt --exclude = / sys --exclude = / backup.tgz /
Restore the system command is:
sudo dd if = / dev / sdb1 of = / dev / sda1
tar xvpfz backup.tgz -C /
But I chose the rsync command. rsync is a very good tool for file synchronization, can be seen from its name, it supports remote synchronization. Of course, my desktop backup system, only need to use its local synchronization on the line. Chose rsync, it is because it has the following advantages:
In the backup and restore process, you can save the file the original time, permissions, soft and hard links and other information;
When the first backup, you need to copy all the files, but when you back up or restore the system again, you only need to copy the modified file.
On how to use rsync, the main reference document is the man rsync, in addition, rsync can also be run as a daemon used to create a backup file server, you can refer to the documentation man rsyncd.conf.
Desktop Backup combat
For my desktop, I chose backup strategy is to use the rsync command to all files on the hard drive (of course, to exclude the contents of / proc and / sys directory) is copied to the U disk. First, use the command df -lh check my computer's system account for how much space
Partition root directory where occupied 14G, and partition / boot directory where it occupies more than 100 M. In fact, Linux system would have been not so bloated, but since I installed a lot of software packages, such as a set of texlive ah what, it takes up so much space. But this is not the thing, anyway, now U disk is cheap, so U disk 32G find the USB 3.0 to back up my system is certainly very pleasant.
New U disk into your computer will be automatically recognized using the mount command with no arguments can view the device file and mount path U disk, using the fdisk command to know the size of the U disk and partition.
U disk is divided into a whole area I do not have opinions, but I do not like it vfat file system, if it was a giant of more than 4G file how to do? so, umount it first, and then use it to re-establish a mkfs.ext3 file system
U disk and then mount up, mount the path / media / youxia / usb.
You can then start the backup, and the backup is my command:
sudo rsync -Pa / / media / youxia / usb / backup_20141216 --exclude = / media / * --exclude = / sys / * --exclude = / proc / * --exclude = / mnt / * --exclude = / tmp / *
Effect after the backup is complete, you can see the entire backup process took 59 more minutes, U-occupied 15G
If the day before the collapse of the system, then only need to use sudo rsync -Pa / media / youxia / usb / backup_20141216 / to restore the system.