Создание бекапов simple restore model DB за 3 периода: вчера, последнее воскресение, последнее воскресение месяца

1я процедура. туда передается подпапка, в которую бекапятся все базы, кроме системных.

CREATE PROCEDURE [dbo].[sp_backup_databases_to_subfolder]
(@subfolder nvarchar(64) )
--exec sp_backup_databases
as
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
--DECLARE @DeleteDate DATETIME =DATEADD(wk,-2,GETDATE()); -- Cutoff date
-- Path to backups.
SET @path = 'K:\Backup\';
-- Get date to include in file name.
--SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112);
-- Dynamically get each database on the server.
DECLARE db_cursor CURSOR FOR
SELECT name
FROM master.sys.databases
WHERE name NOT IN ('master','model','msdb','tempdb');
OPEN db_cursor;
FETCH NEXT FROM db_cursor INTO @name;
-- Loop through the list to backup each database.
WHILE @@FETCH_STATUS = 0
BEGIN 
      -- Build the path and file name.
	  SET @fileName = @path + @subfolder + @name + '_FULL' + /*'_' + @fileDate +*/ '.bak';
      -- Backup the database.
      BACKUP DATABASE @name TO DISK = @fileName WITH COMPRESSION, INIT, NOSKIP, NOUNLOAD;
      -- Loop to the next database.
      FETCH NEXT FROM db_cursor INTO @name;
END 
-- Purge old backup files from disk.
-- EXEC master.sys.xp_delete_file 0,@path,'BAK',@DeleteDate,0;
-- Clean up.
CLOSE db_cursor;
DEALLOCATE db_cursor;

2я процедура. Запускает 3 раза 1ю процедуру с разные параметрами подпапок

CREATE PROCEDURE [dbo].[sp_backup_databases_3times]
AS
--yesterday
EXEC adm.dbo.sp_backup_databases_to_subfolder ''
--Sunday
IF DATENAME(dw,GETDATE()) = 'Sunday'
EXEC adm.dbo.sp_backup_databases_to_subfolder 'Weekly\'
--Last sunday of month
IF	CAST(getdate() as date) = 
	CAST(DATEADD(day,DATEDIFF(day,'19000107',DATEADD(month,DATEDIFF(MONTH,0,GETDATE()),30))/7*7,'19000107') as date)
EXEC adm.dbo.sp_backup_databases_to_subfolder 'Monthly\'