Showing posts with label application. Show all posts
Showing posts with label application. Show all posts

Sunday, March 25, 2012

BACKUP ERRORS MISSING IN THE EVENT LOG

Hi,

One of our backup jobs failed this morning but nothing got written into
win nt application event log. This way our MOM 2005 couldn't generate
an alert on this event since mom inspetcs application event log for
that purpose (event id 17055). I see backup errors about 10 days ago in
the appl log. What could have caused that? Any help will be
appreciated.

Stan(suslikovich@.yahoo.com) writes:
> One of our backup jobs failed this morning but nothing got written into
> win nt application event log. This way our MOM 2005 couldn't generate
> an alert on this event since mom inspetcs application event log for
> that purpose (event id 17055). I see backup errors about 10 days ago in
> the appl log. What could have caused that? Any help will be
> appreciated.

Do you see anything in the SQL Server error log?

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.aspsql

Thursday, March 22, 2012

Backup devices and backup expire

We have a third party application that backs up a sql server database as
part of its overall backup plan. This is hardwired into the application, so
that it must have a backup device with a specific name. I would like to drop
backup sets from the device after a week, so that the backup device does not
grow without bounds. I have played with expiredate/retaindays but this is
not the answer.
Any suggestions would be most appreciated.
Thanks,
John
Unfortunately, you cannot remove part of a backup device, it is all or nothing. An option can be to copy the
physical file at regular intervals over to a new file name and then delete these files as they get too old.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"John" <jkraeck@.NOprincetonSPAM.edu> wrote in message news:uol5hQWIEHA.308@.tk2msftngp13.phx.gbl...
> We have a third party application that backs up a sql server database as
> part of its overall backup plan. This is hardwired into the application, so
> that it must have a backup device with a specific name. I would like to drop
> backup sets from the device after a week, so that the backup device does not
> grow without bounds. I have played with expiredate/retaindays but this is
> not the answer.
> Any suggestions would be most appreciated.
> Thanks,
> John
>
|||Tibor,
Thanks for the response. Alas, I thought that might be the case.
I will look into alternate methods of working around the issue. There is
always some way out.
Cheers,
John
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23FnpQhWIEHA.2688@.tk2msftngp13.phx.gbl...
> Unfortunately, you cannot remove part of a backup device, it is all or
nothing. An option can be to copy the
> physical file at regular intervals over to a new file name and then delete
these files as they get too old.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
>
> "John" <jkraeck@.NOprincetonSPAM.edu> wrote in message
news:uol5hQWIEHA.308@.tk2msftngp13.phx.gbl...[color=darkblue]
so[color=darkblue]
drop[color=darkblue]
not[color=darkblue]
is
>

Backup devices and backup expire

We have a third party application that backs up a sql server database as
part of its overall backup plan. This is hardwired into the application, so
that it must have a backup device with a specific name. I would like to drop
backup sets from the device after a week, so that the backup device does not
grow without bounds. I have played with expiredate/retaindays but this is
not the answer.
Any suggestions would be most appreciated.
Thanks,
JohnUnfortunately, you cannot remove part of a backup device, it is all or nothi
ng. An option can be to copy the
physical file at regular intervals over to a new file name and then delete t
hese files as they get too old.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"John" <jkraeck@.NOprincetonSPAM.edu> wrote in message news:uol5hQWIEHA.308@.tk2msftngp13.phx
.gbl...
> We have a third party application that backs up a sql server database as
> part of its overall backup plan. This is hardwired into the application, s
o
> that it must have a backup device with a specific name. I would like to dr
op
> backup sets from the device after a week, so that the backup device does n
ot
> grow without bounds. I have played with expiredate/retaindays but this is
> not the answer.
> Any suggestions would be most appreciated.
> Thanks,
> John
>|||Tibor,
Thanks for the response. Alas, I thought that might be the case.
I will look into alternate methods of working around the issue. There is
always some way out.
Cheers,
John
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23FnpQhWIEHA.2688@.tk2msftngp13.phx.gbl...
> Unfortunately, you cannot remove part of a backup device, it is all or
nothing. An option can be to copy the
> physical file at regular intervals over to a new file name and then delete
these files as they get too old.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
>
> "John" <jkraeck@.NOprincetonSPAM.edu> wrote in message
news:uol5hQWIEHA.308@.tk2msftngp13.phx.gbl...
so
drop
not
is
>

Backup devices and backup expire

