On Sun, 06 Apr 2003 13:31:45 -0700 Joe Dufresne <nqs@cognisurf.com> wrote:
I've got about 3 gig's of music files I'd like to back up in preparation for doing a fresh install of 8.2. I read the man page, but came away still confused. My goal was 650mb (CD size) archives, I used this command:
nqs@Miverna:~> tar -c -L=614400 *.ogg, *.mp3 music.tar
But get:
tar: =614400: Invalid tape length Try `tar --help' for more information.
Hi, tar is set up to expect tapes (which can be switched when full) when you try to do a multi-volume tar backup. Tar will prompt you when you need to change tapes. That said, you have 2 options: 1. Just make one big gzipped tar file (tar -zcvf) and then use the cut utility, to break it into cd sized chunks. You can recombine them with cat. 2. Use a trick with tar, to simulate a "tape switch" with a "file switch". You basically write a little script, which writes to a file, instead of tape, and have it switch files for you when the current file fills up. Here are some very rudimentary scripts which do this. The problem main problem is that they might not count over 10 accurately, but the should give you the idea. I use perl, to avoid all the sed and awk stuff, but these scripts demonstrate the basic principle. The backup script: ------------------------------------------------------------------------------------ #!/bin/sh if [ -z "$1" ]; then echo 'Usage: backup dir' exit 1 fi PREFIX="mybackup" tar -c -X EXCLUDE_FILE -M -L 500 -F backup-rotate.sh -f $PREFIX.tar $1 #this section tests for the last incomplete archive and renames it to the last number ################################################################################## #LASTNUM=`ls $PREFIX-*.tar | tail -1 | awk -F. '{print $1}' | awk -F- '{print $2}'` LASTNUM=`ls $PREFIX-*.tar | awk -F. '{print $1}' | awk -F- '{print $2}'| sort -g | tail -1` if [ X$LASTNUM = X ] ; then NEWNUM="1" else NEWNUM=`expr $LASTNUM + 1` fi mv $PREFIX.tar $PREFIX-$NEWNUM.tar ################################################################################# #this section gunzips all the tar files #gzip *.tar exit -------------------------------------------------------------------------------------------------------------- The rotator script: ---------------------------------------------------------------------------------------------------- #!/bin/sh PREFIX="mybackup" #LASTNUM=`ls $PREFIX-*.tar | tail -1 | awk -F. '{print $1}' | awk -F- '{print $2}'` #above dosn't account for numbers greater than 10 LASTNUM=`ls $PREFIX-*.tar | awk -F. '{print $1}' | awk -F- '{print $2}'| sort -g | tail -1` if [ X$LASTNUM = X ] ; then NEWNUM="1" else NEWNUM=`expr $LASTNUM + 1` fi mv $PREFIX.tar $PREFIX-$NEWNUM.tar ----------------------------------------------------------------------------------------------------- And here are the corresponding restore scripts, which do the reverse operation. Restore script: ---------------------------------------------------------------------------- #!/bin/sh #gunzip *.gz #if you have them gzipped PREFIX="mybackup" mv $PREFIX-1.tar $PREFIX.tar echo 1 tar -x -M -F restore-rotate.sh -f $PREFIX.tar rm $PREFIX.tar exit ------------------------------------------------------------------------------------ Restore-rotator script: -------------------------------------------------------------------------------- #!/bin/sh PREFIX="mybackup" NEXTNUM=`ls $PREFIX-*.tar | awk -F. '{print $1}' | awk -F- '{print $2}'| sort -g | head -1` #NEXTNUM=`ls $PREFIX-*.tar | head -1 | awk -F. '{print $1}' | awk -F- '{print $2}'` echo $NEXTNUM mv $PREFIX-$NEXTNUM.tar $PREFIX.tar -- use Perl; #powerful programmable prestidigitation