• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 486
  • Last Modified:

modify cpdir to tar.gz output and delete source ?

Hello experts,
my newest challenge for you....

I have looked through cpdir found at http://www.shelldorado.com/scripts/cmds/cpiodir.txt
and i see where the files are actualy copied, line 87

                cpio $CpioOpt "$targetdir"
 
Is there a way to make this script tar.gz the files it copies,
then delete the source files if wanted ?  I guess instead of
copy move into archive....

I could just tar.gz the enitre folder, but the logs are too many and too large,
it would create one big blob, when the seperate tar.gz files are quicker
and lighter to manipulate

I think i should change it to something like,
               tar cuzf  "$CpioOpt".tar.gz -C "$targetdir"
but the syntax is probably far from correct.

Thats the first hurdle,
next would be to delete the source files, if everything was ok.

Thanks in advance !
GHBoom


      
0
ghboom
Asked:
ghboom
1 Solution
 
ahoffmannCommented:
> Is there a way to make this script tar.gz the files it copies,
I guess no, 'cause the these tools (tar, cpio, dd, etc.) build some sort of checksum and discard the result if the checksum fails. In such a case the "moved" data are lost, probably not what you want.
You have to write a script which copies single files (or some amount of files) and removes the sources after szccessfully coying.
0
 
TintinCommented:
Sounds very much like you need rsync.

See http://rsync.samba.org/
0
 
ghboomAuthor Commented:
ahoffmann,
thanks but cpio is used in the original program, all I want to do is to change the compression method and later delete the original....

Tintin, thanks also ;) but Im just looking for an automated way to copy folders and files while only compressing the files, and placing them
localy .

As there are hundreds of files in /var/logs and they need pruning, I would rather not have to do it file by file !

The original shell script looks as if it copies folder structure first, then copies the files.

Thanks anyway, I guess I will try other forums....

GHBoom
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
TintinCommented:
I'm not 100% sure what you are trying to acheive, but will make the following comment.

rsync is quite often used for copying, archiving, moving files locally.  It doesn't have to be remote.

Are you trying to archive old logs by creating a bunch of tar.gz files in an archive location?  If so, what's the reason you want multiple tar.gz files?  What criterea are you using to select the files?

0
 
yuzhCommented:
>>rsync is quite often used for copying, archiving, moving files locally.  It doesn't have to be remote

   True,  please credit to Tintin.
0
 
ghboomAuthor Commented:
Tintin,
sorry about that, my eyes are tired, i missed that !

GHBoom
0
 
NopiusCommented:
With GNU tar you may use --remove-files option, man tar
'remove files after adding them to archive'.
With standard tar there is no such option, sorry.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now