[TAG] Re: Backing up with tar article

Dave Bechtel kingneutron at yahoo.com
Sat Feb 21 05:50:31 MSK 2004


Re: http://linuxgazette.net/issue99/tag/1.html

--I've recently discovered the "rar" archiver.  Here's a sample backup script:

BEGIN bkp2rar
#!/bin/sh

filestobkp=$1
#filestobkp="/mnt/scsibkps/dv/kpxdvd/*"

#destfile="vmware-kpxdvd-b4-sysvinit-updt"
destfile="/mnt/cdtemp/vmware-kpxdvd-b4-sysvinit-updt"

#cd /mnt/cdtemp

time rar \
 a \
 -m1 \
 -md128 \
 -rr8 \
 -ol \
 -ow \
 -o+ \
 -r \
 -tsm \
 -tsc \
 -v100000k \
 -w/mnt/cdtemp \
 -- \
 $destfile \
 $filestobkp

# -sistdin-tar-gz \
# -si cannot be used with -v!
 
#-md4096
# Note: MD size is KB! Smaller it is, faster it goes...

### END

--This splits the archive up into 100MB volumes, with "fastest" compression. 
Fast is apparently relative - Runs slow compared to gzip -9, but experiment
with the dictionary size (' -md ' switch.  Smaller is apparently faster,
albeit with less compression ratio.)  

--Archiving ~5GB of data with this script took between 1+1/2 to 2 hours on a
900MHz AMD Duron with 512MB RAM, resulting in 22 volumes and ~44% compression.
 YMMV.  In fact you could probably knock together a solution with tar, gzip
-9, and ' split '; but rar will also add *recovery records* (that's the -rr8
switch) to work around media errors.

--To list the contents of the resulting volumes:
' rar vt -v *part01*rar '

--Note, rar falls under "non-free" in Debian.

--I'm not *exactly* sure how to do:
' tar cvf - . |gzip -9 |bkp2rar ' (using ' -m0 ' in the script, which means no
rar-compression)

...and have it split into volumes On-The-Fly.  Tried some experiments with
named pipes (mkfifo) but didn't get anywhere.  Any advice on this is welcome.

--Alternative to rar is to investigate Joerg Schilling's "star" archiver (yes,
the same author as cdrecord.)
ftp://ftp.berlios.de/pub/star/

Sample script for a "star" backup (haven't touched it since 2002 tho):

BEGIN bkp-usr
#!/bin/bash

cd /mnt/bkps901/p233

bkpdate='20021202'
mkdir $bkpdate
cd $bkpdate

echo $bkpdate > /dev/shm/usr-bkpdate
echo '1' > /dev/shm/usr-curvol

mkdir usr-vols
# Scram listing
>usr-vols/flist-p233-usr-$bkpdate

pwd
ls -al

time star -cv tsize=700M new-volume-script=/root/bin/star-chgvol \
  file=bkp-p233-usr.star \
  /usr

# Col star-chgvol one last time
~/bin/star-chgvol

# Remove tmp files
/bin/rm /dev/shm/usr-curvol
/bin/rm /dev/shm/usr-bkpdate
### END

--And the companion script to handle volume changes:

BEGIN star-chgvol
#!/bin/bash

bkpdate=`cat /dev/shm/usr-bkpdate`
curvol=`cat /dev/shm/usr-curvol`

echo $0' bkpdate='$bkpdate' curvol='$curvol
echo $0' pwd='$PWD

cd /mnt/bkps901/p233/$bkpdate

time mv bkp-p233-usr.star usr-vols/bkp-p233-usr-$curvol.star

# Listit and compressit nicely
{
 pushd .
 cd usr-vols

 echo 'Volume: '$curvol >>flist-p233-usr-$bkpdate
 time star -tv file=bkp-p233-usr-$curvol.star \
   >>flist-p233-usr-$bkpdate

 time nice gzip -9 bkp-p233-usr-$curvol.star
 popd
} &
wtonit=$!

#wait $wtonit; {
#}

let nextvol="$curvol + 1"
echo $0' nextvol='$nextvol
echo $nextvol >/dev/shm/usr-curvol
### END

--Permission is hereby granted to you in advance, to publish this email in
full or in part, for the edification of your readers.  The scripts, which were
written by me, are released as Freeware.  Feel free to use, adapt, and modify
them as you see fit.


=====
Contents above ThisLine (C)ThisYear KingNeutron Ltd.
===== Check out KNOPPIX Debian/Linux 700MB Live CD:
===== http://www.knopper.net/knoppix/index-old-en.html
"C00K13 M0N573R 0WNZ J00!! PH34R C00K13 M0N573R 4ND 0SC4R 4ND
3LM0 4ND 5NUFFL3UP46U5 4ND 7H3 31337 535AM3 57R337 CR3W!!"
.dotgoeshere.

__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools




More information about the TAG mailing list