DataBase backup

Posted by Mongz under C# on 10/13/2009 | Views : 2074 | Status : [Member] | Replies : 5
Hi guys, i created database backup, but now i want it to backup every time when the time is 00:00. Any help will be highly appreciated.




Responses

Posted by: Vuyiswamb on: 10/13/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
You need a Windows Service if you want to do it C# way if you dont need to code this , you can create a Job in SQL to backup on Schedule time. tell me how do you want to do it code way or SQL way ?

Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Mongz, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tridev_2005 on: 10/14/2009 [Member] Starter

Up
0
Down
visit this link you will get solution

http://www.noupe.com/php/10-ways-to-automatically-manually-backup-mysql-database.html

Mongz, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mongz on: 10/14/2009 [Member] Starter

Up
0
Down
Can you give me both ways, but i'll preferer SQL shedule time.

Mongz, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 10/15/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
ok its is Simple

Create a Stored Procedure that does a Backup like this

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


-- backup a database

ALTER PROCEDURE [dbo].[sp_BackupDatabase]

@databasename varchar(32),
@path varchar(256),
@filename varchar(64)

AS

set nocount on

declare @sql varchar(4000)

select @sql = 'BACKUP DATABASE ' + ltrim(rtrim( @databasename ))
select @sql = @sql + ' TO DISK = ''' + ltrim(rtrim(@path)) + ltrim(rtrim(@filename)) + ''' '
select @sql = @sql + ' WITH INIT'
--print @sql
execute ( @sql )



Pass the Correct Parameters to the SP and go to SQL Management studio , under the "SQl Server Agent" , Collapse it and you will find the Job, Right Click on it and say new Job.

-->A dialog box will appear , give your job a name

--> Go to Steps on the Section on your right hand side

-->Give the name of the Step

--> leave the Type as "Transact SQL Script"

-->leave "Runas" Option as empty

-->In the Database, Choose the database that has a Stored procedure. You can create this backup database stored Procedure in the master database and choose it as it is selected now.

--> in the Command that is where you call the sp i gave and pass the parameters

exec [dbo].[sp_BackupDatabase] 'MyDatabase','C:\DestinationPath\','Mybackupname'



Thank you for posting at DotnetFunda

Vuyiswa Maseko


Thank you for posting at Dotnetfunda
[Administrator]

Mongz, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santosh4u on: 10/15/2009 [Member] Bronze

Up
0
Down
Visit Below Link u will get all details with examples

http://www.dotnetfunda.com/codes/code374-take-backup-at-your-own-time.aspx

Regards
Santosh
More Details Plz Visit
http://santoshdotnetarena.blogspot.com/2009/10/take-backup-at-your-own-time.html

Mongz, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response