All pastes #1760003 Raw Edit

Something

public text v1 · immutable
#1760003 ·published 2010-01-21 10:08 UTC
rendered paste body
#!/bin/bash

## This is the section you modify

DESTINATION=/we-love-external-backups
FSTYPE="vfat"
UUID="013A-2D52"

## End of section you modify

function find_device {
	DEVNAME="`find /dev/disk/by-uuid/ -type l -name $UUID -printf "%l"`"
	if [ -n "$DEVNAME" ]; then
		DEVNAME="/dev/`basename $DEVNAME`"
		if [ -z "`mount | grep "^$DEVNAME"`" ]; then
			echo "Mounting drive.."
			mount -t $FSTYPE $DEVNAME $DESTINATION
			EC=$?
			eval "$1=1"
		else
			echo "The drive is already mounted."
			EC=0
	## If you ever want to leave the drive mounted if it was
	## previously mounted before running this script, change
	## this next line to read 'eval "$1=0"'
			eval "$1=1"
		fi
	else
		echo "The drive (UUID=$UUID) is not connected."
		EC=1
	fi
	return $EC
}

find_device UNMOUNT
if [ $? -eq 0 ]; then
	echo "Ok, starting backup at `date +%r`"
	## Comands to copy stuff go here
	
	
	
	## End of cmmands to copy stuff
	echo "Backup ended at `date +%r`"
	if [ $UNMOUNT -eq 1 ]; then
		echo "Unmounting drive.."
		umount $DEVNAME
	else
		echo "Drive was mounted prior to running script, leaving it mounted."
	fi
else
	echo "Couldn't find the drive or it failed to mount."
fi