[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: compressing tar files / backup scripts



On Sun, Oct 16, 2005 at 11:47:18PM +0100, Adam Hardy wrote:
> I've got a really simple backup script which goes like this:
> 
> tar -rvf backup$1.tar java/projects
> tar -rvf backup$1.tar .mozilla
> tar -rvf backup$1.tar bin
> echo "compress the whole thing .... "
> tar -czvf backup$1.gz.tar backup$1.tar
> 
> 
> Basically I am using -r (the append option) to backup some directories 
> and then I do a compress on the uncompressed file at the end. tar won't 
> let me append and compress at the same time.
> 
> However a side-effect of this is in Windows - I transfer the backups 
> across to another machine running Windows - when I open the tar file in 
> winzip, I then see the uncompressed tar inside the compressed tar, so I 
> then have to open that too.
> 
> Is there a better way to do this, avoiding the side effect with winzip?
> 
> For instance, writing a list of files to a temp file and then piping it 
> all into tar in one go? Example commands of some such strategy would be 
> great!
> 

Hi Adam,

you can simply pipe the resulting .tar through gzip, like this:

tar -rvf backup$1.tar java/projects
tar -rvf backup$1.tar .mozilla
tar -rvf backup$1.tar bin
gzip backup$1.tar

This will create backup$1.tar.gz - you could have achieved the same
result by doing

tar -czvf backup$1.tar.gz java/projects .mozilla bin

because tar -z is doing nothing more than piping the resulting
archive through gzip.


HTH,

Jan


-- 
Jan C. Nordholz
<jckn At gmx net>

Attachment: signature.asc
Description: Digital signature


Reply to: