SQL Server backup database and mail it

I looked and searched to find a way to backup the db SQL server and send the backup file to the email address using the sql server mail profile, but I did not receive it, I found about sending email when the db failed, and another notification, but I did not see about backing up and sending it by email automatically, is there a way to create a job for this? Thanks.

+4
source share
1 answer

If you double-click this SQL Agent job, go to the section Steps, add one more step there and follow the next procedure there. Also make sure that the next step is performed after the database backup step.

Exec sp_send_dbmail   
        @profile_name =  'profile_name' 
     ,  @recipients =  'ablabla@abc.com' 
     ,  @subject =  'Database Backups bla bla'  
     ,  @body =  'body'  
     ,  @file_attachments =  'B:\Backups\DB_Back.bak' 

This will send an email to the person with the backup file as an attachment. In addition, by default, the sql server has a limit on how large the file you can send, you can change their settings to send a larger file.

Consult your data protection team before you do this, I don’t think any company will allow this to happen :) just head

+4
source

Source: https://habr.com/ru/post/1605728/


All Articles