This works (tested) on Server 2003, where vshadow can mount a shadow copy as a
directory.
1. Download cygwin 1.7+ from the regular place
2. install the default system, plus the following: cygrunsrv, openssh, and
rsync
3. I also install joe (my editor of choice), and procps (for top)
4. start a cygwin shell and type:
# ssh-host-config -y
# cygrunsrv -S sshd
5. I then attempt to ssh into my backupPC system from cygwin, just a nice test,
and creates the .ssh directory for me.
6. Copy BackupPC's public key over
# scp r...@backuppc:/var/lib/backuppc/BackupPCkey.pub ~/.ssh/authorized_keys
7. Install the following scripts to Administrators home directory
pre-backuppc.sh
---------------
$ #!/bin/bash
# script to create shadow copies of Windows drives and export them to a
# drive letter for BackupPC backup
# the shadow copies get mount to c:\shadow\(drive letter). The directory
# structure must exist
# Launches passed input via 'at' to get around $USERNAME=SYSTEM
# problem under ssh login where the shell lacks permsisions to run
# commmands like vshadow or dosdev
# from a script by Jeffrey J. Kosowsky
function at_launch ()
{
local h m s wait1 command
if [ $3 != "" ] ; then
command="${1} ${2} >> ${3}"
else
command="${1} ${2}"
fi
set -- $(date +"%H %M %S")
h=$((10#$1)) #Note explicitly use base 10 so that 08 and 09 not interpreted as
bad octal
m=$((10#$2 +1)) #Advance minutes by 1
s=$((10#$3))
wait1=$((60 - $s))
[ $s -gt 55 ] && let "m += 1" "wait1 += 60" # Make sure >5 seconds left
[ $m -ge 60 ] && let "m %= 60" "h += 1" #Overflow minutes
let "h %= 24"
at $h:$m $(cygpath -w $(which bash.exe)) -c \"$command\"
# > /dev/null
echo Running \'$command\' at $h:$m
return $wait1
}
# create the command to shadow the drive, and wait 2 minutes plus the seconds
# before the at command runs before returning (make sure shadow copy is made)
function shadow_drive ()
{
date
echo Shadowing Drive $@
local wait1
drive=$@
at_launch "/cygdrive/c/WINDOWS/vshadow.exe -p" $drive
"/home/Administrator/vshadow-out"
wait1=$?
let "wait1 += 120"
echo sleeping for $wait1
sleep $wait1
date
echo done sleep
}
# get the guids from the vshow-out file and place them into the shadow-guids
# file for the post-backuppc scripts use (and hours for mapping to directory)
function get_guids ()
{
echo Getting shadow copy GUIDS
cat ~/vshadow-out | grep "* SNAPSHOT ID" | awk '{print $5}' >> ~/shadow-guids
}
function map_shadow ()
{
echo Mapping GUID $1 to $2
local wait1
local guid="$1"
local dir="$2"
at_launch /cygdrive/c/WINDOWS/vshadow.exe -el=$guid,$dir
"/home/Administrator/map.out"
wait1=$?
let "wait1 +=30"
sleep $wait1
}
date
# get rid of the guids file if it exists
rm ~/shadow-guids
rm ~/vshadow-out
rm ~/map.out
sleep 10
# create the snapshots
# *EDIT* edit this to match the system
shadow_drive c:
shadow_drive d:
# get the guids into a single file
get_guids
loop=0
# create the shadow directory structure AFTER we make the shadow copies
# the post-backuppc.sh script deletes this tree after removing the mounts
mkdir /cygdrive/c/shadow
mkdir /cygdrive/c/shadow/c
mkdir /cygdrive/c/shadow/d
# loop throuh the guids and map to mount point
# assumes guids in file are in order of shadows created
while read line ;
do
if [ $loop == 0 ] ; then
map_shadow $line "c:\\\\\shadow\\\\\c"
fi
if [ $loop == 1 ] ; then
map_shadow $line "c:\\\\\shadow\\\\\d"
fi
let "loop += 1"
done < ~/shadow-guids
post-backuppc.sh
-------------------
$ #!/bin/bash
# script to delete the shadow copies used by backuppc
while read line ;
do
vshadow -ds=$line
done < ~/shadow-guids
# now clean up the directory structure
#rmdir /cygdrive/c/shadow
8. In the BackupPC config for the system (I use the web page to edit the
con:fig) Add the following
From: "Bowie Bailey" <bowie_bai...@buc.com>
To: backuppc-users@lists.sourceforge.net
Sent: Tuesday, June 8, 2010 11:24:24 AM
Subject: Re: [BackupPC-users] Complete cygwin/VSS/rsync solution for Windows
Backup
Gerald Brandt wrote:
> Hi,
>
> As of today, I have all my Windows Servers being backed up via rsync
> (not rsyncd) and ssh. I can now manage my Linux and Windows backups
> the same way.
>
> My solution doesn't require dosdev.exe, it uses vshadows ability to
> map a shadow copy to any directory.
>
> BackupPC ssh's into the windows box and runs my bash script
> 'pre-backuppc.sh', then ssh's in to do the rsync backup, and when
> done, ssh's in runs post-backuppc.sh.
>
> I borrowed some stuff from other peoples scripts (specifically the
> 'at' command stuff to get permissions to run vshadow.exe), and the
> rest is really simple.
>
> If anyone is interested, I can post the scripts here, and how I setup
> cygwin 1.7
>
Post it. It's always useful to have a complete solution posted to make
it easier on the next person.
-- Bowie
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________ BackupPC-users mailing
list BackupPC-users@lists.sourceforge.net
List: https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki: http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
BackupPC-users mailing list
BackupPC-users@lists.sourceforge.net
List: https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki: http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/