Click to See Complete Forum and Search --> : Tar File > 2GB Workaround.


voidinit
12-04-2003, 05:05 AM
I have more than 18GB of mp3's on a partition. I recently wrote a script to backup them up to a remote smb share nightly via cron. Here is the script.

#!/bin/bash
if [ `id -u` != 0 ]; then
echo "You must be root to do this man, what where you thinking?"
exit 1;
fi


#Make sure /mnt/mp3 and /mnt/backup are mounted

if grep -w /mnt/backup /etc/mtab 1> /dev/null 2> /dev/null; then
echo "/mnt/backup is mounted already"
mountbackup="1"
else
echo "Attempting to mount /mnt/backup using /etc/fstab"
/sbin/mount /mnt/backup
if [ echo $? != "0" ]; then
echo "Failure Mounting /mnt/backup"
exit 1;
fi
echo "Success!"
mountbackup="0"
fi
if grep -w /mnt/mp3 /etc/mtab 1> /dev/null 2>/dev/null; then
echo "/mnt/mp3 is mounted already"
mountmp3="1"
else
echo "Attempting to mount /mnt/mp3 using /etc/fstab"
/sbin/mount /mnt/mp3
if [ echo $? != "0" ]; then
echo "Failure mounting /mnt/mp3"
exit 1;
fi
echo "Success!"
mountmp3="0"
fi
echo "Clearing Log File"
echo " " > /var/log/mp3backup.log
echo "Starting backup @ `date`"
echo "Logging to /var/log/mp3backup.log"
cp -Rv /mnt/mp3 /mnt/backup >& /var/log/mp3backup.log
#If mnt/backup and /mnt/mp3 weren't mounted to begin wtih, unmount them

if [ $mountbackup = "0" ]; then
echo "Unmount /mnt/backup"
umount /mnt/backup
fi

if [ $mountmp3 = "0" ]; then
echo "Unmounting /mnt/mp3"
umount /mnt/mp3
fi


Notice I am using cp -R to copy the mp3's over to the smb share. I'm doing this because the file system of the share doesn't support files greater than 2GB! I would really like to tar and gzip these backups. I know that tar can create mulitple volumes of any specified size. So I could use a multi-volume archive with each volume having a size of 1.9GB. However, tar prompts me to hit a key to continue writing the next archive. Does anyone know of any workaround to increment the file name (e.g. archive1.tgz, archive2.tgz) as well as automate the keypress tar waits for between volumes?

jim mcnamara
12-09-2003, 10:59 AM
Have you thought about split?

find . -size n4194394 -exec split -b 1024m {} \;

which makes any file => 2GB into 1GB file chunks.

To restore the file means you'd have to open the child files as binary (in C) and write them back to one large file. You could also put together your own version of split.

And then use backup, gzip for file groups created with output aimed across to the shared drive. You do not have to tar files. backup also marks a backup date on files, so once you've made a backup, the next time you run it, you can set it to ignore files that are unchanged since the last backup.

voidinit
12-09-2003, 01:20 PM
Ha! Awesome! I've got it rudimentarily implemented. I'm still working on that "not changed! Dont Update!" part.