Archiving with tar in Linux / FreeBSD. tar archiver

Tar archiver for Linux.
Tar archive can be compressed in gzip. Format will then look like this – tar.gz
How to create a tar archive in FreeBSD:
# Tar -cvf archive.tar / var / db / mysql / *
c – create – create an archive
v – verbose – issuing extra. messages when creating an archive
f – to create a file on disk
/ Var / db / mysql / * – archived files by a space.
How to compress the contents of the archive tar?
# Tar -cvzf archive.tar.gz / var / db / mysql / *
Contents of the archive will be compressed with gzip
How to extract the contents of a tar archive to the current folder?
# Tar -xf archive.tar – remove normal tar archive in the current directory
# Tar -xzf archive.tar.gz – extract the compressed tar archive in the current directory
How to extract the contents of the tar file to a specified folder?
# Tar -xf archive.tar -C / home / data – extract a normal tar archive into the directory / home / data
# Tar -xzf archive.tar.gz -C / home / data – extract the compressed tar archive in the directory / home / data
How to delete a file or folder for archiving or creating an archive tar?
To exclude files or folders use the option –exclude
# Tar –exclude = ‘/ home / user / *’ -cvzf archive.tar.gz / home / *
In this example, we archive the entire directory / home, but exclude from the archive folder / home / user