@echo off CLS rem On the 2 servers rem To be run on the destination server after RemoveNode.bat on the source server SETLOCAL ENABLEDELAYEDEXPANSION rem Do not forget to edit volume names below set DOMAIN=mydomain.com Set SRCSRV=server1 Set DSTSRV=server2 Set DNSSRV=mydnsserver rem DNS List, usually one Set CNAMES=DNS1,DNS2 Set DRIVES=X,Y rem Only if LUNs created automatically rem Names declared on SAN Set SANVOLUMES=volume1 volume2 rem Checks drives aren't mounted on the other node for /D %%D in (%DRIVES%) DO ( reg query \\%SRCSRV%\HKLM\SYSTEM\MountedDevices /v \DosDevices\%%D: 2>NUL 1>NUL if !ERRORLEVEL!==1 ( echo %%D is mounted on the other node echo CANCELLING FAILOVER goto end ) ) echo Drive letters available on %SRCSRV% echo =^> STARTING FAILOVER echo. rem Only if procedure to create LUNs has been written rem LUN Failover echo Recreating LUNs on SAN perl remapSanVolumes.pl %SRCSRV% %DSTSRV% %SANVOLUMES% echo. rem Scan for new disks echo Scanning for new disks devcon rescan echo. rem Mount volumes rem To be edited with your own values rem Mount the disks manually the first time rem and run mounvol to display volume names echo Assigning letters to drives mountvol X: \\?\Volume{34520568-7569-11de-86b9-00237de94c0e}\ mountvol Y: \\?\Volume{b888bf7f-7248-11de-a110-002481ae4646}\ echo. rem checkdisk for /D %%D in (%DRIVES%) DO ( chkdsk /F /X %%D: ) echo. rem Restart share service echo restarting services net stop "Server" /y net start "Net Logon" net start "Computer Browser" net start "Distributed File System" rem DNS Change echo Changing DNS for /D %%N in (%CNAMES%) DO ( dnscmd %DNSSRV% /recorddelete %DOMAIN% %%N CNAME /f dnscmd %DNSSRV% /RecordAdd %DOMAIN% %%N 60 CNAME %DSTSRV%.%DOMAIN% ) echo. rem Extra, can be useful if DHCP Failover needed rem Checks if DHCP is running on the other server For /F "Tokens=4" %%I in ('sc \\%SRCSRV% query DHCPServer ^|findstr STATE') Do ( if %%I == RUNNING ( echo DHCP actif sur %SRCSRV% echo PAS DE BASCULE DHCP goto end ) echo Demarrage du DHCP net start DHCPServer ) :end ENDLOCAL