What you want to do is add a scheduled task for SQLServerAgent, and let it do the backup on a scheduled basis. If you have enterprise manager, use the database amintenace wizared to create the backup jobs. If not the TSQL code below will create a weekkly backup schedule, rotating the backup file name and overwiting the oldest. (there is a better way to do this, sql can manage the retention for you, but this is all I had handy)
BEGIN
BEGIN TRANSACTION
DECLARE @JobID BINARY(16)
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
IF (SELECT COUNT(*) FROM msdb.dbo.syscategories WHERE name = N'[Uncategorized (Local)]') < 1
EXECUTE msdb.dbo.sp_add_category @name = N'[Uncategorized (Local)]'
-- Delete the job with the same name (if it exists)
SELECT @JobID = job_id FROM msdb.dbo.sysjobs WHERE (name = N'MyDatabase backup1')
IF (@JobID IS NOT NULL) BEGIN
-- Check if the job is a multi-server job
IF (EXISTS (SELECT *
FROM msdb.dbo.sysjobservers
WHERE (job_id = @JobID) AND (server_id <> 0)))
BEGIN
-- There is, so abort the script
RAISERROR (N'Unable to import job ''MyDatabase backup1'' since there is already a multi-server job with this name.', 16, 1)
GOTO QuitWithRollback
END
ELSE
-- Delete the [local] job
EXECUTE msdb.dbo.sp_delete_job @job_name = N'MyDatabase backup1'
SELECT @JobID = NULL
END
BEGIN
-- Add the job
EXECUTE @ReturnCode = msdb.dbo.sp\_add\_job @job\_id = @JobID OUTPUT , @job\_name = N'MyDatabase backup1', @owner\_login\_name = N'sa', @description = N'No description available.', @category\_name = N'\[Uncategorized (Local)\]', @enabled = 1, @notify\_level\_email = 0, @notify\_level\_page = 0, @notify\_level\_netsend = 0, @notify\_level\_eventlog = 2, @delete\_level= 0
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
-- Add the job steps
EXECUTE @ReturnCode = msdb.dbo.sp\_add\_jobstep @job\_id = @JobID, @step\_id = 1, @step\_name = N'Step 1', @command = N'sp\_Hmx\_BackupDb ''MyDatabase'',''D:\\Database\\DbBackups'',''MyDatabase1.BAK''', @database\_name = N'MyDatabase', @server = N'', @database\_user\_name = N'', @subsystem = N'TSQL', @cmdexec\_success\_code = 0, @flags = 0, @retry\_attempts = 0, @retry\_interval = 0, @output\_file\_name = N'', @on\_success\_step\_id = 0, @on\_success\_action = 1, @on\_fail\_step\_id = 0, @on\_fail\_action = 2
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXECUTE @ReturnCode = msdb.dbo.sp\_update\_job @job\_id = @JobID, @start\_step\_id = 1
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWith