Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Dec 2000 23:40:22 -0800
From:      "Crist J . Clark" <cjclark@reflexnet.net>
To:        Aaron Navratil <anavratil@icplanet.com>
Cc:        "'freebsd-questions@freebsd.org'" <freebsd-questions@FreeBSD.ORG>
Subject:   Re: dump over ssh
Message-ID:  <20001206234022.P99903@149.211.6.64.reflexcom.com>
In-Reply-To: <B155B68E3C16D411BAB100508BAD0AEB308B3B@exchange01.athensnetwork.com>; from anavratil@icplanet.com on Wed, Dec 06, 2000 at 11:49:34AM -0800
References:  <B155B68E3C16D411BAB100508BAD0AEB308B3B@exchange01.athensnetwork.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--sm4nu43k4a2Rpi4c
Content-Type: text/plain; charset=us-ascii

On Wed, Dec 06, 2000 at 11:49:34AM -0800, Aaron Navratil wrote:
> 	has anyone sucessfully dumped a file system to a remote host using
> ssh if so can you show me your script or command line options? 

 $ dump -0f - /filesystem | ssh remote-host "restore -rf -"

I used to do it all of the time. Attached is a script I used to use to
backup a filesystem on another machine. It's pretty heavily
commented. The script actually does the opposite of the above. It is
run on the machine doing the restore.
-- 
Crist J. Clark                           cjclark@alum.mit.edu

--sm4nu43k4a2Rpi4c
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=mailsync

#!/bin/sh
#
# Copyright (c) 1999, Crist J. Clark, cjclark@alum.mit.edu
#    Redistribution and modification permitted provided this
#    notice is left intact and modifications from the original
#    are clearly noted as such. The author requests, but does not 
#    require, that any improvements, fixes, or extensions made 
#    to the code be forwarded to him.
#
# Usage: mailsync [-f]
#
# Does a daily dump to keep files on the mailserver and its backup
# in sync. The script should be run by root on the backup machine.
#
# The '-f' switch causes a full backup to be run. A full dump is also
# done if information about the previous dump cannot be found. 
# Otherwise, only files changed since the last dump are backed up.

#
# WARNING!!!
#
# This procedure never takes into account the fact that files 
# can disappear from the main server. BACKED UP FILES ARE NOT 
# DELETED WHEN THEY DISAPPEAR FROM THE SERVER.

# Executable full paths
SSH=/usr/bin/ssh
DUMP=/sbin/dump
RESTORE=/sbin/restore

# Server we are backing up
SERVER=newmail

# Each filesystem to be backed up is paired with a destination directory
FILESYSPAIRS="/     /u0      \
              /usr  /u0/usr  \
              /var  /u0/var  \
              /home /u0/home"

# Where we store info about dumps
DUMPTIME=/etc/dumptime.$SERVER

# Files in this directory clobber files we have just backed up
OVRWRTDIR=/root/BackupOverwrites

# #####################################################################
# Nothing below this point should need changing

CMD=`basename $0`
usage() {
    echo "usage: $CMD [-f]" >&2
}

errmsg() {
    echo "$CMD: $*" >&2
}

set -- `getopt f $*`

if [ $? -ne 0 ]; then
    usage
    exit 1
fi

for ARG in $*; do
    case "$ARG" in
	-f) FULLDUMP=YES; shift;;
	--) shift; break;;
	*)  errmsg "internal error"; exit 2;;
    esac
done

if [ $# -gt 0 ]; then
    usage
    exit 1
fi

set -- $FILESYSPAIRS

# Check if this is an incremental or a full dump
if [ X"$FULLDUMP" = X"YES" ] || [ ! -f $DUMPTIME ]; then
    DUMPLEVEL="-0"
else
    DUMPLEVEL="-T \"`cat $DUMPTIME`\""
fi

# Store time of this dump-restore
date +"%a %b %e %H:%M:%S %Y" > $DUMPTIME

while [ $1 ] && [ $2 ]; do
    # Change to restore filesystem
    if ! cd $2; then
	errmsg "bad local destination, $2"
    else
	# Dump the filesystem
	$SSH $SERVER "$DUMP $DUMPLEVEL -a -f - $1" | $RESTORE -xyuf -
    fi

    shift; shift
done

# Do overwrites
if [ -d $OVRWRTDIR ]; then
    LOCALROOT=`echo $FILESYSPAIRS | awk '{ print $2 }'`

    # This is a special consideration for clearing the kernel schg flag
    chflags noschg $LOCALROOT/kernel

    tar cf - -C $OVRWRTDIR . | tar xf - -C $LOCALROOT

    # Reset flag on kernel
    chflags schg $LOCALROOT/kernel
fi

exit 0

#End -- NOT REACHED 

--sm4nu43k4a2Rpi4c--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001206234022.P99903>