Advertisement

10.13.2008 at 02:36PM PDT, ID: 23810972
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

virtual server backup

Asked by 03671328 in Microsoft Virtual Server, VB Script

Tags:

looking for a reason as to why the fallowing script will not give the reason why the xcopy failed
any info will be helpfull thanksStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
Set objShell = CreateObject ("WScript.Shell")
 
'local computer computer name
strTime = "local computer"
 
'net use share name
strNetShare= "share name here"
 
'backup computer name
strRemotepc = "ipaddress here"
 
'backup freenas server name
strnasdevice = "computer name here"
 
'location for the daily backup
strold = "W:"
 
'backup location for the old files
strolderfiles = "ip address here"
 
'backup directory drive
strBackupDrive= "Z:"
 
'Drive containing Virtual Machines
strVMdrive = "E:" 
 
'VM folder path
strVMfolder = "\virtual"
 
'available drive letter used to mount shadow copy
strTempDrive = "x:"
 
'nas device drive
strnas = "N:"
'nas computername
strnascomputer = "nas name here"
'nas sharename
strnasdevice ="nas share here"
 
'shadow command file
sExCmd = "CreateVSS.cmd"
 
'logs for program
sLog = "logs.txt"
 
'cleanup file
scleanup = "cleanup.cmd"
 
 
'email variables
'-------------------------------
 
'email address 1
stremail1 = "bla2@bla.com"
 
'email address 2
stremail2 = "bla@bla.com"
 
'from host email
strfrom = "backup@bla.com"
 
'mailserver
strmailserver = "mail.bla.com"
 
'message subject
strsubject= "bla backup"
 
'===================YOU SHOULD NOT NEED TO CHANGE ANYTHING BELOW THIS LINE========================================
 
 
 
 
 
 
dim result
'get the day of week
'---------------------------------
dtmTargetDate = date()  
intDay = WeekDay(dtmTargetDate)
if intDay= 1 then
strday = "Sun"
end if
if intDay= 2 then
strDay = "Mon"
end if
if intDay= 3 then
strDay = "Tues"
end if
if intDay= 4 then
strDay = "Wed"
end if
if intDay= 5 then
strDay = "thurs"
end if
if intDay= 6 then
strDay = "fri"
end if
if intDay= 7 then
strDay = "Sat"
end if
'---------------------------------
'get the week number 1-6
'-------------------------------------------------
dtmDay = DatePart("d", dtmTargetDate)
dtmMonth = DatePart("m", dtmTargetDate)
dtmYear = DatePart("yyyy", dtmTargetDate)
dtmStartDate = dtmMonth & "/1/" & dtmYear
dtmStartDate = CDate(dtmStartDate)
intWeekday = Weekday(dtmStartDate)
intAddon = 8 - intWeekday
intWeek1 = intAddOn
intWeek2 = intWeek1 + 7
intWeek3 = intWeek2 + 7
intWeek4 = intWeek3 + 7
intWeek5 = intWeek4 + 7
intWeek6 = intWeek5 + 7
'-------------------------
'get the day of the week
'-------------------------
If dtmDay <= intWeek6 Then
    strTime1 = "Week 6"
End If
If dtmDay <= intWeek5 Then
    strTime1 = "Week 5"
End If
If dtmDay <= intWeek4 Then
    strTime1 = "Week 4"
End If
If dtmDay <= intWeek3 Then
    strTime1 = "Week 3"
End If
If dtmDay <= intWeek2 Then
    strTime1 = "Week 2"
End If
If dtmDay <= intWeek1 Then
    strTime1 = "Week 1"
End If
 
'--------------------------------------------------
 
'daily backup
stroldbackup = strold &"\"& strDay
 
' Backup target folder or UNC path
strBackupDir = strBackupDrive &"\" & strTime
 
'log file creation
set FileSys = CreateObject("Scripting.FileSystemObject")
if FileSys.FileExists(sLog) then FileSys.DeleteFile(sLog)
set oLog = FileSys.CreateTextFile(sLog,CopyOverwrite)
 
'write all vars to the log file for verfication
olog.writeline("local computer computer name: "& strTime)
olog.writeline("backup computer name: "& strRemotepc)
olog.writeline("backup freenas server name: "&strnasdevice)
olog.writeline("location for the daily backup: "&strold)
olog.writeline("backup directory drive: "&strBackupDrive)
olog.writeline("Drive containing Virtual Machines: "&strVMdrive)
olog.writeline("VM folder path: "& strVMfolder)
olog.writeline("available drive letter used to mount shadow copy: "& strTempDrive)
olog.writeline("nas device drive: "& strnas)
olog.writeline("shadow command file: "& sExCmd)
olog.writeline("logs for program: "& sLog)
 
 
'place time of day in file
olog.writeline("backup created at" &date &" "& time)
 
'create commands for shadow copy
Set oFileSys = CreateObject("Scripting.FileSystemObject")
if oFileSys.FileExists(sExCmd) then oFileSys.DeleteFile(sExCmd)
set oExCmd = oFileSys.CreateTextFile(sExCmd, CopyOverwrite)
 
' Create Shadow copy of VM drive
oExCmd.WriteLine "set startdate=%date%"
oExCmd.WriteLine "set starttime=%time%"
oExCmd.WriteLine "vshadow.exe -script=setvar1.cmd -p " & strVMdrive
oExCmd.WriteLine "call setvar1.cmd"
oExCmd.WriteLine "vshadow.exe -el=%SHADOW_ID_1%," &strTempDrive
oExCmd.WriteLine "net use "&strBackupDrive&" \\"&strRemotepc&"\"&strNetShare
oExCmd.WriteLine "net use "&strnas&" \\"&strnascomputer&"\"&strnasdevice
oExCmd.WriteLine strnas
oExCmd.WriteLine "mkdir " & strTime1
oExCmd.WriteLine "net use "&strold&" \\"&strolderfiles&"\V_M_backup"
oExCmd.WriteLine "dir "&strold
oExCmd.WriteLine "dir "&strBackupDrive
oExCmd.WriteLine "dir "&strnas
oExCmd.WriteLine strBackupDrive
oExCmd.Close
 
'run shadow copy
'result = read_lines(sExCmd)
'if u want to log the shadowcopy data please uncomment above line and then comment between the lines
'---------------------------------------------
 set objExecObject = objShell.exec(sExCmd)
  Do Until objExecObject.StdOut.AtEndOfStream
   strLine = objExecObject.StdOut.ReadLine()
   strIP = Instr(strLine,"Address")
  Loop
'---------------------------------------------
olog.writeline("shadow copy completed at "& Month(Now) & "-" & Day(Now) & "-" & Year(Now) &_
  "_" & hour(now) & "-" &  minute(now))
'create backup of old data every day
olog.writeline ""
olog.writeline ""
olog.writeline "--------------------old files data-----------------------------"
olog.writeline "moving old files to the backup directory time is now "& Time
olog.writeline ("xcopy "&strBackupDir &" " &stroldbackup&" /s /i /y")
result = read_lines("xcopy "&strBackupDir &" " &stroldbackup&" /s /i /y")
olog.writeline "finnished moving old data at " & Time
olog.writeline "--------------------end of old files move----------------------"
olog.writeline ""
olog.writeline ""
 
'weekly backups only runs on firday 
'intday = 1-6
'1 = Sunday
'2 = Monday
'3 = Tuesday
'4 = Wendsday
'5 = Thursday
'6 = Friday
'7 = Saturday
 
if intDay = 6 then
olog.writeline "preparing for nasbackup"
'start backup to nas device
olog.writeline ""
olog.writeline ""
olog.writeline "-----------------------friday backup data----------------------------"
olog.writeline "backup for freenas started at"& time
olog.writeline ("xcopy "&strTempDrive&strVMfolder& " " &strnas&"\"&strTime1&" /s /i /y")
result = read_lines("xcopy "&strTempDrive&strVMfolder& " " &strnas&"\"&strTime1&" /s /i /y")
olog.writeline "backup to freenas ended at" & time
olog.writeline "-----------------------friday data ended-----------------------------"
olog.writeline ""
olog.writeline ""
end if
 
 
'startbackup
olog.writeline "-------------------------virtual server data----------------------"
olog.writeline "backup to vs2 started at"& time
olog.writeline "xcopy "&strTempDrive&strVMfolder& " " &strBackupDir&" /s /i /y"
result = read_lines("xcopy "&strTempDrive&strVMfolder& " " &strBackupDir&" /s /i /y")
olog.writeline "backup to vs2 ended at" & time
olog.writeline "-------------------------virtual sever data end-------------------"
olog.writeline ""
olog.writeline ""
 
'cleanup starts
 
Set oFileSys1 = CreateObject("Scripting.FileSystemObject")
set oExCmd1 = oFileSys.CreateTextFile(scleanup, CopyOverwrite)
oExCmd1.writeline "Echo y | vshadow.exe -da"
oExCmd1.writeline "net use "& strBackupDrive &" /delete"
oExCmd1.writeline "net use "& strnas &" /delete"
oExCmd1.writeline "net use "& strold&" /delete"
oExCmd1.writeline "Echo y | del C:\setvar1.cmd"
oExCmd1.writeline "Echo y | del C:\CreateVSS.cmd"
oExCmd1.writeline "Echo y | del C:\cleanup.cmd"
oExCmd1.close
result = read_lines("C:\cleanup.cmd")
 
'email
result = read_lines("C:\sendEmail.exe -f "&strfrom&" -u "&strsubject&" -t "&stremail2&" -o message-file=C:\logs.txt -s "&strmailserver)
result = read_lines("C:\sendEmail.exe -f "&strfrom&" -u "&strsubject&" -t "&stremail1&" -o message-file=C:\logs.txt -s "&strmailserver)
 
'-------------function that will launch the exe / bat ect. to read the output to a text file creating a log
Function read_lines(x)
 set objExecObject = objShell.exec(x)
  Do Until objExecObject.StdOut.AtEndOfStream
   strLine = objExecObject.StdOut.ReadLine()
   strIP = Instr(strLine,"Address")
   oLog.WriteLine strLine
  Loop
End Function
oLog.Close
[+][-]10.13.2008 at 02:52PM PDT, ID: 22706840

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.15.2008 at 05:23AM PDT, ID: 22720074

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.15.2008 at 07:13AM PDT, ID: 22721286

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.15.2008 at 07:35AM PDT, ID: 22721534

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.15.2008 at 07:39AM PDT, ID: 22721591

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.20.2008 at 06:05PM PDT, ID: 22763670

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Virtual Server, VB Script
Tags: microsoft virtual server
Sign Up Now!
Solution Provided By: 03671328
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628