How to Use Tar Command Effectively in Linux For Good Backup Solution

The Linux tar command stands for tap archive, is not a compressed file and commonly called as a collection (which contains the contents of many files) of a single file.

Tar is the most commonly used command in Linux for creating a archive file. It saves multiple files, folders & other file formats (zip, gzip, bzip2 & tar) into a single archive file. Many of us very frequently uses three operations create, list & extract & two options file & verbose with tar to dealing the backups and restore.

Additionally we can use gzip & bzip2 commands for further compressing the tar archive. Mainly tar command used to performing backup (full and incremental) from the server by server administrator, other famous backup applications are using tar command for backup.

All the files and folders can be restore from the archive file whenever you want, every server administrator need to know the tar command and it’s usage for better backup solution.

By default tar command included into most of the distribution, so we can easily install from distribution official repository.

We are going to show you in this article, how we can use the tar command effectively for different purpose.

[Install Tar on RHEL/CentOS/Fedora]
$ sudo yum install tar

[Install Tar on Fedora] 22 and later]
$ sudo dnf install tar

[Install Tar on Debian/Linux Mint/Ubuntu]
$ sudo apt-get install tar

[Install Tar on openSUSE]
$ sudo zypper in tar

[Install Tar on Mageia]
$ sudo urpmi tar

[Install Tar on Arch based distro]
$ sudo pacman -S tar

Syntax : Common Syntax for tar command

Syntax : tar -[options] [/backup-location/backup-filename] /[webcontent-location]

Options : Commonly used options in tar command are listed below

  • z : Compress the backup file with ‘gzip’ to make it into small size.
  • c : Create a new backup archive
  • v : verbosely list files which are processed
  • p : Preserves the permissions of the files put in the archive for restoration later.
  • f : following is the archive file name
  • x : To extract a archive file
  • t : To viewing content of archive file
  • j : Archive the file with bzip2
  • r : To add new file or folder in existing archive file
  • W : To verify a archive file content
  • p : Compress the backup file with ‘present umask’.
  • C : To mention the path to extract the archive file
  • wildcards : Extract the group of file from archive file

1) How to create tar Archive File

The following example, backup the entire 2daygeek directory content into 2daygeek-backup-17-Dec-2013.tar file and store the backup file at /backup/site-backup/ directory.

# tar -cvf /backup/site-backup/2daygeek-backup-17-Dec-2013.tar /home/2daygeek
/home/2daygeek/
/home/2daygeek/etc/
/home/2daygeek/.bashrc
/home/2daygeekc/public_html/
/home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
/home/2daygeekc/public_html/captca/form.php
/home/2daygeekc/public_html/captca/monofont.ttf
/home/2daygeekc/public_html/captca/error_log
/home/2daygeekc/public_html/colorlover.php
/home/2daygeekc/public_html/userfunctions.php
/home/2daygeekc/public_html/.htaccess

2) To create tar.gz Archive File

The following example, backup the entire 2daygeek directory content with .gzip compressed format (It uses z option which makes the tar into small size) into 2daygeek-backup-17-Dec-2013.tar.gz file and store the backup file at /backup/site-backup/ directory.

# tar -zcvf /backup/site-backup/2daygeek-backup-17-Dec-2013.tar.gz /home/2daygeek
/home/2daygeek/
/home/2daygeek/etc/
/home/2daygeek/.bashrc
/home/2daygeekc/public_html/
/home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
/home/2daygeekc/public_html/captca/form.php
/home/2daygeekc/public_html/captca/monofont.ttf
/home/2daygeekc/public_html/captca/error_log
/home/2daygeekc/public_html/colorlover.php
/home/2daygeekc/public_html/userfunctions.php
/home/2daygeekc/public_html/.htaccess

3) To create tar.bz2 Archive File

The following example, backup the entire 2daygeek directory content with bzip2 compressed format (It uses j option which makes the tar into small size. This method is much better compared to gzip compression) into 2daygeek-backup-17-Dec-2013.tar.gz file and store the backup file at /backup/site-backup/ directory.

# tar -jcvf /backup/site-backup/2daygeek-backup-17-Dec-2013.tar.bz2 /home/2daygeek
/home/2daygeek/
/home/2daygeek/etc/
/home/2daygeek/.bashrc
/home/2daygeekc/public_html/
/home/2daygeekc/public_html/2nd_feb usernameCheck.php
/home/2daygeekc/public_html/captca/
/home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
/home/2daygeekc/public_html/captca/form.php
/home/2daygeekc/public_html/captca/monofont.ttf
/home/2daygeekc/public_html/captca/error_log
/home/2daygeekc/public_html/colorlover.php
/home/2daygeekc/public_html/userfunctions.php
/home/2daygeekc/public_html/.htaccess

