Operating System - Linux
1829607 Members
1386 Online
109992 Solutions
New Discussion

CPIO and logging copied files

 
SOLVED
Go to solution
Mauro_8
Frequent Advisor

CPIO and logging copied files

Hi,

I want to backup some files and while each file is copied to tape, the file name is appended in a log file ( /files_ok.txt ) and if an error occurs it is appended in an error file, called /tmp/log.err. How can I do it ?

I try:
find / -depth -print | cpio -ovB -H newc 2>>/tmp/log.err >/dev/st0

but the list of files goes to /tmp/log.err. It??s so strange because I think it??s a stderr output ( 2>> ). I think I am having problems because I have to redirect the cpio output to tape but I just want to list the files that cpio made backup.

Any ideas ?

Cheers,
Mauro
8 REPLIES 8
Steven E. Protter
Exalted Contributor
Solution

Re: CPIO and logging copied files

Its pretty common practice to use ls for find commands to direct certain files to tape.

If you want a list of what gets to tape somewhere else consider this.

commandline | tee /tmp/tapelist.log

This will have the output go two places, to tape as directed and a copy goes to the file you define.

tee is a very nice little tool.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Mauro_8
Frequent Advisor

Re: CPIO and logging copied files

Hi,

The problem is when I did "find / -depth -print | cpio -ovB -H newc 2>>/tmp/log.err >/dev/st0" I received no messages in my terminal (tty), so I can not use tee... If I use tee it creates a empty file.

Cheers,
Mauro

Steven E. Protter
Exalted Contributor

Re: CPIO and logging copied files

I ran your command in a script like this:

find / -depth -print | cpio -ovB -H newc 2>>/tmp/log.err > find.results

I got a lot of results very quickly.

Is your environment(TERM, etc) normal when you are having these null results?

How about this:

find / -dept -print | cpio -ovB -H newc > /dev/st0



SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Mauro_8
Frequent Advisor

Re: CPIO and logging copied files

Hi,

This is ok. The backup is made. The problem is I do not have a list of all the files that are on the tape...

I get success if I try to restore the backup but I do not know what files are in this tape and I and do not want in my script after the command listed that takes 2 hours running the tape having to do "cpio -ivt < /dev/st0 > /files_ok.txt and more 2 hours running the tape listing the files on it. I want to do it in just one time.

Thanks.

Cheers,
Mauro
Steven E. Protter
Exalted Contributor

Re: CPIO and logging copied files

find / -dept -print | cpio -ovB -H newc > /dev/st0 | tee /tmp/filelist.log

Maybe though the | tee should be before the | cpio

Then just the filelist will go to tee and the filelist will be processed by the cpio command.

If I have time, I'll try and play with this on a linux box tonight.

If you are in a hurry, you can try it sooner.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Caesar_3
Esteemed Contributor

Re: CPIO and logging copied files

Hello!

Yes, you should add the "| tee" after find
command and the output of tee pipe to the
cpio command.
Just like SEP wrote.

Caesar
Stuart Browne
Honored Contributor

Re: CPIO and logging copied files

This is the way I do it:

find . -print0 | cpio -0ovC10240 -H newc -O /dev/nst0 2> output.log

Use '-O' to output to the device, rather than use STDOUT to make less confusion. Unfortunately as errors also come out on STDERR, there's no real way to separate them. The STDOUT of cpio however does have some 'information' messages, depending on the flag syou use.

much fun ;)
One long-haired git at your service...
Mauro_8
Frequent Advisor

Re: CPIO and logging copied files

Thanks !

It??s working now, with tee.

Cheers,
Mauro