Using tar to create multi-volume archives
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. and --help didn't What am I doing wrong, and how do I correct it? I don't wish to compress nor split files, just a clan backup of my ~/Music/ directory Joe -- If you're not a little bit uncomfortable with your position, it isn't radical enough. How can you be TOO principled? Take the most extreme position you can -- you're claiming territory you won't have to fight for later, mostly with your "allies". -- L. Neil Smith nqs@cognisurf.com | Blog: http://tigger.tmcom.com/~josad/blogger.html
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
zentara wrote:
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.
I'm creating the .tgz now. I opened up a second console, and tried experimenting w/ cut w/ a text file, is this command correct: nqs@Miverna:~/Music> cut -b600000 music.txt > test.txt when I use more to view the test file, it's "blank", but has stuff in it (4 bytes) Joe -- If you're not a little bit uncomfortable with your position, it isn't radical enough. How can you be TOO principled? Take the most extreme position you can -- you're claiming territory you won't have to fight for later, mostly with your "allies". -- L. Neil Smith nqs@cognisurf.com | Blog: http://tigger.tmcom.com/~josad/blogger.html
On Monday 07 April 2003 02:33, Joe Dufresne wrote:
zentara wrote:
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.
I'm creating the .tgz now. I opened up a second console, and tried experimenting w/ cut w/ a text file, is this command correct:
nqs@Miverna:~/Music> cut -b600000 music.txt > test.txt
when I use more to view the test file, it's "blank", but has stuff in it (4 bytes)
That's not what cut is used for. cut grabs fields from lines in files. What you did with the above command was grab byte number 600000 from each line in file music.txt and put it in test.txt. I'm guessing that's not what you wanted :) I think you want the "split" utility. Read "man split" regards Anders
Anders Johansson wrote: Hey Group: If you are going to use "tar" and want multi-volumes take a look at "tar -M"
On Monday 07 April 2003 02:33, Joe Dufresne wrote:
zentara wrote:
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.
I'm creating the .tgz now. I opened up a second console, and tried experimenting w/ cut w/ a text file, is this command correct:
nqs@Miverna:~/Music> cut -b600000 music.txt > test.txt
when I use more to view the test file, it's "blank", but has stuff in it (4 bytes)
That's not what cut is used for. cut grabs fields from lines in files. What you did with the above command was grab byte number 600000 from each line in file music.txt and put it in test.txt. I'm guessing that's not what you wanted :)
I think you want the "split" utility. Read "man split"
regards Anders
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
-- 73 de Donn Washburn __ " http://www.hal-pc.org/~n5xwb " Ham Callsign N5XWB / / __ __ __ __ __ __ __ 307 Savoy St. / /__ / / / \/ / / /_/ / \ \/ / Sugar Land, TX 77478 /_____/ /_/ /_/\__/ /_____/ /_/\_\ LL# 1.281.242.3256 a MSDOS Virus "Free Zone" OS Email: n5xwb@hal-pc.org Info: http://www.knoppix.net
On Sun, 06 Apr 2003 21:48:45 -0500 Donn aka N5XWB <n5xwb@hal-pc.org> wrote:
If you are going to use "tar" and want multi-volumes take a look at "tar -M"
That was the original problem. When you use the -M option, tar will stop and ask you to change tapes when it fills the first -L sized chunk. The scripts I posted use a file instead of tapes, and automate the file switching. If you do it with the -M -L and -F switches, but don't use a file rotator script, you can manually rename the files when tar askes for a new tape. Just rename mybackup.tar to mybackup1.tar, and touch mybackup.tar, then tar will make the second file. The rotator script automates it. I'm sorry about the "cut" mistake, I meant split, as Anders pointed out. -- use Perl; #powerful programmable prestidigitation
participants (4)
-
Anders Johansson
-
Donn aka N5XWB
-
Joe Dufresne
-
zentara