Linux is unlike Windows, which does not restrict the root user from accessing anything. Therefore, you can put every file on a partition into a TAR file.
Use the root user to switch to the root directory
Then, use the following command to back up the complete system:
tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys
Instructions: The
tar part is what we will software used.
'cvpfz' is the option we added to tar, like "create a compressed archive" (this is obvious), "save permissions" (so that every identical file has the same permissions), and "gzip" (reduced size). Next, is the name the compressed archive will get, in our case backup.tgz.
Following this is the root directory we want to back up. Since we want to backup everything :/. Then there are the directories we want to exclude: we don't want to back up everything, because including some directories isn't very useful. Also make sure you don't include the backup file itself, otherwise you'll get weird results. You probably also don't want to include the /mnt folder - if you have other partitions mounted there - otherwise you'll end up backing up those too. Also make sure you don't have anything mounted in /media (i.e. no CDs or removable media mounted). Otherwise, remove /media.
At the end of the process, you might get a message saying "tar: error due to delay from previous error" or something, but in most cases you can just ignore it.
As an option, you can use Bzip to compress your backups. This means higher compression ratio but also lower speed. If the compression ratio is important to you, just replace the "z" in the command with "j" and give the backup name a corresponding extension. These will make the command look like this:
tar cvpjf backup.tar.bz2 / --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys
Recommended tutorial: centos tutorial
The above is the detailed content of How to back up centos system. For more information, please follow other related articles on the PHP Chinese website!