From owner-freebsd-questions Wed Dec 6 23:40:36 2000 From owner-freebsd-questions@FreeBSD.ORG Wed Dec 6 23:40:32 2000 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mailhost01.reflexnet.net (mailhost01.reflexnet.net [64.6.192.82]) by hub.freebsd.org (Postfix) with ESMTP id 2FC0337B400 for ; Wed, 6 Dec 2000 23:40:32 -0800 (PST) Received: from 149.211.6.64.reflexcom.com ([64.6.211.149]) by mailhost01.reflexnet.net with Microsoft SMTPSVC(5.5.1877.197.19); Wed, 6 Dec 2000 23:38:51 -0800 Received: (from cjc@localhost) by 149.211.6.64.reflexcom.com (8.11.0/8.11.0) id eB77eNk70202; Wed, 6 Dec 2000 23:40:23 -0800 (PST) (envelope-from cjc) Date: Wed, 6 Dec 2000 23:40:22 -0800 From: "Crist J . Clark" To: Aaron Navratil Cc: "'freebsd-questions@freebsd.org'" Subject: Re: dump over ssh Message-ID: <20001206234022.P99903@149.211.6.64.reflexcom.com> Reply-To: cjclark@alum.mit.edu References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="sm4nu43k4a2Rpi4c" X-Mailer: Mutt 1.0i In-Reply-To: ; from anavratil@icplanet.com on Wed, Dec 06, 2000 at 11:49:34AM -0800 Sender: cjc@149.211.6.64.reflexcom.com Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --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