Hi all,
I have to copy folder all the time between multiple server and it getting to be time consuming. I want to create a batch script to do this for me. I have 6 servers in a domain i want to log onto 1 server and run the script to backup all the folders.
server 1 10.5.10.1
server 2 10.5.10.2
server 3 10.5.10.3
server 4 10.5.10.4
server 5 10.5.10.5
server 6 10.5.10.6
The folder i want to backup is c:\program files\orbit
need to be backed up to d:\data\backup\todays date if c drive not exist then c:\data\backup todays date. The batch file must also be ease to change since i want to take it to my other sites. All these folders are shared. any help to point me in the right direction would be appreciated.
Thanks
This is untested, but it should be pretty close.
@echo offsetlocal
REM setting up proper date variable for destination file name
set _my_datetime=%date%_%time%
set _my_datetime=%_my_datetime: =_%
set _my_datetime=%_my_datetime::=%
set _my_datetime=%_my_datetime:/=_%
set _my_datetime=%_my_datetime:.=_%echo 10.5.10.1 > list.tmp
echo 10.5.10.2 >> list.tmp
echo 10.5.10.3 >> list.tmp
echo 10.5.10.4 >> list.tmp
echo 10.5.10.5 >> list.tmp
echo 10.5.10.6 >> list.tmpREM looping through list.tmp to perform tasks on each server
for /f "tokens=*" %%a in (list.tmp) do (
REM check to see if D drive exists, if it does set drive variable equal to d and skip to the copy operation
if exist %%a\d$\*.* set drive=d && goto startcopy
REM if it doesn't set drive variable equal to c
set drive=c
:startcopy
copy "c:\program files\orbit" "\\%%a\%drive%$\data\backup\%_my_datetime%" /y
)
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |