Showing posts with label backups. Show all posts
Showing posts with label backups. Show all posts

Tuesday, March 20, 2012

Can not Backups on SQL2005

Can not Backups.No Error!

The Code:

Code Snippet

static void Main(string[] args)
{
try
{
SqlConnection Connection = new SqlConnection(@."Data Source=SUPER-9ZT4OE2OQ;Initial Catalog=DataBase;Persist Security Info=True;User ID=tj;password=tj");
Server server = new Server(new ServerConnection(Connection));
Backup bak = new Backup();
bak.Action = BackupActionType.Database;
bak.Database = "DataBase";

BackupDevice backupDevice = new BackupDevice(server, "Full_Backup");
backupDevice.PhysicalLocation = @."\\192.168.2.13\DatabaseBak\over.remoteBak";
backupDevice.BackupDeviceType = BackupDeviceType.Disk;

bak.Devices.AddDevice("Full_Backup", DeviceType.File);
bak.Incremental = false;
bak.SqlBackup(server);

}
catch (Exception)
{

throw;
}
}

Any help is highly appreciated

Thanks.

Try changing the line

bak.Devices.AddDevice(xxx)

to

bak.Devices.Add(xxx)

Here's the example (in VB.Net) from BOL:

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Reference the AdventureWorks database.
Dim db As Database
db = srv.Databases("AdventureWorks")
'Define a Backup object variable.
Dim bk As New Backup
'Specify the type of backup, the description, the name, and the database to be backed up.
bk.Action = BackupActionType.Database
bk.Database = "AdventureWorks"
'Declare a BackupDeviceItem by supplying the backup device file name in the constructor, and the type of device is a file.
Dim bdi As BackupDeviceItem
bdi = New BackupDeviceItem("Test_Full_Backup1", DeviceType.File)
'Add the device to the Backup object.
bk.Devices.Add(bdi)
'Run SqlBackup to perform the full database backup on the instance of SQL Server.
bk.SqlBackup(srv)

Can not Backups on SQL2005

Can not Backups.No Error!

The Code:

Code Snippet

static void Main(string[] args)
{
try
{
SqlConnection Connection = new SqlConnection(@."Data Source=SUPER-9ZT4OE2OQ;Initial Catalog=DataBase;Persist Security Info=True;User ID=tj;password=tj");
Server server = new Server(new ServerConnection(Connection));
Backup bak = new Backup();
bak.Action = BackupActionType.Database;
bak.Database = "DataBase";

BackupDevice backupDevice = new BackupDevice(server, "Full_Backup");
backupDevice.PhysicalLocation = @."\\192.168.2.13\DatabaseBak\over.remoteBak";
backupDevice.BackupDeviceType = BackupDeviceType.Disk;

bak.Devices.AddDevice("Full_Backup", DeviceType.File);
bak.Incremental = false;
bak.SqlBackup(server);

}
catch (Exception)
{

throw;
}
}

Any help is highly appreciated

Thanks.

Try changing the line

bak.Devices.AddDevice(xxx)

to

bak.Devices.Add(xxx)

Here's the example (in VB.Net) from BOL:

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Reference the AdventureWorks database.
Dim db As Database
db = srv.Databases("AdventureWorks")
'Define a Backup object variable.
Dim bk As New Backup
'Specify the type of backup, the description, the name, and the database to be backed up.
bk.Action = BackupActionType.Database
bk.Database = "AdventureWorks"
'Declare a BackupDeviceItem by supplying the backup device file name in the constructor, and the type of device is a file.
Dim bdi As BackupDeviceItem
bdi = New BackupDeviceItem("Test_Full_Backup1", DeviceType.File)
'Add the device to the Backup object.
bk.Devices.Add(bdi)
'Run SqlBackup to perform the full database backup on the instance of SQL Server.
bk.SqlBackup(srv)

Wednesday, March 7, 2012

Can I use SQL server 2005 manager to schedule backups?

Can I use SQL server 2005 manager to schedule backups?
Any documents for that?
Thanks in advance.
Sean wrote:
> Can I use SQL server 2005 manager to schedule backups?
> Any documents for that?
> Thanks in advance.
Create a SQL Agent job that executes the BACKUP command...
Tracy McKibben
MCDBA
http://www.realsqlguy.com
|||Hi,
You could also use the Maintenance plans from SQL Server Management studio
to configure the database backup. The wizard itself will guide you to steps
to setup the backup job.
Thanks
Hari
SQL Server MVP
"Sean" <Sean@.discussions.microsoft.com> wrote in message
news:F1DC9D76-2519-42A4-807A-1D788D9B8A3F@.microsoft.com...
> Can I use SQL server 2005 manager to schedule backups?
> Any documents for that?
> Thanks in advance.