We have a third party application that backs up a sql server database as
part of its overall backup plan. This is hardwired into the application, so
that it must have a backup device with a specific name. I would like to drop
backup sets from the device after a week, so that the backup device does not
grow without bounds. I have played with expiredate/retaindays but this is
not the answer.
Any suggestions would be most appreciated.
Thanks,
JohnUnfortunately, you cannot remove part of a backup device, it is all or nothing. An option can be to copy the
physical file at regular intervals over to a new file name and then delete these files as they get too old.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"John" <jkraeck@.NOprincetonSPAM.edu> wrote in message news:uol5hQWIEHA.308@.tk2msftngp13.phx.gbl...
> We have a third party application that backs up a sql server database as
> part of its overall backup plan. This is hardwired into the application, so
> that it must have a backup device with a specific name. I would like to drop
> backup sets from the device after a week, so that the backup device does not
> grow without bounds. I have played with expiredate/retaindays but this is
> not the answer.
> Any suggestions would be most appreciated.
> Thanks,
> John
>|||Tibor,
Thanks for the response. Alas, I thought that might be the case.
I will look into alternate methods of working around the issue. There is
always some way out.
Cheers,
John
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23FnpQhWIEHA.2688@.tk2msftngp13.phx.gbl...
> Unfortunately, you cannot remove part of a backup device, it is all or
nothing. An option can be to copy the
> physical file at regular intervals over to a new file name and then delete
these files as they get too old.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
>
> "John" <jkraeck@.NOprincetonSPAM.edu> wrote in message
news:uol5hQWIEHA.308@.tk2msftngp13.phx.gbl...
> > We have a third party application that backs up a sql server database as
> > part of its overall backup plan. This is hardwired into the application,
so
> > that it must have a backup device with a specific name. I would like to
drop
> > backup sets from the device after a week, so that the backup device does
not
> > grow without bounds. I have played with expiredate/retaindays but this
is
> > not the answer.
> >
> > Any suggestions would be most appreciated.
> >
> > Thanks,
> > John
> >
> >
>

Tuesday, March 20, 2012

Backup DB to LocalMachine

alslamo alikom...

hope u all be in a good health...

ok...my problem that i have a client application that designed to adminstrate the DB server using SMO...

now iam trying to backup the desired DB from the DB server which is another machine connected to the same network...

i specified the file name and the DB name....and every thing runs smothly with no exceptions....but no file generated in the client machine....and no exception were thrown....

wish to have a solution soon plz....thx for ur time...

and here is sample code:

public bool BackupDB(string dbName, string backupFilePath)

{

try

{

// Create a new backup and specify what to back up

Backup backup = new Backup();

backup.Action = BackupActionType.Database;

backup.BackupSetDescription = "Backup " + dbName + " database";

backup.BackupSetName = dbName + " Backup";

backup.Database = dbName;

backup.Checksum = true;

backup.ContinueAfterError = true;

backup.Incremental = false;

backup.ExpirationDate = DateTime.Now.AddYears(1);

backup.LogTruncation = BackupTruncateLogType.Truncate;

backup.MediaDescription = "File Backup";

backup.Initialize = true;

backup.Restart = true;

backup.RetainDays = 7;

// Create a new backup device, in this case a file

BackupDeviceItem backupItem = new BackupDeviceItem(backupFilePath, DeviceType.File);

backup.Devices.Add(backupItem);

backup.SqlBackup(sqlServer);

return true;

}

catch(Exception ex)

{

return false;

}

}

thx again.....

alaslamo alikom...(Peace Upon You All) "IsLamic Greeting"

Hi,

SMO is just used to remote administer SQL Server. Defining backups is always relative to the Server. If you want to store the information from the server on the client you will have to define a UNC path which points to a client share or any share where you can copy the backup file to the client from in your application code.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||thank you very much.... Mr.Jens K. Suessmeyer

Thursday, March 8, 2012

Backup command and getting progress like Enterprise/Management Studio

Sorry if this is the wrong place for this, but I couldn't find a better place...

I have a .net application that calls a TSQL command to backup the database when the user clicks a button. I would like to give the user incremental feedback on what's going on.

So I hooked into the connection's InfoMessage event.

It gets called at the end of the command, not during. I read somewhere that you're supposed to be able to add "WITH NOWAIT" to a TSQL command to have it return immediately and then use the InfoMessage for updates, but the Backup command doesn't support it.

I also set a trace on the SQL Server and told SQL Server to backup using Enterprise manager hoping to catch what it was doing special to get these commands, and didn't see anything unique.

Does anyone have suggestions? I really need to show the progress of what's going on.

Thanks!

SqlClient unfortunately does not support retrieving of messages asynchronously during command execution. You can do this however if you use System.Data.Odbc instead. The steps are pretty much the same. This can also be done if you use C/C++ and use ODBC/OLEDB/SNAC.

Backup command and getting progress like Enterprise/Management Studio

Sorry if this is the wrong place for this, but I couldn't find a better place...

