Re: Correct way to use dump to backup a Samba share

2007-07-09 Thread L Goodwin
Thanks for filling in the blanks, Roland!

--- Roland Smith <[EMAIL PROTECTED]> wrote:

> On Sat, Jul 07, 2007 at 06:42:20PM -0700, L Goodwin
> wrote:
> > I have a Samba share on a software RAID 1 array
> (using
> > gmirror) that I need to backup. I want to create a
> > shell script that does a level 0 backup every time
> to
> > (alternately) one of two USB drives. I plan to
> have
> > only ONE USB drive connected at a time. 
> > 
> > I want the script to mount the drive, perform the
> > backup, then unmount the drive so that it is ready
> for
> > someone who knows zip about computers to safely
> remove
> > and take offsite. 
> > 
> > Here are the steps I have for the script.
> > Is this all I need to do? Do I need any error
> handling
> > logic? THANKS!
> 
> > # Mount the backup drive:
> > mount /dev/usb0
> > 
> > # Create the backup:
> > /sbin/dump -0u -f /dev/usb0 /sambavol
> > 
> > # Unmount the backup drive:
> > umount /dev/usb0
> 
> The following is a rough outline of what you should
> do;
> -- shell-script --
> #!/bin/sh
> # The following assumes that the USB mass-storage
> device is formatted
> # with a UFS filesystem
> 
> # Only root can perform dumps.
> if [ $(id -u) -ne 0 ]; then
> echo "Only root can perform dumps. Exiting."
> exit 1
> fi
> 
> DDIR=/mnt/root
> # First, check if the target directory exists
> if [ ! -d $DDIR ]; then
> echo "The $DDIR directory doesn't exist.
> Exiting."
> exit 1
> fi
> # Then check if it is already mounted
> if mount|grep $DDDIR >/dev/null; then
>echo "The $DDIR directory is already in use.
> Exiting"
> exit 1
> fi
> 
> # Check if the device to dump to exists;
> DEV=/dev/da0
> if [ ! -c $DEV ]; then
> echo "The $DEV device doesn't exist. Exiting."
> exit 1
> fi
> # Check if the device is already mounted
> if mount|grep $DEV >/dev/null; then
>echo "The $DEV device is already mounted.
> Exiting"
>exit 1
> fi
> 
> SRC=/sambavol
> DFLAGS="-0 -u -f"
> # Check if the filesystem that is to be dumped
> exists.
> if [ ! -d $SRC ]; then
> echo "The $SRC directory doesn't exist.
> Exiting."
> exit 1
> fi
> # Now check if it is mounted
> if mount -t ufs|grep $SRC; then
>DFLAGS="-L "$DFLAGS
> fi
> 
> # Mount the USB device.
> if ! mount $DEV $DDIR; then
>"Mounting the USB disk failed. Exiting"
>exit 1
> fi
> 
> DATE=$(date "+%Y%m%d")
> # Perfrom the dump, assuming that the filesystem is
> live.
> dump $DFLAGS ${DDIR}/sambavol-0-${DATE}.dump $SRC
> 
> umount $DDIR
> -- shell-script --
> 
> Of course, you have to remove old dumps once in a
> while, lest you run
> out of disk space.
> 
> Depending on the contents of the samba share, it
> might be worthwhile to
> compress the dump with gzip;
> 
> # Perfrom the dump, 
> dump $DFLAGS - $SRC|gzip
> >${DDIR}/sambavol-0-${DATE}.gz
> 
> Roland
> -- 
> R.F.Smith  
> http://www.xs4all.nl/~rsmith/
> [plain text _non-HTML_ PGP/GnuPG encrypted/signed
> email much appreciated]
> pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321
> A725 (KeyID: C321A725)
> 



  

Park yourself in front of a world of choices in alternative vehicles. Visit the 
Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/ 
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Correct way to use dump to backup a Samba share

2007-07-08 Thread Roland Smith
On Sat, Jul 07, 2007 at 06:42:20PM -0700, L Goodwin wrote:
> I have a Samba share on a software RAID 1 array (using
> gmirror) that I need to backup. I want to create a
> shell script that does a level 0 backup every time to
> (alternately) one of two USB drives. I plan to have
> only ONE USB drive connected at a time. 
> 
> I want the script to mount the drive, perform the
> backup, then unmount the drive so that it is ready for
> someone who knows zip about computers to safely remove
> and take offsite. 
> 
> Here are the steps I have for the script.
> Is this all I need to do? Do I need any error handling
> logic? THANKS!

> # Mount the backup drive:
> mount /dev/usb0
> 
> # Create the backup:
> /sbin/dump -0u -f /dev/usb0 /sambavol
> 
> # Unmount the backup drive:
> umount /dev/usb0

The following is a rough outline of what you should do;
-- shell-script --
#!/bin/sh
# The following assumes that the USB mass-storage device is formatted
# with a UFS filesystem

# Only root can perform dumps.
if [ $(id -u) -ne 0 ]; then
echo "Only root can perform dumps. Exiting."
exit 1
fi

DDIR=/mnt/root
# First, check if the target directory exists
if [ ! -d $DDIR ]; then
echo "The $DDIR directory doesn't exist. Exiting."
exit 1
fi
# Then check if it is already mounted
if mount|grep $DDDIR >/dev/null; then
   echo "The $DDIR directory is already in use. Exiting"
exit 1
fi

# Check if the device to dump to exists;
DEV=/dev/da0
if [ ! -c $DEV ]; then
echo "The $DEV device doesn't exist. Exiting."
exit 1
fi
# Check if the device is already mounted
if mount|grep $DEV >/dev/null; then
   echo "The $DEV device is already mounted. Exiting"
   exit 1
fi

SRC=/sambavol
DFLAGS="-0 -u -f"
# Check if the filesystem that is to be dumped exists.
if [ ! -d $SRC ]; then
echo "The $SRC directory doesn't exist. Exiting."
exit 1
fi
# Now check if it is mounted
if mount -t ufs|grep $SRC; then
   DFLAGS="-L "$DFLAGS
fi

# Mount the USB device.
if ! mount $DEV $DDIR; then
   "Mounting the USB disk failed. Exiting"
   exit 1
fi

DATE=$(date "+%Y%m%d")
# Perfrom the dump, assuming that the filesystem is live.
dump $DFLAGS ${DDIR}/sambavol-0-${DATE}.dump $SRC

umount $DDIR
-- shell-script --

Of course, you have to remove old dumps once in a while, lest you run
out of disk space.

Depending on the contents of the samba share, it might be worthwhile to
compress the dump with gzip;

# Perfrom the dump, 
dump $DFLAGS - $SRC|gzip >${DDIR}/sambavol-0-${DATE}.gz

Roland
-- 
R.F.Smith   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)


pgpvIWffXtpp5.pgp
Description: PGP signature