Output:

As of now, i have created three archive format tar, tar.gz & tar.bz2 and located at /backup/site-backup/. See the below output for better understanding.

Here, i can see the much different on .tar.bz2 archive format compared with others. bzip2 is the high-quality data compressor method. It typically compresses files to within 10% to 15% of the best available technique (the PPM family of statistical compressors).

# ll -h
total 72M
drwxr-xr-x 2 root root 4.0K Dec 17 05:57 ./
drwxr-xr-x 3 root root 4.0K Dec 17 05:28 ../
-rw-r--r-- 1 root root  58M Dec 17 05:33 2daygeek-backup-17-Dec-2013.tar
-rw-r--r-- 1 root root 5.4M Dec 17 05:57 2daygeek-backup-17-Dec-2013.tar.bz2
-rw-r--r-- 1 root root 8.3M Dec 17 05:48 2daygeek-backup-17-Dec-2013.tar.gz

4) Display Content of tar.bz2 Archive File

If you want to display, list of the files & folder inside the .tar.bz2 archive file without extracting? use the following command to print it.

# tar -jtvf /backup/site-backup/2daygeek-backup-17-Dec-2013.tar.bz2
drwx--x--x 2daygeek/2daygeek 0 2013-12-14 01:00 home/2daygeek/
drwxr-x--- 2daygeek/mail     0 2013-04-29 06:15 home/2daygeek/etc/
-rw-r--r-- 2daygeek/2daygeek 124 2013-02-21 21:09 home/2daygeek/.bashrc
drwxr-x--- 2daygeek/nobody     0 2013-09-25 09:07 home/2daygeekc/public_html/
-rw-r--r-- 2daygeek/2daygeek 52418 2013-04-29 08:29 home/2daygeekc/public_html/2nd_feb usernameCheck.php
drwxr-xr-x 2daygeek/2daygeek     0 2013-04-29 08:31 home/2daygeekc/public_html/captca/
-rw-r--r-- 2daygeek/2daygeek  2084 2013-04-29 08:31 home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
-rw-r--r-- 2daygeek/2daygeek  1120 2013-04-29 08:31 home/2daygeekc/public_html/captca/form.php
-rw-r--r-- 2daygeek/2daygeek 41036 2013-04-29 08:31 home/2daygeekc/public_html/captca/monofont.ttf
-rw-r--r-- 2daygeek/2daygeek  4587 2013-04-29 08:31 home/2daygeekc/public_html/captca/error_log
-rw-r--r-- 2daygeek/2daygeek   710 2013-04-29 08:29 home/2daygeekc/public_html/colorlover.php
-rw-r--r-- 2daygeek/2daygeek  4730 2013-04-29 08:29 home/2daygeekc/public_html/userfunctions.php
-rw-r--r-- 2daygeek/2daygeek 17787 2013-09-25 07:37 home/2daygeekc/public_html/.htaccess
-rw-r--r-- 2daygeek/2daygeek   691 2013-04-29 08:29 home/2daygeekc/public_html/reddit.php

5) List Content of .tar Archive File

If you want to display, list of the files & folder inside the .tar archive file without extracting? use the following command to print it.

# tar -tvf /backup/site-backup/2daygeek-backup-17-Dec-2013.tar
drwx--x--x 2daygeek/2daygeek 0 2013-12-14 01:00 home/2daygeek/
drwxr-x--- 2daygeek/mail     0 2013-04-29 06:15 home/2daygeek/etc/
-rw-r--r-- 2daygeek/2daygeek 124 2013-02-21 21:09 home/2daygeek/.bashrc
drwxr-x--- 2daygeek/nobody     0 2013-09-25 09:07 home/2daygeekc/public_html/
-rw-r--r-- 2daygeek/2daygeek 52418 2013-04-29 08:29 home/2daygeekc/public_html/2nd_feb usernameCheck.php
drwxr-xr-x 2daygeek/2daygeek     0 2013-04-29 08:31 home/2daygeekc/public_html/captca/
-rw-r--r-- 2daygeek/2daygeek  2084 2013-04-29 08:31 home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
-rw-r--r-- 2daygeek/2daygeek  1120 2013-04-29 08:31 home/2daygeekc/public_html/captca/form.php
-rw-r--r-- 2daygeek/2daygeek 41036 2013-04-29 08:31 home/2daygeekc/public_html/captca/monofont.ttf
-rw-r--r-- 2daygeek/2daygeek  4587 2013-04-29 08:31 home/2daygeekc/public_html/captca/error_log
-rw-r--r-- 2daygeek/2daygeek   710 2013-04-29 08:29 home/2daygeekc/public_html/colorlover.php
-rw-r--r-- 2daygeek/2daygeek  4730 2013-04-29 08:29 home/2daygeekc/public_html/userfunctions.php
-rw-r--r-- 2daygeek/2daygeek 17787 2013-09-25 07:37 home/2daygeekc/public_html/.htaccess
-rw-r--r-- 2daygeek/2daygeek   691 2013-04-29 08:29 home/2daygeekc/public_html/reddit.php