I have a .net application that calls a TSQL command to backup the database when the user clicks a button. I would like to give the user incremental feedback on what's going on.

So I hooked into the connection's InfoMessage event.

It gets called at the end of the command, not during. I read somewhere that you're supposed to be able to add "WITH NOWAIT" to a TSQL command to have it return immediately and then use the InfoMessage for updates, but the Backup command doesn't support it.

I also set a trace on the SQL Server and told SQL Server to backup using Enterprise manager hoping to catch what it was doing special to get these commands, and didn't see anything unique.

Does anyone have suggestions? I really need to show the progress of what's going on.

Thanks!

SqlClient unfortunately does not support retrieving of messages asynchronously during command execution. You can do this however if you use System.Data.Odbc instead. The steps are pretty much the same. This can also be done if you use C/C++ and use ODBC/OLEDB/SNAC.

Wednesday, March 7, 2012

Backup and restore of mdf database

Hi,

I've got a following problem: I have a VB 2005 application that uses SQL Server 2005 Express as DB engine. This application has it's own database stored in mdf file, e.g. invoices.mdf with corresponding log file.

I'd like to give users opportunity to backup and restore this DB file from this application (there won't be a system administrator, only end-users). Unfortunatelly after I connect to this database (using user instance of SQL Server), I'm unable to read or copy it, despite the fact, that I close all connections. And I'm sure that all connections are closed.

Database files become accessible for reading after I close the whole application.

I've tried to detach this database using sp_detach_db prcedure, but it can't be done with database I'm connected to.

I will be grateful for any help.

Tomasz

hi Tomasz,

obviously at least 1 connection is still open referencing the database you are dealing with..

try changing the database context to the master system database (that can be done in .Net via the workingConnection.ChangeDatabase("master") statement...)

a workaround to "orphaned" connections could even be an alter database statement to close all pending connections, like

USE master;

GO

ALTER DATABASE dbName

SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

GO-- and the counterpart is

ALTER DATABASE dbName

SET MULTI_USER WITH ROLLBACK IMMEDIATE;

but I'd prefer to find and close all pending connections...

regards

|||

We just had a couple threads about this topic in the forum over the last week. I've summarized how to use SMO to handle Backup and Restore of User Instance database in my blog. Backup should work with connection open but restore is not so forgiving.

Mike

|||

Hi,

thanks for this advice, I will try today to implement backup/restore approach according to the blog.

I'm 100% sure that I close all connections to the DB. I've made a very simple application which just connects to the database and immediatly closes this one an single connection. After that mdf file remains locked until I close the application. It seems, that there is some "stealth" connection, which I can't close directly. You can replicate this behaviour by creating a new application which on start does:

Dim lCon As New SqlClient.SqlConnection(sConnStr)

lCon.Open()

lCon.Close()

lCon.Dispose() 'even that won't help

And then try to copy mdf file to other location while this application is still running.

greetings

Tomasz

|||

Hi,

I've got the same problem as Tomasz. I read all that was written and I was wondering if there isn't a command capable of closing all connection to the database file (.mdf). I just need to upload it to a remote location not restore it.

Thanks in advance

Friday, February 24, 2012

Backup and recovery of SQL Server using VB.net

Hi,

I have a small application in which i'm using Sql Server as Database. my requirement is how to take the backup of the entire database or some tables from the database when there is any delete from the database. My requirement is to do from the VB.net application.Hope i delivered my question correctly. Any little help is beneficial to me.

-regards

GRK

Try this one out...

Dim oDevice As New SQLDMO.BackupDevice
Dim BACKUP As New SQLDMO.BACKUP
Dim SERVER As New SQLServer

Private Sub Form_Load()
On Error Resume Next 'If the device already exists an error will result if you try to add it again so just resume next cos its already there

With oDevice
.Type = SQLDMODevice_DiskDump
.Name = "NorthwindBakUp"
.PhysicalLocation = "C:\Documents and Settings\Administrator\Desktop\BACKUP.bak"
End With

SERVER.Connect "Sanjib", "sa"
SERVER.BackupDevices.Add oDevice
BACKUP.Action = SQLDMOBackup_Database
BACKUP.Database = "Northwind"
BACKUP.Devices ="NorthwindBakUp"
BACKUP.BackupSetDescription = "Full BackUp"
BACKUP.BackupSetName = "By Sanjib"

BACKUP.SQLBackup SERVER

End Sub

|||

Hi,

Here's my backup class of one of my project that uses Microsoft.SqlServer.Management:

public class BackupManager

{

Server srvSql;

SaveFileDialog saveBackupDialog = new SaveFileDialog();

OpenFileDialog openBackupDialog = new OpenFileDialog();

DatabaseCache dbCache = DatabaseCache.Instance;

private string GetAppPath()

{

return System.IO.Path.GetDirectoryName

(System.Windows.Forms.Application.ExecutablePath);

}

private void Connect()

{

ServerConnection srvConn = new

ServerConnection(dbCache.SqlConnection);

srvSql = new Server(srvConn);

}

private string GetDatabase(SqlConnection conn)

{

string[] connArray = conn.ConnectionString.Split(';');

string toMatch = "AttachDbFilename=";

string match = null;

foreach (string item in connArray) {

if (item.StartsWith(toMatch))

{

match = item.Substring(toMatch.Length);

break;

}

}

if (!String.IsNullOrEmpty(match) ) {

match = match.Replace("|DataDirectory|", GetAppPath());

} else {

throw new Exception(

"Could not extract database path from connection string");

}

return match;

}

public bool MakeBackup()

{

// If there was a SQL connection created

if (srvSql == null) {

Connect();

}

if (srvSql != null)

{

string path = GetAppPath();

path = path += @."\Backup";

if (!Directory.Exists(path))

{

Directory.CreateDirectory(path);

}

saveBackupDialog.InitialDirectory = path;

saveBackupDialog.DefaultExt = "bak";

// If the user has chosen a path

// where to save the backup file

if (saveBackupDialog.ShowDialog() == DialogResult.OK)

{

// Create a new backup operation

Backup bkpDatabase = new Backup();

// Set the backup type to a database backup

bkpDatabase.Action = BackupActionType.Database;

// Set the database that we want to perform a backup on

bkpDatabase.Database = GetDatabase(dbCache.SqlConnection);

// Set the backup device to a file

BackupDeviceItem bkpDevice = new BackupDeviceItem(saveBackupDialog.FileName, DeviceType.File);

// Add the backup device to the backup

bkpDatabase.Devices.Add(bkpDevice);

// Perform the backup

bkpDatabase.SqlBackup(srvSql);

} else {

return false;

}

} else {

throw new Exception("Could not connect to database.");

}

return true;

}

public void RestoreBackup()

{

//database must first be unloaded before calling this.

// If there was a SQL connection created

if (srvSql == null)

{

Connect();

}

if (srvSql != null)

{

openBackupDialog.InitialDirectory = "./Backup";

openBackupDialog.DefaultExt = "bak";

// If the user has chosen the file from which he wants the database to be restored

if (openBackupDialog.ShowDialog() == DialogResult.OK)

{

// Create a new database restore operation

Restore rstDatabase = new Restore();

// Set the restore type to a database restore

rstDatabase.Action = RestoreActionType.Database;

// Set the database that we want to perform the restore on

rstDatabase.Database = GetDatabase(dbCache.SqlConnection);

// Set the backup device from which we want to restore, to a file

BackupDeviceItem bkpDevice = new BackupDeviceItem(openBackupDialog.FileName, DeviceType.File);

// Add the backup device to the restore type

rstDatabase.Devices.Add(bkpDevice);

// If the database already exists, replace it

rstDatabase.ReplaceDatabase = true;

// Perform the restore

try

{

rstDatabase.SqlRestore(srvSql);

}

catch (FailedOperationException ex)

{

Log.WriteLine( "" );

Log.WriteLine( "Error: (BackupManager.RestoreBackup)" );

Log.Write( ex );

throw new Exception("Error while restoring backup.", ex);

}

}

}

else

{

throw new Exception("Could not connect to database.");

}

}

}

It's not generic so you'll have to change some of the code (and translate to vb...) You can see the basic idee from the code above.

Good luck,
Charles

|||

Hi ,

forgive me for the late reply.I tried the above code it is running after small changes to the code.thanks a lot

-regards

GRK

|||

Hi,

i hav the same problem...

" I have a small application in which i'm using Sql Server as Database. my requirement is how to take the backup of the entire database or some tables from the database when there is any delete from the database. My requirement is to do from the VB.net application"

i used tht abov code.. bt it dnt wok..

so.. plz snd me the code... plz its urgent.....

thnks in advance

siva

|||brallient|||

where i can find DatabaseCache class i downloaded and install SQLServer2005_XMO.msi

but still i cant see that class, other code works fine.

Thanks

|||

Hi,

It's normal, DatabaseCache is my own class that contains all the data of my application :)

Basically you need to remove that and replace dbCache.SqlConnection in the Connect function with the connection you use for your database.

Charles

|||

my connectionString is

connectionString = "Data Source=localhost,1433;Network Library=DBMSSOCN;Initial Catalog=myDb; User ID=sa;Password=saabc;";

when i replaced dbCache.SqlConnection with my own opened connection as "openedConnection", it compiled and executed, but when i click on backup button, i caught by following exception

