Linux system backup and restore
Backup system:
1.
To become the root user: Su root
2.
Go to root directory: CD/
3.
To package compression with the TAR command:
Tar CVPJF compressed package name. TAR.BZ2--exclude=/Compressed package name. TAR.GZ2/
Such as:
Tar cvpjf backup.tar.bz2--exclude=/backup.tar.bz2/
Command explanation:
Tar: Package Compression command
CVPJF: Is the tar option, which means "create profile", keep permissions (keep everything original permission), use BZIP2 compression (high compression rate)
BACKUP.TAR.BZ2: Compressed file name
/: Is the directory we want to back up, here is the entire system
--EXCLUDE=/BACKUP.TAR.BZ2: Exclude this file (exclude front is two horizontal lines)
If it is:
Tar cvpzf backup.tgz--exclude=/backup.tgz/
means that the compression method used is different, that is, using gzip to compress
If a hint like this appears in tar
Exiting with failure status due to previous errors
You can view
Ls-ld
Look at its permissions, which is typically displayed: Drwxr-xr-x 3 root root 4096
So you can handle this:
chmod 0777.
Look at the ls-ld and see drwxrwxrwx
Restore System:
Put the above backup.tar.bz2 or backup.tgz in the root directory
1.
To become the root user: Su root
2.
Go to root directory: CD/
3.
If it is back.tar.bz2, then:
Tar xvpfj backup.tar.bz2-c/
Or
Tar Xvpfz backup.tgz-c/
If you have not previously backed up, you can manually create the relevant directories and files
Linux system backup and restore