Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A script to create multi-DVD-spanning backups UNIX
This hint is based on this previous hint, and alluded to in this comment to that hint. I went ahead and created a DVD-spanning script using tar. Copy and paste this code into your favorite pure text editor, and save it as tar2dvd.sh. In Terminal, make it executable (chmod 755 tar2dvd.sh), and store it somewhere on your path for easy access.

To use it, just type tar2dvd.sh folder_to_backup in Terminal. For example, you could do this:
$ cd ~/Documents
$ tar2dvd.sh MyBigFolder
When the processing is done, you'll find a new folder called MyBigFolder.backup, which will contain numbered subdirectories, one per DVD.

[robg adds: This worked well in my testing, even on folders with spaces in their names. Note that if you use Apple's Backup app, you'll probably want to change the line that reads TARDIR=$BACKUPDIR.backup -- the .backup extension will make it appear as though the end result is a Backup package bundle. I changed the extension to simply .bkup, and then the end result is a folder, as expected.]
    •    
  • Currently 2.80 / 5
  You rated: 3 / 5 (5 votes cast)
 
[15,583 views]  

A script to create multi-DVD-spanning backups | 10 comments | Create New Account
Click here to return to the 'A script to create multi-DVD-spanning backups' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to create multi-DVD-spanning backups
Authored by: roncross@cox.net on May 24, '07 09:07:23AM

What about zipping them to further compress the files and thus reducing the number of DVDs needed to store them on. Does gzip in Tiger support resource fork? I know it didn't support resource fork in Panther.

with warm regards
Ron Cross

---
rlc



[ Reply to This | # ]
A script to create multi-DVD-spanning backups
Authored by: harrisj on May 24, '07 02:16:16PM

tar can't use compression on multi-volume archives. Probably because it can't accurately calculate the filesize.



[ Reply to This | # ]
A script to create multi-DVD-spanning backups
Authored by: roncross@cox.net on May 24, '07 04:51:10PM

I believe you can tar it first followed by gzip and then split and burn to DVDs or some other medium. This would save some coasters.

---
rlc



[ Reply to This | # ]
multi-DVD-spanning backups without tar
Authored by: dbs on May 24, '07 09:18:06AM

I'd like a script that does not tar files. I.e., I want it to copy as far down the directory structure as it can fit then put the rest of the structure on the next DVD so I can browse them without untarring first.

I a script to do this. It creates burn folders for each DVD (so there's no copying involved) but it doesn't work correctly. The problem is that I used "du" to calculate the size of folders for splitting, but this does not give the same results as Apple's burn folders.

I.e., I'd make sure I had less than 4.7GB of data in each DVD, but the burn folder would show it was larger. I think this has a lot to do with the number of files/directories, but I could not figure out any way to correctly estimate this so I haven't been able to finish it.

Any ideas?



[ Reply to This | # ]
here docs
Authored by: airdrummer on May 24, '07 11:24:09AM
to simplify creating scripts on the fly, bash has 'here docs'
http://tldp.org/LDP/abs/html/here-docs.html
so replace all the >>$SCRIPT lines with:

cat > $SCRIPT <<EOF
#!/bin/bash
#
COUNT=1
TARDIR=\""`echo $TARDIR|sed 's/ /\\ /'`"\"
FILENAME=\""`echo $FILENAME|sed 's/ /\\ /'`"\"
test -d \"\$TARDIR\"
if [ ! $? ]; then
echo Dir does not exist. Exiting..
exit 1
fi
FOLDERS=\`ls \"\$TARDIR\"\`
for i in \$FOLDERS; do
let COUNT++
done
mkdir \"\$TARDIR\"/\$COUNT
mv \"\$FILENAME\" \"\$TARDIR\"/\$COUNT
exit 0
EOF
chmod +x $SCRIPT

there may b issues with the escaped quotes...

[ Reply to This | # ]
here docs
Authored by: harrisj on May 24, '07 02:19:28PM

Hey, that is handy. Learn something new everyday :)



[ Reply to This | # ]
A script to create multi-DVD-spanning backups
Authored by: ayeq123 on May 24, '07 12:01:48PM

The potential trouble with this script is that the mult-volume option in tar is limited to files of a certian size. I believe about 2GB from what I recall. I made a script similar to this one a while ago and it would always die when it ran into my virtual PC hard drive.



[ Reply to This | # ]
A script to create multi-DVD-spanning backups
Authored by: harrisj on May 24, '07 02:18:00PM

Hmm, I've been using this script to archive my iMovie projects. I'm pretty sure all of them containe DV video files in excess of 2gb.



[ Reply to This | # ]
Fantastic
Authored by: ruaric on Jun 01, '07 11:31:53AM

I mean to try this as soon as possible.

You have done the hard bit that I have been too lazy to try and figure out. Thanks!! ;-)



[ Reply to This | # ]
A script to create multi-DVD-spanning backups
Authored by: blgrace on Aug 23, '09 03:42:14AM

This hint is awesome.
Thanks



[ Reply to This | # ]