如何实现Sybase自动备份

栏目:Sybase 来源:网络 关注:0 时间:2019-08-18

Sybase自动备份的方法我们经常会用到,下面就为您详细介绍Sybase自动备份的实现过程,希望对您学习Sybase自动备份方面能有所帮助。

Imports System.IO 
Module Module1 
Sub Main() 
Dim str_Path As String 
Dim str_FileName As String 
Dim str_Name As String 
Dim i As Integer, weeknum As Integer 
Dim f_file As System.IO.File 
Dim F_write As System.IO.StreamWriter 
Dim str_temp As String 
str_FileName = gbackupdump_data.txt 
If File.Exists(str_FileName) = True Then 
File.Delete(str_FileName) 
End If 
F_write = File.CreateText(str_FileName) 
F_write.WriteLine(use master) 
F_write.WriteLine(go) 
weeknum = Weekday(Now()) 
'每隔一天转储的文件名相同 
Select Case weeknum 
Case 1, 2, 4, 6 
F_write.WriteLine(select getdate()) 
F_write.WriteLine(go) 
F_write.WriteLine(dump database  bsjdw to 'g:/-/backup/-/dumpback/-/bsjdw_data0.dump') 
F_write.WriteLine(go) 
F_write.WriteLine(select getdate()) 
F_write.WriteLine(go) 
F_write.WriteLine(dump database  system to 'g:/-/backup/-/dumpbacksystem_data0.dump') 
F_write.WriteLine(go) 
F_write.WriteLine(select getdate()) 
F_write.WriteLine(go) 
Case 3, 5, 7 
F_write.WriteLine(select getdate()) 
F_write.WriteLine(go) 
F_write.WriteLine(dump database  bsjdw to 'g:/-/backupdumpbackbsjdw_data1.dump') 
F_write.WriteLine(go) 
F_write.WriteLine(select getdate()) 
F_write.WriteLine(go) 
F_write.WriteLine(dump database  system to 'gbackupdumpbacksystem_data1.dump') 
F_write.WriteLine(go) 
F_write.WriteLine(select getdate()) 
F_write.WriteLine(go) 
End Select 
F_write.WriteLine(exit) 
F_write.Close() 
Dim ti As Date 
Dim te As Date 
ti = Now
Dim logfilename As String 
logfilename = datafile + Trim(Str(Year(Now()))) + Trim(Str(Month(Now()))) + Trim(Str(Day(Now()))) + .txt 
Shell(cmd k iSQL -Usa -PSjb81! -i + str_FileName +gbackupdumpbackdumplog + logfilename, AppWinStyle.NormalFocus) 
te = Now
Try 
Dim myProcesses() As Process 
Dim instance As Process 
Do 
myProcesses = Process.GetProcessesByName(cmd) 
Dim j As Integer 
j = 0
For Each instance In myProcesses 
If instance.StartTime = ti And instance.StartTime = te Then 
j = 1
End If 
Next 
If j = 0 Then 
Exit Do 
End If 
Loop 
myProcesses.Clear(myProcesses, 0, myProcesses.Length) 
Catch 
End Try 
Exit Sub 
End Sub 
End Module

本文标题:如何实现Sybase自动备份
本文地址:http://www.q0738.com/sybase/1333.html