11.3. Backup Server Scripts
The ssh scripts above have a possible security problem. If you run them on a firewall, the firewall has to have access via ssh to the backup server. In that case, a clever cracker might also be able to crack the backup server. It would be more secure to run backup and restore scripts on the backup server, and let the backup server have access to the firewall. That is what these scripts are for.
Rename them to get.x and restore.x where x is the name of the target computer. Edit them (the variable $target's initialization) to use the target computer's host name, or rewrite them to use a command line argument.
These scripts backup and restore the target completely, not just the stage one backup and restore. Also, note that get.tester backs up the ZIP disk as well, in case you need to replace a faulty ZIP disk.
I use these scripts routinely.
11.3.1. get.tester
  Â
#! /bin/sh# Back up another computer's drive to this system. To make this work, # we need a convenient chunk of disk space on this computer. This # version uses ssh to do its transfer, and compresses using bz2. This # version was developed so that the system to be backed up won't be # authenticated to log onto the backup computer. This script is # intended to be used on a firewall. You don't want the firewall to be # authenticated to the backup system in case the firewall is cracked.# Time-stamp: <2006-04-05 20:36:00 ccurley get.tester># Copyright 2000 through the last date of modification Charles Curley.# This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version.# This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details.# You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA# You can also contact the Free Software Foundation at http://www.fsf.org/# For more information contact the author, Charles Curley, at # http://www.charlescurley.com/.# 2004 04 03: added /sys to the list of excludes. It is a read-only # pseudo-file system like /proc.# 2002 07 01: We now set the path on the target to the zip drive with # a variable. This fixes a bug in the command to eject the zip disk.# 2002 07 01: The zip disk archives are now in bzip2 format, so this # script has been changed to reflect that. # The host name of the computer to be backed up. target=tester #zip=/mnt/zip export zip="/var/bare.metal";# Where we will put archives. Not the ZIP drive here.echo Backing up $targetecho Aging the ZIP disk backups.rm -r $target.old.zipmv $target.zip $target.old.zip# ssh $target "modprobe ppa ; mount -r $zip"echo Copying the ZIP disk.# -r for recursive copy, -p to preserve times and permissions, -q for # quiet: no progress meter.scp -qpr $target:$zip $target.zipdu -hs $target.*zip echo Aging the archivesrm $target.tar.old.bz2mv $target.tar.bz2 $target.tar.old.bz2echo Cleaning out old yum packages ssh $target "yum clean packages"echo Backing up $target to the backup server.# The "--anchored" option is there to prevent --exclude from excluding # all files with that name. E.g. we only want to exclude /sys, not # some other sys elsewhere in the file system.ssh $target "cd / ; tar -cf - --anchored --exclude sys --exclude $zip\ --exclude $zip.old --exclude mnt --exclude proc --exclude var/spool/squid\ *" | bzip2 -9 | cat > $target.tar.bz2# ssh $target "eject $zip"echo Testing the results. find . -iname "*.bz2" |
* License
* Backup and Recovery How-To Index
SHARE