6) List Content of tar.gz Archive File

If you want to display, list of the files & folder inside the .tar.gz archive file without extracting? use the following command to print it.

# tar -ztvf /backup/site-backup/2daygeek-backup-17-Dec-2013.tar.gz
drwx--x--x 2daygeek/2daygeek 0 2013-12-14 01:00 home/2daygeek/
drwxr-x--- 2daygeek/mail     0 2013-04-29 06:15 home/2daygeek/etc/
-rw-r--r-- 2daygeek/2daygeek 124 2013-02-21 21:09 home/2daygeek/.bashrc
drwxr-x--- 2daygeek/nobody     0 2013-09-25 09:07 home/2daygeekc/public_html/
-rw-r--r-- 2daygeek/2daygeek 52418 2013-04-29 08:29 home/2daygeekc/public_html/2nd_feb usernameCheck.php
drwxr-xr-x 2daygeek/2daygeek     0 2013-04-29 08:31 home/2daygeekc/public_html/captca/
-rw-r--r-- 2daygeek/2daygeek  2084 2013-04-29 08:31 home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
-rw-r--r-- 2daygeek/2daygeek  1120 2013-04-29 08:31 home/2daygeekc/public_html/captca/form.php
-rw-r--r-- 2daygeek/2daygeek 41036 2013-04-29 08:31 home/2daygeekc/public_html/captca/monofont.ttf
-rw-r--r-- 2daygeek/2daygeek  4587 2013-04-29 08:31 home/2daygeekc/public_html/captca/error_log
-rw-r--r-- 2daygeek/2daygeek   710 2013-04-29 08:29 home/2daygeekc/public_html/colorlover.php
-rw-r--r-- 2daygeek/2daygeek  4730 2013-04-29 08:29 home/2daygeekc/public_html/userfunctions.php
-rw-r--r-- 2daygeek/2daygeek 17787 2013-09-25 07:37 home/2daygeekc/public_html/.htaccess
-rw-r--r-- 2daygeek/2daygeek   691 2013-04-29 08:29 home/2daygeekc/public_html/reddit.php

7) List Content of .tbz Archive File

If you want to display, list of the files & folder inside the .tbz archive file without extracting? use the following command to print it.

# tar -jtvf /backup/site-backup/2daygeek-backup-17-Dec-2013.tbz
drwx--x--x 2daygeek/2daygeek 0 2013-12-14 01:00 home/2daygeek/
drwxr-x--- 2daygeek/mail     0 2013-04-29 06:15 home/2daygeek/etc/
-rw-r--r-- 2daygeek/2daygeek 124 2013-02-21 21:09 home/2daygeek/.bashrc
drwxr-x--- 2daygeek/nobody     0 2013-09-25 09:07 home/2daygeekc/public_html/
-rw-r--r-- 2daygeek/2daygeek 52418 2013-04-29 08:29 home/2daygeekc/public_html/2nd_feb usernameCheck.php
drwxr-xr-x 2daygeek/2daygeek     0 2013-04-29 08:31 home/2daygeekc/public_html/captca/
-rw-r--r-- 2daygeek/2daygeek  2084 2013-04-29 08:31 home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
-rw-r--r-- 2daygeek/2daygeek  1120 2013-04-29 08:31 home/2daygeekc/public_html/captca/form.php
-rw-r--r-- 2daygeek/2daygeek 41036 2013-04-29 08:31 home/2daygeekc/public_html/captca/monofont.ttf
-rw-r--r-- 2daygeek/2daygeek  4587 2013-04-29 08:31 home/2daygeekc/public_html/captca/error_log
-rw-r--r-- 2daygeek/2daygeek   710 2013-04-29 08:29 home/2daygeekc/public_html/colorlover.php
-rw-r--r-- 2daygeek/2daygeek  4730 2013-04-29 08:29 home/2daygeekc/public_html/userfunctions.php
-rw-r--r-- 2daygeek/2daygeek 17787 2013-09-25 07:37 home/2daygeekc/public_html/.htaccess
-rw-r--r-- 2daygeek/2daygeek   691 2013-04-29 08:29 home/2daygeekc/public_html/reddit.php

8) To create .tbz Archive File with permission

The following example, backup the entire 2daygeek directory content with User-ID & Group-ID permission & .bzip2 compressed format (It uses j option which makes the tar into small size) into 2daygeek-backup-17-Dec-2013.tbz file and stores the backup file at /backup/site-backup/ directory.

# tar -jcvpf /backup/site-backup/2daygeek-backup-17-Dec-2013.tbz /home/2daygeek
/home/2daygeek/
/home/2daygeek/etc/
/home/2daygeek/.bashrc
/home/2daygeekc/public_html/
/home/2daygeekc/public_html/2nd_feb usernameCheck.php
/home/2daygeekc/public_html/captca/
/home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
/home/2daygeekc/public_html/captca/form.php
/home/2daygeekc/public_html/captca/monofont.ttf
/home/2daygeekc/public_html/captca/error_log
/home/2daygeekc/public_html/colorlover.php
/home/2daygeekc/public_html/userfunctions.php
/home/2daygeekc/public_html/.htaccess

9) Add Files & Directory into existing tar Archive

Use the following example to add additional files & folder into existing archive file, it uses -r option to append files. In this example, we are going to add magesh.html file & mageshm directory.

# tar -rvf /backup/site-backup/2daygeek-backup-17-Dec-2013.tar magesh.html mageshm

Make a note, you can’t add files or directory to a compressed archive like, tar.gz & tar.bz2. If you try to add, you will endof with below error message.

# tar -jrvf /backup/site-backup/2daygeek-backup-23-nov-2013.tar.bz2 magesh.html
tar: Cannot update compressed archives
Try `tar –help’ or `tar –usage’ for more information.

10) Extract tar archive File

Use the following example to extract or untar the .tar archive file. It uses -x option to extract the tar archive file.

If you want to extract the tar archive file to any particular location, use the same below format and change the /home/magesh/2daygeek path as per your wish.

To extract the archive file into present working directory, use the same below command without destination path /home/magesh/2daygeek & -C option.

# tar -xvf 2daygeek-backup-17-Dec-2013.tar -C /home/magesh/2daygeek
home/2daygeek/
home/2daygeek/etc/
home/2daygeek/.bashrc
home/2daygeekc/public_html/
home/2daygeekc/public_html/2nd_feb usernameCheck.php
home/2daygeekc/public_html/captca/
home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
home/2daygeekc/public_html/captca/form.php
home/2daygeekc/public_html/captca/monofont.ttf
home/2daygeekc/public_html/captca/error_log
home/2daygeekc/public_html/colorlover.php
home/2daygeekc/public_html/userfunctions.php
home/2daygeekc/public_html/.htaccess

11) Extract tar.gz Archive File

Use the following example to extract or untar the .tar.gz archive file. It uses -x option to extract the tar archive file.

If you want to extract the tar archive file to any particular location, use the same below format and change the /home/magesh/2daygeek path as per your wish.

To extract the archive file into present working directory, use the same below command without destination path /home/magesh/2daygeek & -C option.

# tar -xzvf 2daygeek-backup-17-Dec-2013.tar.gz -C /home/magesh/2daygeek
home/2daygeek/
home/2daygeek/etc/
home/2daygeek/.bashrc
home/2daygeekc/public_html/
home/2daygeekc/public_html/2nd_feb usernameCheck.php
home/2daygeekc/public_html/captca/
home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
home/2daygeekc/public_html/captca/form.php
home/2daygeekc/public_html/captca/monofont.ttf
home/2daygeekc/public_html/captca/error_log
home/2daygeekc/public_html/colorlover.php
home/2daygeekc/public_html/userfunctions.php
home/2daygeekc/public_html/.htaccess

12) Extract tar.bz2 Archive File

Use the following example to extract or untar the .tar.bz2 archive file. It uses -x option to extract the tar archive file.

If you want to extract the tar archive file to any particular location, use the same below format and change the /home/magesh/2daygeek path as per your wish.

To extract the archive file into present working directory, use the same below command without destination path /home/magesh/2daygeek & -C option.

# tar -xjvf 2daygeek-backup-17-Dec-2013.tar.bz2 -C /home/magesh/2daygeek
home/2daygeek/
home/2daygeek/etc/
home/2daygeek/.bashrc
home/2daygeekc/public_html/
home/2daygeekc/public_html/2nd_feb usernameCheck.php
home/2daygeekc/public_html/captca/
home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
home/2daygeekc/public_html/captca/form.php
home/2daygeekc/public_html/captca/monofont.ttf
home/2daygeekc/public_html/captca/error_log
home/2daygeekc/public_html/colorlover.php
home/2daygeekc/public_html/userfunctions.php
home/2daygeekc/public_html/.htaccess

13) Extract Single file from .tar archive File

For some reason, you want to extract or untar only particular file from the tar archive, use the following example and replace your file name instead of us magesh.html.

# tar -xvf 2daygeek-backup-17-Dec-2013.tar magesh.html

Output:

See below magesh.html file has been extracted from tar archive and stored in the same location.

# ll -h
total 81M
drwxr-xr-x 2 root     root     4.0K Dec 17 07:22 ./
drwxr-xr-x 3 root     root     4.0K Dec 17 05:28 ../
-rw-r--r-- 1 root     root      58M Dec 17 06:33 2daygeek-backup-17-Dec-2013.tar
-rw-r--r-- 1 root     root     7.4M Dec 17 05:57 2daygeek-backup-17-Dec-2013.tar.bz2
-rw-r--r-- 1 root     root     8.3M Dec 17 05:48 2daygeek-backup-17-Dec-2013.tar.gz
-rw-r--r-- 1 root     root     7.4M Dec 17 06:09 2daygeek-backup-17-Dec-2013.tbz
-rw-r--r-- 1 magesh magesh     53 Dec 17 06:29 magesh.html

14) Extract Single file from the sub-directory of tar archive File

The same way, you want to extract or untar only particular file from the tar archive, use the following example and replace your file name instead of us index.html.

# tar --extract --file=2daygeek-backup-17-Dec-2013.tar /home/2daygeek/tmp/webalizerftp/index.html

15) Extract Multiple file from tar archive File

Alternatively we can extract or untar more then one files from the tar archive. use the following example and replace your file name instead of us "magesh.html" "ramesh.html".

The below example will be extract the magesh.html & ramesh.html file from the .tar archive file.

# tar -xvf 2daygeek-backup-17-Dec-2013.tar "magesh.html" "ramesh.html"
magesh.html
ramesh.html

Output:

See below magesh.html & ramesh.html file has been extracted from tar archive and stored in the same location.

# ll -h
total 81M
drwxr-xr-x 2 root     root     4.0K Dec 17 08:35 ./
drwxr-xr-x 3 root     root     4.0K Dec 17 05:28 ../
-rw-r--r-- 1 root     root      58M Dec 17 08:33 2daygeek-backup-17-Dec-2013.tar
-rw-r--r-- 1 root     root     7.4M Dec 17 05:57 2daygeek-backup-17-Dec-2013.tar.bz2
-rw-r--r-- 1 root     root     8.3M Dec 17 05:48 2daygeek-backup-17-Dec-2013.tar.gz
-rw-r--r-- 1 root     root     7.4M Dec 17 06:09 2daygeek-backup-17-Dec-2013.tbz
-rw-r--r-- 1 magesh magesh       53 Dec 17 06:29 magesh.html
-rw-r--r-- 1 magesh magesh       17 Dec 17 08:32 ramesh.html

16) Extract Group of Files using Wildcard

For some special requirement, you want to extract or untar group of files from the tar archive, use the following example and replace required file extension instead of us .html.

In below example, we are going to extract group of file which is matched with the pattern .html from tar archive.

# tar -xvf 2daygeek-backup-17-Dec-2013.tar --wildcards '*.html'
home/2daygeekc/public_html/37.99.html
home/2daygeekc/public_html/57.99.html
home/2daygeek/tmp/analog/11.html
home/2daygeek/tmp/analog/5.html
home/2daygeek/tmp/analog/12.html
home/2daygeek/tmp/analog/9.html
home/2daygeek/tmp/analog/10.html
magesh.html
ramesh.html

17) To create tar.gz Archive File and Exclude particular directory

We can exclude any directory, if we don’t want to take backup (like, if it’s holding video files). Mention the particular directory which you want to exclude with help of --exclude option and replace yours instead of us /home/2daygeek/demo then add required info too.

