Coming from this thread, just wondering if there is an option to check if the Tar of the files/directory will be without any file-errors without actually making the tar.
Scenario:
Let's say you have a directory of 20GB, but you don't have the space to make Tar file at the moment, and you want to check before you actually make Tar achieve file, that all the files in the directory can be Tarred, how would you achieve this ?
Obviously during a tar operation you can get errors reading the files and errors writing the archive. The archive can be a disk file, a tape drive, or some other device. One output device is /dev/null which is a black hole to nowhere. If you send the archive to that you will still see any reading errors.
Where's your backup file gone with the second version?
The first trial with tee fails because the files' names are listed to stderr, which doesn't make it into tee , and which you redirect in version 2. Still, you don't have the files on screen AND in testoutput as desired.
With the second version, I will not see any output on the screen , it will be redirected to the file.
root@clodb:/clodbvg>ls -ltra
total 16417272
drwxr-xr-x 2 root system 256 May 22 00:46 lost+found
-rw-r--r-- 1 root system 12976636 Jun 12 00:28 testoutput.txt
-rw-r--r-- 1 root system 5885143569 Jun 12 00:28 bkp_21MAY16_oratech.tgz
root@clodb:/clodbvg>tail -n3 testoutput.txt | more
/opt/freeware/bin/tar: Removing leading `/' from member names
/oratech/
/oratech/.TTauthority
/oratech/.Xauthority
/oratech/.dt/
/oratech/.dt/Desktop/
/oratech/.dt/Trash/
/oratech/.dt/Trash/.trashinfo
/oratech/.dt/appmanager/
/oratech/.dt/errorlog
/oratech/.dt/help/
/oratech/.dt/help/oraprod-oradb-0/
/oratech/.dt/help/oraprod-oradb-0/browser.hv
/oratech/.dt/help/oraprod-oradb-0/browser00.ht
/oratech/.dt/help/oraprod-oradb-0/browser01.ht
root@clodb:/clodbvg>tail -n3 testoutput.txt
/oratech/smit.script
/oratech/smit.transaction
/oratech/test1
now trying with your version
root@clodb:/clodbvg>bash
root@clodb:/clodbvg>tar cvf - /oratech 2> >(tee ZZ /dev/tty) | gzip > testversion.tgz
a /oratech
a /oratech/.TTauthority 1 blocks.
a /oratech/.Xauthority 1 blocks.
a /oratech/.dt
a /oratech/.dt/Desktop
a /oratech/.dt/Trash
a /oratech/.dt/Trash/.trashinfo 0 blocks.
a /oratech/.dt/appmanager
a /oratech/.dt/errorlog 1 blocks.
a /oratech/.dt/help
a /oratech/.dt/help/oraprod-oradb-0
a /oratech/.dt/help/oraprod-oradb-0/browser.hv 2 blocks.
root@clodb:/clodbvg>cat ZZ
a /oratech
a /oratech/.TTauthority 1 blocks.
a /oratech/.Xauthority 1 blocks.
a /oratech/.dt
a /oratech/.dt/Desktop
a /oratech/.dt/Trash
a /oratech/.dt/Trash/.trashinfo 0 blocks.
a /oratech/.dt/appmanager
a /oratech/.dt/errorlog 1 blocks.
a /oratech/.dt/help
a /oratech/.dt/help/oraprod-oradb-0
a /oratech/.dt/help/oraprod-oradb-0/browser.hv 2 blocks.
a /oratech/.dt/help/oraprod-oradb-0/browser00.ht 3 blocks.
a /oratech/.dt/help/oraprod-oradb-0/browser01.ht 0 blocks.
Now trying the files which had error
root@clodb:/clodbvg>tar cvf - /oradata/proddata/applsys*.* 2> >(tee errorfiles.txt /dev/tty) | gzip > errorfiles.tgz
a /oradata/proddata/applsysd01.dbf 6963216 blocks.
a /oradata/proddata/applsysd02.dbf 14680080 blocks.
/oradata/proddata/applsysd02.dbf: There is an input or output error.
tar: 0511-182 Read error on a /oradata/proddata/applsysd03.dbf 13107216 blocks.
a /oradata/proddata/applsysd04.dbf 4505616 blocks.
a /oradata/proddata/applsysd05.dbf 4505616 blocks.
a /oradata/proddata/applsysx01.dbf 4915216 blocks.
a /oradata/proddata/applsysx02.dbf 7987216 blocks.
The error is only on applsysd02.dbf and not applsysd03.dbf
root@clodb:/clodbvg>/opt/freeware/bin/tar cvf - /oradata | gzip > /clodbvg/bkp_30MAY16.tgz
/opt/freeware/bin/tar: Removing leading `/' from member names
/oradata/
/oradata/JAVA/
/oradata/JAVA/.toc
/oradata/JAVA/Java131.rte
/oradata/JAVA/Java131.rte.tar
/oradata/Stage11i/
/oradata/lost+found/
/oradata/proddata/
/oradata/proddata/XDOD.dbf
/oradata/proddata/XDOX.dbf
/opt/freeware/bin/tar: /oradata/proddata/applsysd02.dbf: Read error at byte 4767080960, reading 10240 bytes: There is an input or output error.
/oradata/proddata/applsysd03.dbf
/oradata/proddata/applsysd04.dbf
/oradata/proddata/applsysd05.dbf
/oradata/proddata/applsysx01.dbf
/oradata/proddata/applsysx02.dbf