• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 407
  • Last Modified:

sql server 2008 full bakup every night

hello experts, how I can make a full bakup every night. In addition to the name of the backup has the date and time
0
enrique_aeo
Asked:
enrique_aeo
  • 2
3 Solutions
 
smoutkastCommented:
Hi Enrique. hopefully the link below can help you out

http://stackoverflow.com/questions/3180007/how-to-schedule-backup-in-sql-server-2008
0
 
Vijaya Reddy Pinnapa ReddyCommented:
1. Create to a job and configure schedule to run the job daily at specific time.

The script to run everyday to take back is:

DECLARE @name VARCHAR(50) -- database name 
DECLARE @path VARCHAR(256) -- path for backup files 
DECLARE @fileName VARCHAR(256) -- filename for backup 
DECLARE @fileDate VARCHAR(20) -- used for file name 

SET @path = 'C:\Backup\' 

SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112) 

DECLARE db_cursor CURSOR FOR 
SELECT name 
FROM master.dbo.sysdatabases 
WHERE name='databasename'

OPEN db_cursor 
FETCH NEXT FROM db_cursor INTO @name 

WHILE @@FETCH_STATUS = 0 
BEGIN 
SET @fileName = @path + @name + '_' + @fileDate + '.BAK' 
BACKUP DATABASE @name TO DISK = @fileName 

FETCH NEXT FROM db_cursor INTO @name 
END 

CLOSE db_cursor 
DEALLOCATE db_cursor 

Open in new window


Also refer the following docs.
http://msdn.microsoft.com/en-us/library/ms190268
http://msdn.microsoft.com/en-us/library/ms191439
http://www.mssqltips.com/sqlservertip/1070/simple-script-to-backup-all-sql-server-databases/
0
 
enrique_aeoAuthor Commented:
can you explain me
1. Create to a job and configure schedule to run the job daily at specific time.
0
 
Vijaya Reddy Pinnapa ReddyCommented:
Go through the following link to create a job.
http://msdn.microsoft.com/en-us/library/ms190268

Expand the SQL server agent
Right click on 2nd right click on jobs --> select create new job
1) Give the name of the job
2)In step, click on new give the name of the step and copy the above command in command box
3)In schedules give name and in the schedule type select "Recurring".
In the Occurs, select Daily and provide the details etc.
If you want configure remaing(alerts,notifications,Targets) options, otherwise click ok.

This job will be executed everyday at scheduled time.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now