Can I use SQL server 2005 manager to schedule backups?

Can I use SQL server 2005 manager to schedule backups?
Any documents for that?
Thanks in advance.Sean wrote:
> Can I use SQL server 2005 manager to schedule backups?
> Any documents for that?
> Thanks in advance.
Create a SQL Agent job that executes the BACKUP command...
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||Hi,
You could also use the Maintenance plans from SQL Server Management studio
to configure the database backup. The wizard itself will guide you to steps
to setup the backup job.
Thanks
Hari
SQL Server MVP
"Sean" <Sean@.discussions.microsoft.com> wrote in message
news:F1DC9D76-2519-42A4-807A-1D788D9B8A3F@.microsoft.com...
> Can I use SQL server 2005 manager to schedule backups?
> Any documents for that?
> Thanks in advance.

Can I use SQL server 2005 manager to schedule backups?

Can I use SQL server 2005 manager to schedule backups?
Any documents for that?
Thanks in advance.Sean wrote:
> Can I use SQL server 2005 manager to schedule backups?
> Any documents for that?
> Thanks in advance.
Create a SQL Agent job that executes the BACKUP command...
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||Hi,
You could also use the Maintenance plans from SQL Server Management studio
to configure the database backup. The wizard itself will guide you to steps
to setup the backup job.
Thanks
Hari
SQL Server MVP
"Sean" <Sean@.discussions.microsoft.com> wrote in message
news:F1DC9D76-2519-42A4-807A-1D788D9B8A3F@.microsoft.com...
> Can I use SQL server 2005 manager to schedule backups?
> Any documents for that?
> Thanks in advance.

Sunday, February 19, 2012

Can I setup Log Shipping and nightly backups?

I have backups that have been running nightly without issue for quite some
time. To minimize data loss in the event of a major server disaster I setup
log shipping. I want to know if I can continue to perform the nightly
backups or if this will interfere with the log file shipping. The nightly
backups are useful for lots of things we do but aren't entirely necessary.As long as these "nightly backups" aren't log backups then you should be fine. A database backup do
not empty the log, i.e..e., it do not affect your log backup chain sequence in any way.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Bishop" <nospam@.nospam.com> wrote in message news:uyk7Nf8qIHA.1952@.TK2MSFTNGP05.phx.gbl...
>I have backups that have been running nightly without issue for quite some time. To minimize data
>loss in the event of a major server disaster I setup log shipping. I want to know if I can
>continue to perform the nightly backups or if this will interfere with the log file shipping. The
>nightly backups are useful for lots of things we do but aren't entirely necessary.
>|||Thank You!
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:E46D838C-19D6-4FAB-A7F1-53B91CE3B005@.microsoft.com...
> As long as these "nightly backups" aren't log backups then you should be
> fine. A database backup do not empty the log, i.e..e., it do not affect
> your log backup chain sequence in any way.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Bishop" <nospam@.nospam.com> wrote in message
> news:uyk7Nf8qIHA.1952@.TK2MSFTNGP05.phx.gbl...
>>I have backups that have been running nightly without issue for quite some
>>time. To minimize data loss in the event of a major server disaster I
>>setup log shipping. I want to know if I can continue to perform the
>>nightly backups or if this will interfere with the log file shipping. The
>>nightly backups are useful for lots of things we do but aren't entirely
>>necessary.
>

Thursday, February 16, 2012

Can I restore database with just the mdf?

I need to restore a database to the state it was in six months ago. Though
backups were faithfully done, the backup files are not retained on the system
past one month. And the tape backups of the network, that do go back in
time, skipped the directories that held the bak and trn files.
What I have is an mdf file from that period. I tried doing an attach with
ATTACH_REBUILD_LOG, but it errors out because "the database was not cleanly
shut down." I'm guessing that this is because the database file was simply
copied as a physical file instead of being detached first.
In an act of desperation, I created an empty database of the same name, shut
down the server, and then copied over the old mdf file. I didn't really
expect it to work, and therefore was not disappointed.
Is there anything I can do to restore this old mdf?I saw several posts advising people to try sp_attach_single_file_db. It did
this but got the same error message that I had been getting.
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file
"D:\SysData\MSSQL\LogFiles\MCRSL_V65\MCRinc_65App_log.ldf". Operating system
error 5: "5(Access is denied.)".
File activation failure. The physical file name
"D:\SysData\MSSQL\LogFiles\MCRSL_V65\MCRinc_65App_log.ldf" may be incorrect.
The log cannot be rebuilt because the database was not cleanly shut down.
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'MCRinc_65App_Jun07'. CREATE DATABASE is aborted.
"Bev Kaufman" wrote:
> I need to restore a database to the state it was in six months ago. Though
> backups were faithfully done, the backup files are not retained on the system
> past one month. And the tape backups of the network, that do go back in
> time, skipped the directories that held the bak and trn files.
> What I have is an mdf file from that period. I tried doing an attach with
> ATTACH_REBUILD_LOG, but it errors out because "the database was not cleanly
> shut down." I'm guessing that this is because the database file was simply
> copied as a physical file instead of being detached first.
> In an act of desperation, I created an empty database of the same name, shut
> down the server, and then copied over the old mdf file. I didn't really
> expect it to work, and therefore was not disappointed.
> Is there anything I can do to restore this old mdf?|||Bev,
This may not work, depending on many things. But, having said that, it did
save my skin in one disaster. Please read and follow carefully:
http://www.tech-archive.net/Archive/SQL-Server/microsoft.public.sqlserver.server/2004-03/3026.html
As Jasper Smith says, this is unsupported.
RLF
"Bev Kaufman" <BevKaufman@.discussions.microsoft.com> wrote in message
news:C5E520BD-5FD1-44EE-9963-399369BABA22@.microsoft.com...
>I saw several posts advising people to try sp_attach_single_file_db. It
>did
> this but got the same error message that I had been getting.
> Msg 5120, Level 16, State 101, Line 1
> Unable to open the physical file
> "D:\SysData\MSSQL\LogFiles\MCRSL_V65\MCRinc_65App_log.ldf". Operating
> system
> error 5: "5(Access is denied.)".
> File activation failure. The physical file name
> "D:\SysData\MSSQL\LogFiles\MCRSL_V65\MCRinc_65App_log.ldf" may be
> incorrect.
> The log cannot be rebuilt because the database was not cleanly shut down.
> Msg 1813, Level 16, State 2, Line 1
> Could not open new database 'MCRinc_65App_Jun07'. CREATE DATABASE is
> aborted.
>
> "Bev Kaufman" wrote:
>> I need to restore a database to the state it was in six months ago.
>> Though
>> backups were faithfully done, the backup files are not retained on the
>> system
>> past one month. And the tape backups of the network, that do go back in
>> time, skipped the directories that held the bak and trn files.
>> What I have is an mdf file from that period. I tried doing an attach with
>> ATTACH_REBUILD_LOG, but it errors out because "the database was not
>> cleanly
>> shut down." I'm guessing that this is because the database file was
>> simply
>> copied as a physical file instead of being detached first.
>> In an act of desperation, I created an empty database of the same name,
>> shut
>> down the server, and then copied over the old mdf file. I didn't really
>> expect it to work, and therefore was not disappointed.
>> Is there anything I can do to restore this old mdf?|||I had to do something similar but I only thing was I couldn't get step 9 on
working. So what I did was after the database was in emergency state, I
created a new blank database. And used DTS services to transfer all objects
from original database to the new one. SQL was able to access the database
even though it had no log file; just didn't want me to make any transactions
against it where log was required I guess.
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCTS: SQL Server 2005
http://sqllearnings.blogspot.com/
"Russell Fields" wrote:
> Bev,
> This may not work, depending on many things. But, having said that, it did
> save my skin in one disaster. Please read and follow carefully:
> http://www.tech-archive.net/Archive/SQL-Server/microsoft.public.sqlserver.server/2004-03/3026.html
> As Jasper Smith says, this is unsupported.
> RLF
> "Bev Kaufman" <BevKaufman@.discussions.microsoft.com> wrote in message
> news:C5E520BD-5FD1-44EE-9963-399369BABA22@.microsoft.com...
> >I saw several posts advising people to try sp_attach_single_file_db. It
> >did
> > this but got the same error message that I had been getting.
> >
> > Msg 5120, Level 16, State 101, Line 1
> > Unable to open the physical file
> > "D:\SysData\MSSQL\LogFiles\MCRSL_V65\MCRinc_65App_log.ldf". Operating
> > system
> > error 5: "5(Access is denied.)".
> > File activation failure. The physical file name
> > "D:\SysData\MSSQL\LogFiles\MCRSL_V65\MCRinc_65App_log.ldf" may be
> > incorrect.
> > The log cannot be rebuilt because the database was not cleanly shut down.
> > Msg 1813, Level 16, State 2, Line 1
> > Could not open new database 'MCRinc_65App_Jun07'. CREATE DATABASE is
> > aborted.
> >
> >
> > "Bev Kaufman" wrote:
> >
> >> I need to restore a database to the state it was in six months ago.
> >> Though
> >> backups were faithfully done, the backup files are not retained on the
> >> system
> >> past one month. And the tape backups of the network, that do go back in
> >> time, skipped the directories that held the bak and trn files.
> >>
> >> What I have is an mdf file from that period. I tried doing an attach with
> >> ATTACH_REBUILD_LOG, but it errors out because "the database was not
> >> cleanly
> >> shut down." I'm guessing that this is because the database file was
> >> simply
> >> copied as a physical file instead of being detached first.
> >>
> >> In an act of desperation, I created an empty database of the same name,
> >> shut
> >> down the server, and then copied over the old mdf file. I didn't really
> >> expect it to work, and therefore was not disappointed.
> >>
> >> Is there anything I can do to restore this old mdf?
>
>

