I am using SQL Server 2017 for Linux, and the Maintenance Plans are missing from the Management menu.
Does anyone knows if the Maintenance Plans are available for SQL Server for Linux? I can't find anything related to this topic.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
As you can read on Microsoft SQL Server documentation (here on the Known Issues section), maintenance plans are not supported on SQL Server Management Studio for SQL Server on Linux.
However, you can create your own SQL Server jobs to perform backups, index and statistics maintenance as shown below.
Create a job
CREATE DATABASE SampleDB ; USE msdb ; GO EXEC dbo.sp_add_job @job_name = N’Daily SampleDB Backup’ ; GO
Add one or more job steps
EXEC sp_add_jobstep @job_name = N’Daily SampleDB Backup’, @step_name = N’Backup database’, @subsystem = N’TSQL’, @command = N’BACKUP DATABASE SampleDB TO DISK = \ N”/var/opt/mssql/data/SampleDB.bak” WITH NOFORMAT, NOINIT, \ NAME = ”SampleDB-full”, SKIP, NOREWIND, NOUNLOAD, STATS = 10′, @retry_attempts = 5, @retry_interval = 5 ; GO
Create a job schedule
EXEC dbo.sp_add_schedule @schedule_name = N’Daily SampleDB’, @freq_type = 4, @freq_interval = 1, @active_start_time = 233000 ; USE msdb ; GO
Attach the schedule and add the job server
EXEC sp_attach_schedule @job_name = N’Daily SampleDB Backup’, @schedule_name = N’Daily SampleDB’; GO EXEC dbo.sp_add_jobserver @job_name = N’Daily SampleDB Backup’, @server_name = N'(LOCAL)’; GO
EXEC dbo.sp_start_job N’ Daily SampleDB Backup’ ; GO
For more information, please read this announcement.