SAP Business One SDK Support

Scheduled Automatic SQL Database Backup using SSMS and Using Stored Procedure

There are two ways to schedule the DB backup in SQL for SAP Business One DB. 

Option 1 : Using Store Procedure - Follow the Below Steps

1: Create a Store procedure in master DB. - Check Link for Query
2: Run the Query in master
3: Open Object Explorer > SQL Server Agent > Jobs > Right Click (New Job)..

4: Left side > General > 
  > Set Name " Auto Backup"
  > Set Owner "sa" 
  > OK


5: Left Side Steps 
  >  New
  >  Sub Window > set StepName
  >  Type : T-SQL
  > Database : master
  > Command : EXEC [LiveAutoBackup]


6: Left Side : Schedule 
  > New
  > Schedule Name 
  > Schedule Type : Set as Recurring (if backup need to be done repeatedly)
  > Other Details all depend upon you , Occurs, Recurs, Daily Frequency 


7: OK and Close all Window.

Note: Make sure SQL server Agent Service is running in the system (Run > Services.msc > SQL Server Agent).

Advertisement




Option 2: SQL Maintenance Plan method. 
Note : Below method, I have found issue in non-release of SQL Memory after the schedule of backup is completed(Note this in DB size 15GB+); You can try the same and let me know if you have faced any memory issue.


Below details are from the Blog Owner Kenan.jaddeny  Origanl Blog Link : LinkSAPBlog


Open your SQL server Management Studio

Log into SQL Server Management Studio (SSMS) and connect to the database. Go to the Object Explorer window (located on the left) and make sure that your SQL Server Agent is running.

Open the folder named Management and find the Maintenance Plan folder. Then right-click on Maintenance Plan folder and select New Maintenance Plan. How to Backup SQL Database Automatically

Enter the name of the Maintenance Plan you are going to create. Press on the calendar icon on the top-right highlighted section on the job schedule screen. It will bring up the job schedule screen. In the opened window set up all necessary backup schedule.

Now choose from the left-side window, select the Backup Database Task to set up the backup process and drag the element onto the right window as shown in the picture.

Now you need double-click on the database task. In the opened window set up, the configuration related to the database backup.

Specify the databases you are going to backup. Also, you can pick the files to expire after specific period or on a specific date.

Now from the Object Explorer > SQL Server Agent > Jobs
under the SQL Agent jobs, we may find the job that created automatically according to the Maintenance Plan that we created.

And right-click on this job, and press Start job at Step, to test the maintenance plan that we created before,

Now let’s go to the backup file that we defined previously to check the backup,

SQL Server Express editions do not offer a way to schedule either jobs or maintenance plans because the SQL Server Agent component is not included in these editions. Therefore, you have to take in consideration a different approach to back up your databases when you use these editions.

Currently SQL Server Express users can back up their databases by using one of the following methods:

  • Use SQL Server Management Studio Express. This is installed together with either SQL Server Express Advanced Service or SQL Server Express Toolkit.
  • Use a Transact-SQL script that uses the BACKUP DATABASE family of commands.

Maintenance Plans are more suitable for less experienced DBAs because they provide an easy to use GUI, and do not require manually written maintenance scripts. The downside of Maintenance Plans is that the tasks that Maintenance Plans provide are basic and don’t leave space for customization.

A Maintenance Plan is also atomic and is therefore not able to run multiple tasks. Each type of maintenance task within a single Maintenance Plan can only be configured to run once within that Plan. For example, if a task that is made to delete older backup files it will only delete one file type at a time. Because of this multiple Maintenance Plans have to be created just to perform a single task, in some cases, and every Maintenance Plan has to have a corresponding SQL Server Agent job to be scheduled.

That is all, your backup plan is ready, and all your backups will be made according to the specified schedule. Now you know how to backup SQL database automatically.



No comments: