'==================== Lan File Automatic Backup vbs script ============================
'
'Condition: 10.97.1.x xcopy/xcopy belongs to Adminstrator.
'The directory where the shared backup file is located gives xcopy users full control!
'After running, there are two processes in the management process: wscript. EXE , Ping.exe
'Use the date as the log file name and only keep the logs for 7 days
'
'================================================ ======================================
Do While true
Dim F, txtfile
Set F = Createobject ("scripting. FileSystemObject ")
Set txtfile = f. opentextfile ("D: \ WEB \ barcodeprinter \ backup \" & Date & ". txt", 8, true)
'==== Determine whether the log file existed seven days ago. If yes, delete it!
If F. fileexists ("D: \ WEB \ barcodeprinter \ backup \" & date-5 & ". txt") then
F. deletefile ("D: \ WEB \ barcodeprinter \ backup \" & date-5 & ". txt ")
End if
'=
Txtfile. writeline ("========= real-time backup start:" & Date & "& time &" ========== ")
Txtfile. writeline ("")
Call backupfile (F, txtfile)
Wscript. Sleep 10000
Txtfile. writeline ("========= real-time backup end:" & Date & "& time &" ========== ")
Txtfile. writeline ("")
Set F = nothing
Set txtfile = nothing
Loop
'------------------------------------ Real-time backup process -----------------------------------
Sub backupfile (F, txtfile)
Dim path, FSO, Net
Num = 1
Do While num <10
If num = 1 then
IP = "10.97.1.3" & num
Source_path = "\" & IP & "\ product digital tracking"
Target_path = "backup \ barcodeprinter31.mdb"
End if
If num = 2 then
IP = "10.97.1.3" & num
Source_path = "\" & IP & "\ product digital tracking"
Target_path = "backup \ barcodeprinter32.mdb"
End if
If num = 3 then
IP = "10.97.1.3" & num
Source_path = "\" & IP & "\ product digital tracking"
Target_path = "backup \ barcodeprinter33.mdb"
End if
If num = 4 then
IP = "10.97.1.3" & num
Source_path = "\" & IP & "\ product digital tracking"
Target_path = "backup \ barcodeprinter34.mdb"
End if
If num = 5 then
IP = "10.97.1.3" & num
Source_path = "\" & IP & "\ qjcf_no1"
Target_path = "backup \ barcodeprinter35.mdb"
End if
If num = 6 then
IP = "10.97.1.3" & num
Source_path = "\" & IP & "\ barcodeprinter )"
Target_path = "backup \ barcodeprinter36.mdb"
End if
If num = 7 then
IP = "10.97.1.3" & num
Source_path = "\" & IP & "\ barcodeprinter )"
Target_path = "backup \ barcodeprinter37.mdb"
End if
If num = 8 then
IP = "10.97.1.3" & num
Source_path = "\" & IP & "\ product digital tracking"
Target_path = "backup \ barcodeprinter38.mdb"
End if
If num = 9 then
IP = "10.97.1.3" & num
Source_path = "\" & IP & "\ barcodeprinter )"
Target_path = "backup \ barcodeprinter39.mdb"
End if
'
IP = "10.97.1.3" & num
Source_path = "\" & IP & "\ product digital tracking"
Target_path = "D: \ WEB \ barcodeprinter \ backup \ barcodeprinter3" & num & ". mdb"
'------------ Ping test,NetworkPing = "T ";-------------------
Set filesys = Createobject ("scripting. FileSystemObject ")
Set wshshell = Createobject ("wscript. Shell ")
Retcode = wshshell. Run ("ping" & IP, 0, true)
If retcode = 0 then' Ping test passed
Ping = "T"
Else
Ping = "F"
End if
Set filesys = nothing
Set wshshell = nothing
'------------ Ping ends ------------------------------------
If Ping = "T" then
On Error resume next 'error not displayed, execute the next
Path = "X :"
Set FSO = Createobject ("scripting. FileSystemObject ")
Set net = Createobject ("wscript. Network ")
If not FSO. driveexists (FSO. getdrivename (PATH) then
Net. mapnetworkdrive path, source_path, false, "xcopy", "xcopy"
End if
Set file = FSO. GetFile (Path & "\ barcodeprinter. mdb ")
File. Copy (target_path)
Net. removenetworkdrive path, true
If err. Number <> 0 then
Txtfile. writeline ("---" & IP & "backup failed! "& Date &" & time)
Else
Txtfile. writeline ("---" & IP & "backed up successfully! "& Date &" & time & "--- OK! ")
End if
Else
Txtfile. writeline ("---" & IP & "Network unavailable! "& Date &" & time)
End if
Set FSO = nothing
Set net = nothing
Num = num + 1
Loop
End sub
'------------------------------------ Real-time backup process -----------------------------------
the file backed up here is barcodeprinter. MDB. database file, you can perform Code modification