HI,
I'm new to sql and i would like to run a script to make a backup of msde dat
abase, i have modified this script but i'm getting some errors running it. C
ould any first tell me if my @.command syntaxe is correct if not what would b
e a way of setting a schedu
led job to run a backup of multiple database in one job.
Here are the errors i'm getting
C:\Documents and Settings\ncsadmin>osql -U sa -i c:\smslab3.sql -n
Password:
Msg 119, Level 15, State 1, Server SMSLAB3, Line 7
Must pass parameter number 5 and subsequent parameters as '@.name = value'.
After the form '@.name = value' has been used, all subsequent parameters must
be
passed in the form '@.name = value'.
Msg 119, Level 15, State 1, Server SMSLAB3, Line 7
Must pass parameter number 5 and subsequent parameters as '@.name = value'.
After the form '@.name = value' has been used, all subsequent parameters must
be
passed in the form '@.name = value'.
Msg 156, Level 15, State 1, Server SMSLAB3, Line 10
Incorrect syntax near the keyword 'EXEC'.
Thanks
---
--This Transact-SQL script creates a backup job and calls sp_start_job to ru
n the job.
-- Create job.
-- You may specify an e-mail address, commented below, and/or pager, etc.
-- For more details about this option or others, see SQL Server Books Online
.
USE msdb
EXEC sp_add_job @.job_name = 'MSDEBACKUPJOB',
@.enabled = 1,
@.description = 'MSDEBACKUPJOB',
@.owner_login_name = 'sa',
@.notify_level_eventlog = 2,
@.notify_level_email = 2,
@.notify_level_netsend =2,
@.notify_level_page = 2
-- @.notify_email_operator_name = 'raould.traore@.mcgill.ca'
go
-- Add job step (backup data).
USE msdb
EXEC sp_add_jobstep @.job_name = 'MSDEBACKUPJOB',
@.step_name = 'Backup msdb Data',
@.subsystem = 'TSQL',
@.command = 'BACKUP DATABASE EDMSO TO DISK = ''c:\MSDESQLBACKUP\EDMSO.dat_bak
''','BACKUP DATABASE master TO DISK = ''c:\MSDESQLBACKUP\master.dat_bak''','
BACKUP DATABASE model TO DISK = ''c:\MSDESQLBACKUP\model.dat_bak''','BACKUP
DATABASE msdb TO DISK = ''c
:\MSDESQLBACKUP\msdb.dat_bak''',
@.on_success_action = 3,
@.retry_attempts = 5,
@.retry_interval = 5
go
-- Add job step (backup log).
USE msdb
EXEC sp_add_jobstep @.job_name = 'MSDEBACKUPJOB',
@.step_name = 'Backup msdb Log',
@.subsystem = 'TSQL',
@.command = 'BACKUP LOG EDMSO TO DISK = ''c:\MSDESQLBACKUP\EDMSO.log_bak''','
BACKUP LOG master TO DISK = ''c:\MSDESQLBACKUP\master.log_bak''','BACKUP LOG
model TO DISK = ''c:\MSDESQLBACKUP\model.log_bak''','BACKUP LOG msdb TO DIS
K = ''c:\MSDESQLBACKUP\msdb
.log_bak''',
@.on_success_action = 1,
@.retry_attempts = 5,
@.retry_interval = 5
go
-- Add the target servers.
USE msdb
EXEC sp_add_jobserver @.job_name = 'MSDEBACKUPJOB', @.server_name = N'(local)'
-- Run job. Starts the job immediately.
USE msdb
EXEC sp_add_jobschedule @.job_name = 'MSDEBACKUPJOB',
@.name = 'ScheduledBackup_msdb',
@.freq_type = 4, --daily
@.freq_interval = 1, --once
@.active_start_time = '153000' --(10:30 am) 24hr HHMMSS.
---Ralph,
I have modified your script slightly (below) and it should now work. There
was a problem with the number of single quotes which meant that the command
wasn't enclosed in a string. This applied to both commands.
Regards,
Paul Ibison
EXEC sp_add_job @.job_name = 'MSDEBACKUPJOB',
@.enabled = 1,
@.description = 'MSDEBACKUPJOB',
@.owner_login_name = 'sa',
@.notify_level_eventlog = 2,
@.notify_level_email = 2,
@.notify_level_netsend =2,
@.notify_level_page = 2
-- @.notify_email_operator_name = 'raould.traore@.mcgill.ca'
go
-- Add job step (backup data).
USE msdb
EXEC sp_add_jobstep @.job_name = 'MSDEBACKUPJOB',
@.step_name = 'Backup msdb Data',
@.subsystem = 'TSQL',
@.command = 'BACKUP DATABASE EDMSO TO DISK =
''c:\MSDESQLBACKUP\EDMSO.dat_bak'',BACKUP DATABASE master TO DISK =
''c:\MSDESQLBACKUP\master.dat_bak'',BACKUP DATABASE model TO DISK =
''c:\MSDESQLBACKUP\model.dat_bak'',BACKUP DATABASE msdb TO DISK =
''c:\MSDESQLBACKUP\msdb.dat_bak''',
@.on_success_action = 3,
@.retry_attempts = 5,
@.retry_interval = 5
go
-- Add job step (backup log).
USE msdb
EXEC sp_add_jobstep @.job_name = 'MSDEBACKUPJOB',
@.step_name = 'Backup msdb Log',
@.subsystem = 'TSQL',
@.command = 'BACKUP LOG EDMSO TO DISK =
''c:\MSDESQLBACKUP\EDMSO.log_bak'',BACKUP LOG master TO DISK =
''c:\MSDESQLBACKUP\master.log_bak'',BACKUP LOG model TO DISK =
''c:\MSDESQLBACKUP\model.log_bak'',BACKUP LOG msdb TO DISK =
''c:\MSDESQLBACKUP\msdb.log_bak''',
@.on_success_action = 1,
@.retry_attempts = 5,
@.retry_interval = 5
go
-- Add the target servers.
USE msdb
EXEC sp_add_jobserver @.job_name = 'MSDEBACKUPJOB', @.server_name = N'(local)'
-- Run job. Starts the job immediately.
USE msdb
EXEC sp_add_jobschedule @.job_name = 'MSDEBACKUPJOB',
@.name = 'ScheduledBackup_msdb',
@.freq_type = 4, --daily
@.freq_interval = 1, --once
@.active_start_time = '153000' --(10:30 am) 24hr HHMMSS.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment