USE [Levelcode-LevelOS]
GO

DROP PROCEDURE IF EXISTS [dbo].[sp_BackupFull]
GO

CREATE PROCEDURE [dbo].[sp_BackupFull]
AS
BEGIN
    SET NOCOUNT ON;

    DECLARE @Caminho NVARCHAR(500);

    SET @Caminho = '/var/opt/mssql/backups/Levelcode-LevelOS_FULL_'
                 + FORMAT(GETDATE(), 'yyyyMMdd_HHmmss') + '.bak';

    BACKUP DATABASE [Levelcode-LevelOS]
    TO DISK = @Caminho
    WITH FORMAT,
         INIT,
         NAME  = 'Backup FULL - Levelcode-LevelOS',
         STATS = 10;
END
GO

-- Confirma criação
SELECT name, create_date, modify_date
FROM sys.procedures
WHERE name = 'sp_BackupFull';


USE [Levelcode-LevelOS]
GO

DROP PROCEDURE IF EXISTS [dbo].[sp_BackupDiferencial]
GO

CREATE PROCEDURE [dbo].[sp_BackupDiferencial]
AS
BEGIN
    SET NOCOUNT ON;

    DECLARE @Caminho NVARCHAR(500);

    SET @Caminho = '/var/opt/mssql/backups/Levelcode-LevelOS_DIFF_'
                 + FORMAT(GETDATE(), 'yyyyMMdd_HHmmss') + '.bak';

    BACKUP DATABASE [Levelcode-LevelOS]
    TO DISK = @Caminho
    WITH DIFFERENTIAL,
         INIT,
         NAME  = 'Backup DIFERENCIAL - Levelcode-LevelOS',
         STATS = 10;
END
GO

-- Confirma ambas criadas
SELECT name, create_date, modify_date
FROM sys.procedures
WHERE name IN ('sp_BackupFull', 'sp_BackupDiferencial')
ORDER BY name;