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?
#!/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?