Tar - pre-checking before making the Tar file


 
Thread Tools Search this Thread
Operating Systems AIX Tar - pre-checking before making the Tar file
# 8  
Old 06-11-2016
Quote:
Originally Posted by hicksd8
If you want to see the output on screen but also capture it then you can have the best of both worlds using the 'tee' command:

Code:
<whatever command> | tee <output text capture file>

I have tried this one, but does not work

Code:
root@clodb:/clodbvg>df -g
Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on

/dev/fslv02       14.00      1.72   88%   160138    29% /oratech

root@clodb:/clodbvg>/opt/freeware/bin/tar -cvf -  /oratech | gzip > /clodbvg/bkp_21MAY16_oratech.tgz | tee output.txt

root@clodb:/clodbvg>ls -ltra
total 6956360
drwxr-xr-x    2 root     system          256 May 22 00:46 lost+found

-rw-r--r--    1 root     system            0 Jun 11 23:42 output.txt
drwxr-xr-x    5 root     system         4096 Jun 11 23:42 .
-rw-r--r--    1 root     system   1054146560 Jun 11 23:45 bkp_21MAY16_oratech.tgz

root@clodb:/clodbvg>cat output.txt
root@clodb:/clodbvg>

output.txt is 0KB and there is nothing in it.


Whereas this

Code:
root@clodb:/clodbvg>(/opt/freeware/bin/tar -cvf -  /oratech | gzip > /clodbvg/bkp_21MAY16_oratech.tgz) > testoutput.txt 2>&1


root@clodb:/clodbvg>ls -ltra
total 5760048
drwxr-xr-x    2 root     system          256 May 22 00:46 lost+found

-rw-r--r--    1 root     system         1324 Jun 11 23:47 testoutput.txt


root@clodb:/clodbvg>cat testoutput.txt
/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

works perfectly.
# 9  
Old 06-11-2016
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.
This User Gave Thanks to RudiC For This Post:
# 10  
Old 06-11-2016
With my GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu), i came up with
Code:
tar cvf - fi* 2> >(tee ZZ /dev/tty) | gzip > XX 
file
file~
file1
file1~
file2
file2~
cat ZZ
file
file~
file1
file1~
file2
file2~

which seems to be close to what you requested.
This User Gave Thanks to RudiC For This Post:
# 11  
Old 06-11-2016
Quote:
Originally Posted by RudiC
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.
Code:
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

Code:
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

Code:
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

Code:
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

Thanks Rudic.

Last edited by filosophizer; 06-12-2016 at 08:03 AM.. Reason: posted the results of file which had problem when doing tar
# 12  
Old 06-15-2016
Quote:
Originally Posted by RudiC
With my GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu), i came up with
Code:
tar cvf - fi* 2> >(tee ZZ /dev/tty) | gzip > XX 
file
file~
file1
file1~
file2
file2~
cat ZZ
file
file~
file1
file1~
file2
file2~

which seems to be close to what you requested.
Rudic, for restore how would you do it ?

Backup
Code:
tar cvf - fi* 2> >(tee ZZ /dev/tty) | gzip > XX

Restore
Code:
.

# 13  
Old 06-15-2016
Sort of (untested)
Code:
gunzip XX | tar xf -

Doesn't your tar version offer the -z option for creation and extraction of gzipped archives?


---------------------


Quote:
Originally Posted by filosophizer
.
.
.
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.
.
.
.
I'm inclined to bet there's <CR> chars involved.

Last edited by RudiC; 06-15-2016 at 06:50 PM.. Reason: Restructured post.
# 14  
Old 06-15-2016
Quote:
Originally Posted by RudiC
Sort of (untested)
Code:
gunzip XX | tar xf -

Doesn't your tar version offer the -z option for creation and extraction of gzipped archives?


---------------------




I'm inclined to bet there's <CR> chars involved.

sorry for misunderstanding, meant to say restore using tee command to capture the output like how wrote the command for backup..
so where to put
Code:
tee

command in your code
Code:
gunzip XX | tar xf -

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Making Tar of directory and tar file is going to be placed

Quick question, is it possible to make a Tar of completely directory and placing the tar file in it (will this cause even the tar file to tarred ?) sample: /opt/freeware/bin/tar -cvf - /oracle | gzip > /oracle/backup.tgz will the tar file backup.tgz also include backup.tgz ? i tried... (5 Replies)
Discussion started by: filosophizer
5 Replies

2. UNIX for Dummies Questions & Answers

UNIX command to check if file name ends with .tar OR if the file is a tar file

Hello Team, Would you please help me with a UNIX command that would check if file is a tar file. if we dont have that , can you help me with UNIX command that would check if file ends with .tar Thanks in advance. (10 Replies)
Discussion started by: sanjaydubey2006
10 Replies

3. UNIX for Dummies Questions & Answers

Do I need to extract the entire tar file to confirm the tar folder is fine?

I would like to confirm my file.tar is been tar-ed correctly before I remove them. But I have very limited disc space to untar it. Can I just do the listing instead of actual extract it? Can I say confirm folder integrity if the listing is sucessful without problem? tar tvf file1.tar ... (1 Reply)
Discussion started by: vivien_chu
1 Replies

4. UNIX for Advanced & Expert Users

Move files while making a tar

I have the following folder structure code/f1/ code/lib/t1 code/lib/t2 code/lib/t3 code/lib/t3 code/lib_1/t1 code/exc I would like to create a tar with a folder structure below and I can use the following tar command f1 lib/t1 lib/t2 lib/t3 tar -cvf code.tar -C code f1 lib... (4 Replies)
Discussion started by: alpboys
4 Replies

5. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

6. UNIX for Dummies Questions & Answers

Making tar of a remote file system

Hello, I was asked by my boss to make a backup of one of our systems that is slated to be decommissioned. When I suggested if could tar the "/" directory he nodded and said that would do the trick, When I try and execute the command I get EOF error. I think it is because there is not enough... (2 Replies)
Discussion started by: mojoman
2 Replies

7. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

8. UNIX for Advanced & Expert Users

Tar utility (untar a .tar file) on VxWorks

Hi All Can someone pls guide me if there any utility to compress file on windows & uncompress on vxworks I tried as - - compressed some folders on windows ... i created .tar ( to maintain directory structure ) and compressed to .gz format. - on VxWorks i have uncompressed it to .tar... (1 Reply)
Discussion started by: uday_01
1 Replies

9. Shell Programming and Scripting

extract one file form .tar.gz without uncompressing .tar.gz file

hi all, kindly help me how to extract one file form .tar.gz without uncompressing .tar.gz file. thanks in advance bali (2 Replies)
Discussion started by: balireddy_77
2 Replies

10. UNIX for Advanced & Expert Users

Does tar do crc checking on a tape or tar file?

Trying to answer a question about whether tar table-of-contents is a good tool for verifying tape data. (1 Reply)
Discussion started by: tjlst15
1 Replies
Login or Register to Ask a Question