The below example, we are going to exclude the entire demo directory then archive rest of the files and folders.

# tar --exclude=’/home/2daygeek/demo’ -zcvpf /backup/site-backup/2daygeek-backup-17-Dec-2013.tar.gz /home/2daygeek
/home/2daygeek/
/home/2daygeek/etc/
/home/2daygeek/.bashrc
/home/2daygeekc/public_html/
/home/2daygeekc/public_html/2nd_feb usernameCheck.php
/home/2daygeekc/public_html/captca/
/home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
/home/2daygeekc/public_html/captca/form.php
/home/2daygeekc/public_html/captca/monofont.ttf
/home/2daygeekc/public_html/captca/error_log
/home/2daygeekc/public_html/colorlover.php
/home/2daygeekc/public_html/userfunctions.php
/home/2daygeekc/public_html/.htaccess

18) To create tar.gz Archive File and Exclude group of files

Alternatively, we can exclude group of files from any directory, if we don’t want to take backup like .mp3 & .avi files. Just mention the particular directory name with file extension which you want to exclude with help of --exclude option and replace yours instead of us /home/2daygeek/demo then add required info too.

The below example, we are going to exclude the .mp3 & .avi files from the demo directory then archive rest of the files and folders.

# tar --exclude=’/home/2daygeek/demo/*.avi’ –exclude=’/home/2daygeek/demo/*.mp3' -zcvpf /backup/site-backup/2daygeek-backup-23-nov-2013.tar.gz /home/2daygeek
/home/2daygeek/
/home/2daygeek/etc/
/home/2daygeek/.bashrc
/home/2daygeekc/public_html/
/home/2daygeekc/public_html/2nd_feb usernameCheck.php
/home/2daygeekc/public_html/captca/
/home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
/home/2daygeekc/public_html/captca/form.php
/home/2daygeekc/public_html/captca/monofont.ttf
/home/2daygeekc/public_html/captca/error_log
/home/2daygeekc/public_html/colorlover.php
/home/2daygeekc/public_html/userfunctions.php
/home/2daygeekc/public_html/.htaccess

19) How To Verify tar Archive File

We can verify the tar archive file which was created by us to validate either it get created properly or not using the -w option.

Make a note, you can’t verify a compressed archive like, tar.gz & tar.bz2 file. If you try to add, you will end of with error message.

# tar tvfW 2daygeek-backup-17-Dec-2013.tar
tar: This does not look like a tar archive
tar: Skipping to next header
Verify ---------- 505/505       52418 1970-01-01 01:00 home/2daygeekc/public_html/2nd_feb usernameCheck.php
tar: home/2daygeekc/public_html/2nd_feb usernameCheck.php: Warning: Cannot stat: No such file or directory
Verify d--------- 505/505           0 1970-01-01 01:00 home/2daygeekc/public_html/captca/
tar: home/2daygeekc/public_html/captca: Warning: Cannot stat: No such file or directory
Verify ---------- 505/505        2084 1970-01-01 01:00 home/2daygeekc/public_html/captca/CaptchaSecurityImages.php
tar: home/2daygeekc/public_html/captca/CaptchaSecurityImages.php: Warning: Cannot stat: No such file or directory
Verify ---------- 505/505        1120 1970-01-01 01:00 home/2daygeekc/public_html/captca/form.php
tar: home/2daygeekc/public_html/captca/form.php: Warning: Cannot stat: No such file or directory
Verify ---------- 505/505       41036 1970-01-01 01:00 home/2daygeekc/public_html/captca/monofont.ttf
tar: home/2daygeekc/public_html/captca/monofont.ttf: Warning: Cannot stat: No such file or directory
Verify ---------- 505/505        4587 1970-01-01 01:00 home/2daygeekc/public_html/captca/error_log

20) To check the Size of the tar, tar.gz and tar.bz2 Archive File

To check the size of any tar, tar.gz and tar.bz2 archive file, use the below command.

[email protected] [/backup/site-backup]# tar -czf - 2daygeek-backup-17-Dec-2013.tar | wc -c
8657681

[email protected] [/backup/site-backup]# tar -czf - 2daygeek-backup-17-Dec-2013.tar.gz | wc -c
8276311

[email protected] [/backup/site-backup]# tar -czf - 2daygeek-backup-17-Dec-2013.tar.bz2 | wc -c
7695961


Hope this article will help you to understand the Tar command usage and important for good backup solution on server environment. Kindly provide your valuable feedback/comments in the commenting section.

Stay tuned with us !!

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...