"Could not extract database path from connection string"

Could you please change the code according to my connection.

Thanks

|||

Ok,

My code assumes that a database file is used. So in your case the GetDatabase method fails to find the db file from the connection string.

Try replacing bkpDatabase.Database = GetDatabase(dbCache.SqlConnection); by

bkpDatabase.Database = "myDb";

or better yet to modify the GetDatabase method to take into account the Initial Catalog key.

Charles

|||Thanks, let me check it

Backup and recovery of SQL Server using VB.net

Hi,

I have a small application in which i'm using Sql Server as Database. my requirement is how to take the backup of the entire database or some tables from the database when there is any delete from the database. My requirement is to do from the VB.net application.Hope i delivered my question correctly. Any little help is beneficial to me.

-regards

GRK

Try this one out...

Dim oDevice As New SQLDMO.BackupDevice
Dim BACKUP As New SQLDMO.BACKUP
Dim SERVER As New SQLServer

Private Sub Form_Load()
On Error Resume Next 'If the device already exists an error will result if you try to add it again so just resume next cos its already there

With oDevice
.Type = SQLDMODevice_DiskDump
.Name = "NorthwindBakUp"
.PhysicalLocation = "C:\Documents and Settings\Administrator\Desktop\BACKUP.bak"
End With

SERVER.Connect "Sanjib", "sa"
SERVER.BackupDevices.Add oDevice
BACKUP.Action = SQLDMOBackup_Database
BACKUP.Database = "Northwind"
BACKUP.Devices ="NorthwindBakUp"
BACKUP.BackupSetDescription = "Full BackUp"
BACKUP.BackupSetName = "By Sanjib"

BACKUP.SQLBackup SERVER

End Sub

|||

Hi,

Here's my backup class of one of my project that uses Microsoft.SqlServer.Management:

public class BackupManager

{

Server srvSql;

SaveFileDialog saveBackupDialog = new SaveFileDialog();

OpenFileDialog openBackupDialog = new OpenFileDialog();

DatabaseCache dbCache = DatabaseCache.Instance;

private string GetAppPath()

{

return System.IO.Path.GetDirectoryName

(System.Windows.Forms.Application.ExecutablePath);

}

private void Connect()

{

ServerConnection srvConn = new

ServerConnection(dbCache.SqlConnection);

srvSql = new Server(srvConn);

}

private string GetDatabase(SqlConnection conn)

{

string[] connArray = conn.ConnectionString.Split(';');

string toMatch = "AttachDbFilename=";

string match = null;

foreach (string item in connArray) {

if (item.StartsWith(toMatch))

{

match = item.Substring(toMatch.Length);

break;

}

}

if (!String.IsNullOrEmpty(match) ) {

match = match.Replace("|DataDirectory|", GetAppPath());

} else {

throw new Exception(

"Could not extract database path from connection string");

}

return match;

}

public bool MakeBackup()

{

// If there was a SQL connection created

if (srvSql == null) {

Connect();

}

if (srvSql != null)

{

string path = GetAppPath();

path = path += @."\Backup";

if (!Directory.Exists(path))

{

Directory.CreateDirectory(path);

}

saveBackupDialog.InitialDirectory = path;

saveBackupDialog.DefaultExt = "bak";

// If the user has chosen a path

// where to save the backup file

if (saveBackupDialog.ShowDialog() == DialogResult.OK)

{

// Create a new backup operation

Backup bkpDatabase = new Backup();

// Set the backup type to a database backup

bkpDatabase.Action = BackupActionType.Database;

// Set the database that we want to perform a backup on

bkpDatabase.Database = GetDatabase(dbCache.SqlConnection);

// Set the backup device to a file

BackupDeviceItem bkpDevice = new BackupDeviceItem(saveBackupDialog.FileName, DeviceType.File);

// Add the backup device to the backup

bkpDatabase.Devices.Add(bkpDevice);

// Perform the backup

bkpDatabase.SqlBackup(srvSql);

} else {

return false;

}

} else {

throw new Exception("Could not connect to database.");

}

return true;

}

public void RestoreBackup()

{

//database must first be unloaded before calling this.

// If there was a SQL connection created

if (srvSql == null)

{

Connect();

}

if (srvSql != null)

{

openBackupDialog.InitialDirectory = "./Backup";

openBackupDialog.DefaultExt = "bak";

// If the user has chosen the file from which he wants the database to be restored

if (openBackupDialog.ShowDialog() == DialogResult.OK)

{

// Create a new database restore operation

Restore rstDatabase = new Restore();

// Set the restore type to a database restore

rstDatabase.Action = RestoreActionType.Database;

// Set the database that we want to perform the restore on

rstDatabase.Database = GetDatabase(dbCache.SqlConnection);

// Set the backup device from which we want to restore, to a file

BackupDeviceItem bkpDevice = new BackupDeviceItem(openBackupDialog.FileName, DeviceType.File);

// Add the backup device to the restore type

rstDatabase.Devices.Add(bkpDevice);

// If the database already exists, replace it

rstDatabase.ReplaceDatabase = true;

// Perform the restore

try

{

rstDatabase.SqlRestore(srvSql);

}

catch (FailedOperationException ex)

{

Log.WriteLine( "" );

Log.WriteLine( "Error: (BackupManager.RestoreBackup)" );

Log.Write( ex );

throw new Exception("Error while restoring backup.", ex);

}

}

}

else

{

throw new Exception("Could not connect to database.");

}

}

}