Sunday, February 12, 2012

Can I manually delete .bak files?

I'm running a SQL 2000 server and have a maintenance plan that does complete
backups daily, with a 10 day retention on files.
For some reason, I have .bak files that go back as far as January on several
databases, which is an issue in and of itself.
My question is, are all of the .bak files independent of each other and can
I safely delete older ones without affecting the more recent backups?
Thanks you,
LarryAre we talking about database or log backups?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Larry" <Larry@.discussions.microsoft.com> wrote in message
news:C86E6A38-8449-4ADB-8F5D-0559B676AB16@.microsoft.com...
> I'm running a SQL 2000 server and have a maintenance plan that does complete
> backups daily, with a 10 day retention on files.
> For some reason, I have .bak files that go back as far as January on several
> databases, which is an issue in and of itself.
> My question is, are all of the .bak files independent of each other and can
> I safely delete older ones without affecting the more recent backups?
> Thanks you,
> Larry|||Database, not transaction.
"Tibor Karaszi" wrote:
> Are we talking about database or log backups?
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Larry" <Larry@.discussions.microsoft.com> wrote in message
> news:C86E6A38-8449-4ADB-8F5D-0559B676AB16@.microsoft.com...
> > I'm running a SQL 2000 server and have a maintenance plan that does complete
> > backups daily, with a 10 day retention on files.
> >
> > For some reason, I have .bak files that go back as far as January on several
> > databases, which is an issue in and of itself.
> >
> > My question is, are all of the .bak files independent of each other and can
> > I safely delete older ones without affecting the more recent backups?
> >
> > Thanks you,
> >
> > Larry
>|||A more recent db backup is not dependent on an earlier db backup. However if you need to do point in
time restore to some point between the earlier and the more recent db backup and you also have log
backups covering that period, then you want to save the earlier db backup.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Larry" <Larry@.discussions.microsoft.com> wrote in message
news:D06E7454-66E6-4153-8EFA-3B7A0FF7C62E@.microsoft.com...
> Database, not transaction.
> "Tibor Karaszi" wrote:
>> Are we talking about database or log backups?
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Larry" <Larry@.discussions.microsoft.com> wrote in message
>> news:C86E6A38-8449-4ADB-8F5D-0559B676AB16@.microsoft.com...
>> > I'm running a SQL 2000 server and have a maintenance plan that does complete
>> > backups daily, with a 10 day retention on files.
>> >
>> > For some reason, I have .bak files that go back as far as January on several
>> > databases, which is an issue in and of itself.
>> >
>> > My question is, are all of the .bak files independent of each other and can
>> > I safely delete older ones without affecting the more recent backups?
>> >
>> > Thanks you,
>> >
>> > Larry
>>