Hi
I have a set of databases that back up to their local machine and a network timeout or something that stops them from backing up over a network share. I am trying to create a system that copies the backup over the network separately to SQL Server.
One of the DBs is 16GB and takes quite a while to copy not sure how long but it's certainly not instantaneous.
the code I have is as follows. essentially what it is meant to do is:
- look at the destination folder, check out to see if any duplicate files exist (there will be of course: yesterday's backup)
- move any duplicates to a separate archive folder (anywhere out of the way really)
- move the new backups in.
an added complication is that the day-before-yesterday's backups will be in the archive folder so i delete those (they are simple backups anyway, so unnecessary)
The code is here:
Code:
Dim folder1 AsNew DirectoryInfo(sSourceDirectory19)
Dim folder1a AsNew DirectoryInfo(sTargetDirectory19)
Dim folder1b AsNew DirectoryInfo(sArchiveDirectory19)
Dim fileList1 As FileInfo() = folder1.GetFiles()
Dim fileList1a As FileInfo() = folder1a.GetFiles()
Dim fileList1b As FileInfo() = folder1b.GetFiles()
Dim file1 As FileInfo
Dim file1a As FileInfo
Dim file1b As FileInfo
Try
IfNot (Directory.Exists(sTargetDirectory19)) Then
Directory.CreateDirectory(sTargetDirectory19)
EndIf
ForEach file1a In fileList1a
'for each backup file in source check to see if there is a
'file of the same name in the target on R51 (Step1). If there is
'delete any archive files(step3).
'finally move the pre-existing file to archive folder(Step2) and move the backup to the backup folder.
ForEach file1 In fileList1
'Step1
If file1.Name = file1a.Name Then
ForEach file1b In fileList1b
'step2
Debug.Print("Exists " & file1a.Name.ToString)
If file1b.Name = file1a.Name Then
Debug.Print("Archive Exists " & file1b.Name.ToString)
file1b.Delete()
EndIf
Next
'step3
Debug.Print("No files in archive")
file1a.MoveTo(sArchiveDirectory19 & file1a.Name)
file1.MoveTo(sTargetDirectory19 & "\" & file1.Name)
Else
Debug.Print("Not exists " & file1.Name.ToString)
EndIf
Debug.Print("last file = " & file1.Name.ToString)
Next
'file1.MoveTo(sTargetDirectory19 & "\" & file1.Name)
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
file1 = Nothing
fileList1 = Nothing
folder1 = Nothing
file1a = Nothing
fileList1a = Nothing
folder1a = Nothing
file1b = Nothing
fileList1b = Nothing
folder1b = Nothing
EndTry
When copying the 16Gig file the code runs but once it has done step3, the for loop doesn't go on the Next statement to start again. It doesn;t even hit the End If. The only exception I have got from the runtime is that the network name is no longer available which is not correct.
I think some kind of timeout is at work but I haven't the faintest idea how I sort it out.
Can someone help to give me an I dea of where I go from here?
Thanks in advance
Rob.