It's not generic so you'll have to change some of the code (and translate to vb...) You can see the basic idee from the code above.

Good luck,
Charles

|||

Hi ,

forgive me for the late reply.I tried the above code it is running after small changes to the code.thanks a lot

-regards

GRK

|||

Hi,

i hav the same problem...

" I have a small application in which i'm using Sql Server as Database. my requirement is how to take the backup of the entire database or some tables from the database when there is any delete from the database. My requirement is to do from the VB.net application"

i used tht abov code.. bt it dnt wok..

so.. plz snd me the code... plz its urgent.....

thnks in advance

siva

|||brallient|||

where i can find DatabaseCache class i downloaded and install SQLServer2005_XMO.msi

but still i cant see that class, other code works fine.

Thanks

|||

Hi,

It's normal, DatabaseCache is my own class that contains all the data of my application :)

Basically you need to remove that and replace dbCache.SqlConnection in the Connect function with the connection you use for your database.

Charles

|||

my connectionString is

connectionString = "Data Source=localhost,1433;Network Library=DBMSSOCN;Initial Catalog=myDb; User ID=sa;Password=saabc;";

when i replaced dbCache.SqlConnection with my own opened connection as "openedConnection", it compiled and executed, but when i click on backup button, i caught by following exception

"Could not extract database path from connection string"

Could you please change the code according to my connection.

Thanks

|||

Ok,

My code assumes that a database file is used. So in your case the GetDatabase method fails to find the db file from the connection string.

Try replacing bkpDatabase.Database = GetDatabase(dbCache.SqlConnection); by

bkpDatabase.Database = "myDb";

or better yet to modify the GetDatabase method to take into account the Initial Catalog key.

Charles

|||Thanks, let me check it

Backup and Log Strategies

Hi all,
I'm mostly an application developer - so please don't flog me for not
knowing things which are probably very basic. Our machine keeps
running out of space. We have all our data/bak/log files on e: , and
they have some kind of maintenance plan set up. Backups of the data
and log are created one after another and never deleted. In the 4
years we've been running various systems, we've never had to restore to
a previous time - just restore to current state once.
I've also read that the transaction log should automatically shrink
after it is backed up. When I do this manually it doesn't happen - I
have to run 'shrink db' after to make it happen. It doesn't seem to
happen with their scheduled routines either.
Do people write scripts to delete old backups?
Should we be using the overwrite option so we don't get a buildup?
What other tips might you have?
thanks alot
SamMaint Plans creates a new file for every backup. so if you use maint plans, there no "overwrite"
considerations. MPs also have option to remove backups "older than...". Check the plan to see what
it is configured for. MPs has (among other things) one bad behavior, though. If a plan fails, it
stops. And removal of old backup files is among the last things performed. One such frequent reason
if that you have included databases in simple recovery mode for plans that try to do log backups. So
sqlmaint tries a log backups for, for example master, it fails and the execution stops without
removing *any* old backup files.
The ldf file is emptied when you do a log backup, that is not the same as shrinking the file size.
See http://www.karaszi.com/SQLServer/info_dont_shrink.asp for elaborations on the subject.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<samuelgreene@.gmail.com> wrote in message
news:1154533293.924009.30720@.m73g2000cwd.googlegroups.com...
> Hi all,
> I'm mostly an application developer - so please don't flog me for not
> knowing things which are probably very basic. Our machine keeps
> running out of space. We have all our data/bak/log files on e: , and
> they have some kind of maintenance plan set up. Backups of the data
> and log are created one after another and never deleted. In the 4
> years we've been running various systems, we've never had to restore to
> a previous time - just restore to current state once.
> I've also read that the transaction log should automatically shrink
> after it is backed up. When I do this manually it doesn't happen - I
> have to run 'shrink db' after to make it happen. It doesn't seem to
> happen with their scheduled routines either.
> Do people write scripts to delete old backups?
> Should we be using the overwrite option so we don't get a buildup?
> What other tips might you have?
> thanks alot
> Sam
>|||Thank you very much!

