Linux study 5-compression and backup
1. Common compressed files in Linux *. files compressed by the Z compress Program (not popular now, and can be decompressed using gzip );*. files compressed by the gz gzip program ;*. bz2 bzip2 program compressed files ;*. the data packaged by the tar program has not been compressed. The files packaged by the * .tar.gz tar program are compressed by the gzip * .tar.bz2 tar program, compress With bzip2 2. Common compression commands 1. gzip is compressed into gzip [-cdtv #] File Name options and parameters:-c: Output compressed data to the screen, which can be processed through data stream redirection;-d: decompression parameters;-t: can be used to check the consistency of a compressed file to see if there are any errors in the file;-v: can display the compression ratio of the original file/compressed file case and other information; -#: Compression level.-1 is the fastest, but the compression ratio is the worst.-9 is the slowest, but the compression ratio is the best! The default value is-6 2. zcat file name .gz can be directly viewed without decompression 3. bzip2 is compressed into bzip2 bzip2 [-cdkzv #] File Name options and parameters:-c: output the data produced by the compression process to the screen! -D: extract parameter-k: Keep the source file without deleting the original file-z: Compressed parameter-v: displays the compression ratio of the original file/compressed file; -#: Compression level,-9 is the best,-1 is the fastest! 4. bzcat file name. bz2: view the File Content Without decompression. 5. tar packaging Command Options and parameters:-c: Create a package file-t: check which file names are contained in the package file-x: unpackage or decompress function, you can use-C to uncompress a file in a specific directory.-j: Use bzip2 to compress/decompress the file. The file name is * .tar.bz2-z: Use gzip to compress/decompress the file: at this time, the file name should be * .tar.gz-v: During the compression/decompression process, the file name being processed will be displayed! -F filename: name of the file to be processed immediately after-f! -F is recommended to write an option separately! -C Directory: This option is used for decompression. to decompress the package in a specific directory, you can use this option to select "Unzip. -P: Retain the original permissions and attributes of the backup data. It is often used in backup (-c) important configuration file-P: retain the absolute path, that is, allow the backup data to contain the root directory; -- exclude = FILE: do not pack the FILE during compression! Use Case: compress: tar-jcv-f filename.tar.bz2 query the file or directory name to be compressed: tar-jtv-f filename.tar.bz2 decompress: tar-jxv-f filename.tar.bz2-C only extract a specific file in the directory to be decompressed: tar-jxv-f/root/etc.tar.bz2 etc/shadow 3. System Backup and restoration 1. you can use dump to back up the file system. Dump supports the backup of the entire file system or a single directory. When backing up a single file system, you can perform hierarchical backup. During backup, you can use a mount point or device file name. When you back up a directory, all the backup data must be under this directory. Only full backup is supported and hierarchical backup is not supported. Dump [-Suvj] [-level] [-f backup file] Options and parameters of the data to be backed up:-S: only list the disk space required for the subsequent data to be backed up to complete the backup;-u: record the dump time to the/etc/dumpdates file;-v: display the dump file process.-j: Support for bzip2! Compress the data. The default bzip2 compression level is 2-level: the level we talked about, from-0 ~ -9 a total of 10 levels;-f: A bit similar to tar, followed by the generated files, such as/dev/st0 device file name-W: is there any backup for the mongopartition with the dump setting in/etc/fstab listed? 2. Use restore to restore the system.