Backup and Log Strategies

Hi all,
I'm mostly an application developer - so please don't flog me for not
knowing things which are probably very basic. Our machine keeps
running out of space. We have all our data/bak/log files on e: , and
they have some kind of maintenance plan set up. Backups of the data
and log are created one after another and never deleted. In the 4
years we've been running various systems, we've never had to restore to
a previous time - just restore to current state once.
I've also read that the transaction log should automatically shrink
after it is backed up. When I do this manually it doesn't happen - I
have to run 'shrink db' after to make it happen. It doesn't seem to
happen with their scheduled routines either.
Do people write scripts to delete old backups?
Should we be using the overwrite option so we don't get a buildup?
What other tips might you have?
thanks alot
SamMaint Plans creates a new file for every backup. so if you use maint plans,
there no "overwrite"
considerations. MPs also have option to remove backups "older than...". Chec
k the plan to see what
it is configured for. MPs has (among other things) one bad behavior, though.
If a plan fails, it
stops. And removal of old backup files is among the last things performed. O
ne such frequent reason
if that you have included databases in simple recovery mode for plans that t
ry to do log backups. So
sqlmaint tries a log backups for, for example master, it fails and the execu
tion stops without
removing *any* old backup files.
The ldf file is emptied when you do a log backup, that is not the same as sh
rinking the file size.
See http://www.karaszi.com/SQLServer/info_dont_shrink.asp for elaborations o
n the subject.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<samuelgreene@.gmail.com> wrote in message
news:1154533293.924009.30720@.m73g2000cwd.googlegroups.com...
> Hi all,
> I'm mostly an application developer - so please don't flog me for not
> knowing things which are probably very basic. Our machine keeps
> running out of space. We have all our data/bak/log files on e: , and
> they have some kind of maintenance plan set up. Backups of the data
> and log are created one after another and never deleted. In the 4
> years we've been running various systems, we've never had to restore to
> a previous time - just restore to current state once.
> I've also read that the transaction log should automatically shrink
> after it is backed up. When I do this manually it doesn't happen - I
> have to run 'shrink db' after to make it happen. It doesn't seem to
> happen with their scheduled routines either.
> Do people write scripts to delete old backups?
> Should we be using the overwrite option so we don't get a buildup?
> What other tips might you have?
> thanks alot
> Sam
>|||Thank you very much!

Sunday, February 19, 2012

Backup /Restore options

I'm trying to decide what path to take in implementing Backup & Restore
processes in my VB6/MSDE application.
Either (a) create and execute Maintenance Plans or (b) use the BACKUP /
RESTORE / DBSHRINK commands in the program.
Can anybody explain to me the pros/cons of using one of the other?
TIA
Jim K
Hi Jim,
This depends upon the type of client in my opinion. A scheduled backup to a
file (for example) is great for small sites (followed by an operating system
backup of that file) but ONLY if they're going to check that the file
date/time keeps changing. If the SQL Agent stops (for example), they'll
blissfully keep backing up the same file and not actually have a backup
(apart from an old one). Maintenance plans have the same issues.
If that's a problem, I'd rather have an option in the program because you
are more likely to have those sorts of places carry out a "procedure" than
to look for something more subtle.
HTH,
Greg Low [MVP]
MSDE Manager SQL Tools
www.whitebearconsulting.com
"Jim K" <krusej@.megsinet.net> wrote in message
news:OcvVvds5EHA.4072@.TK2MSFTNGP10.phx.gbl...
> I'm trying to decide what path to take in implementing Backup & Restore
> processes in my VB6/MSDE application.
> Either (a) create and execute Maintenance Plans or (b) use the BACKUP /
> RESTORE / DBSHRINK commands in the program.
> Can anybody explain to me the pros/cons of using one of the other?
> TIA
> Jim K
>

Backup / Restore Question - MSDE

MSDE2000

I have an application in which I am running a TSQL command of BACKUP DATABASE and RESTORE DATABASE for the backup and restore commands for my application. For testing purposes, i did the following:

1) Ran a BACKUP DATABASE command to a file named C:\TEST.BAK.
2) Deleted the database completely.
3) Ran a RESTORE DATABASE on the same file (note, I did NOT recreate the database)

Now I have the database back with all my data. What are the gotchas when doing a backup and restore using this method? I am not relying on transaction logs to restore to a certain point, the user can only restore back to their last backup (may be daily, weekly or monthly)

TIA

--
Tim MorrisonThis method will work find for the SIMPLE recovery model. It doesn't matter
whether or not the target database exists since it will be recreated during
the restore if needed.

Be sure to backup WITH INIT or the backup will append to the existing backup
file and the file will grow indefinitely. Also, consider copying the backup
file elsewhere for disaster recovery.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Tim Morrison" <sales@.kjmsoftware.com> wrote in message
news:YE3Db.545312$Tr4.1480932@.attbi_s03...
MSDE2000

I have an application in which I am running a TSQL command of BACKUP
DATABASE and RESTORE DATABASE for the backup and restore commands for my
application. For testing purposes, i did the following:

1) Ran a BACKUP DATABASE command to a file named C:\TEST.BAK.
2) Deleted the database completely.
3) Ran a RESTORE DATABASE on the same file (note, I did NOT recreate the
database)

Now I have the database back with all my data. What are the gotchas when
doing a backup and restore using this method? I am not relying on
transaction logs to restore to a certain point, the user can only restore
back to their last backup (may be daily, weekly or monthly)

TIA

--
Tim Morrison|||Yes, I have the database set to simple recovery in my initial SQL script the
user uses to create the database.

I also have WITH INIT in my backup command.

I also discovered that the restore database name does not have to be the
same as the initial database. This is both a benefit and a risk.

I even 100% uninstalled MSDE, and reinstalled (Including SP3a), then
performed my restore command, and everything seems to work perfectly.

Im guessing that if I wanted to send a sample database with my application
that includes sample data, it would be very easy to do using this method.

Im learning more and more every day. I have a SAMS SQL Server 2000 book
which is always helpfull

Tim Morrison

"Dan Guzman" <danguzman@.nospam-earthlink.net> wrote in message
news:7O5Db.1465$Bg5.648@.newsread2.news.atl.earthli nk.net...
> This method will work find for the SIMPLE recovery model. It doesn't
matter
> whether or not the target database exists since it will be recreated
during
> the restore if needed.
> Be sure to backup WITH INIT or the backup will append to the existing
backup
> file and the file will grow indefinitely. Also, consider copying the
backup
> file elsewhere for disaster recovery.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
>
> "Tim Morrison" <sales@.kjmsoftware.com> wrote in message
> news:YE3Db.545312$Tr4.1480932@.attbi_s03...
> MSDE2000
> I have an application in which I am running a TSQL command of BACKUP
> DATABASE and RESTORE DATABASE for the backup and restore commands for my
> application. For testing purposes, i did the following:
> 1) Ran a BACKUP DATABASE command to a file named C:\TEST.BAK.
> 2) Deleted the database completely.
> 3) Ran a RESTORE DATABASE on the same file (note, I did NOT recreate the
> database)
> Now I have the database back with all my data. What are the gotchas when
> doing a backup and restore using this method? I am not relying on
> transaction logs to restore to a certain point, the user can only restore
> back to their last backup (may be daily, weekly or monthly)
> TIA
>
> --
> Tim Morrison|||Yes, I have the database set to simple recovery in my initial SQL script the
user uses to create the database.

I also have WITH INIT in my backup command.

I also discovered that the restore database name does not have to be the
same as the initial database. This is both a benefit and a risk.

I even 100% uninstalled MSDE, and reinstalled (Including SP3a), then
performed my restore command, and everything seems to work perfectly.

Im guessing that if I wanted to send a sample database with my application
that includes sample data, it would be very easy to do using this method.

Im learning more and more every day. I have a SAMS SQL Server 2000 book
which is always helpfull

Tim Morrison

"Dan Guzman" <danguzman@.nospam-earthlink.net> wrote in message
news:7O5Db.1465$Bg5.648@.newsread2.news.atl.earthli nk.net...
> This method will work find for the SIMPLE recovery model. It doesn't
matter
> whether or not the target database exists since it will be recreated
during
> the restore if needed.
> Be sure to backup WITH INIT or the backup will append to the existing
backup
> file and the file will grow indefinitely. Also, consider copying the
backup
> file elsewhere for disaster recovery.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
>
> "Tim Morrison" <sales@.kjmsoftware.com> wrote in message
> news:YE3Db.545312$Tr4.1480932@.attbi_s03...
> MSDE2000
> I have an application in which I am running a TSQL command of BACKUP
> DATABASE and RESTORE DATABASE for the backup and restore commands for my
> application. For testing purposes, i did the following:
> 1) Ran a BACKUP DATABASE command to a file named C:\TEST.BAK.
> 2) Deleted the database completely.
> 3) Ran a RESTORE DATABASE on the same file (note, I did NOT recreate the
> database)
> Now I have the database back with all my data. What are the gotchas when
> doing a backup and restore using this method? I am not relying on
> transaction logs to restore to a certain point, the user can only restore
> back to their last backup (may be daily, weekly or monthly)
> TIA
>
> --
> Tim Morrison