---
title: "Backup a Cloud Sites MSSQL Database Using a cron"
source: "https://docs.nexcess.com/hosting/cloud-sites/database-management/mssql/backup-a-cloud-sites-mssql-database-using-a-cron/"
description: "Follow these steps to create a cron to back up your MSSQL databases."
vertical: "Hosting"
date: "2024-03-04"
last_modified: "2026-07-02"
---

# Backup a Cloud Sites MSSQL Database Using a cron

| ### **Code Examples:** |
|---|
| The code provided below is only an example. Your specific website may require different code. As explained in our article [Management and Support Levels](https://docs.nexcess.com/hosting/portal/support-center/management-and-support-levels/), we are unable to help you troubleshoot code issues. We recommend speaking with your developer before implementing any scripts. |

[Microsoft SQL Server](https://www.liquidweb.com/sql-server-hosting/) has a built-in backup feature that you can run as a query or a stored procedure. You can configure the output file to write into an FTP folder. This tutorial will explain how to accomplish an MSSQL database backup using scripts to write into the folder. While Cloud Sites now offers automatic backups, MSSQL is not included in these backups, you will need to follow the steps below to create a cron to back up your MSSQL databases.

This article will walk you through the steps of creating the backup folder and the cron job, you will:

1. [Create the Folder](#folder)
2. [Create the Stored Procedure](#procedure)
3. [Create the Web Page](#page)
4. [Create the Cron Job](#cron)

**There are some unsupported commands in cron, see the section [Unsupported Commands in Cron](#commands) for the list.**

| ### **Warning:** |
|---|
| It is important to use caution when running unfamiliar scripts. If you are unfamiliar with running scripts for cron jobs, please consult a developer to help you deploy them. |

## Create the Folder

First, you will need to create a folder to store the backup in your FTP application.

1. Connect your FTP client to the site in Cloud Sites that has the database attached that you want to back up.  
    ![ftp client open](https://docs.nexcess.com/wp-content/uploads/2026/06/help.liquidweb.com_3HCMa0.png)
2. Create a folder called backups inside the /web directory.  
    ![create a folder](https://docs.nexcess.com/wp-content/uploads/2026/06/help.liquidweb.com_SwbkTP.png)
3. In your FTP client, right-click the folder you just created and set its permissions to 766. If you are unable to update permissions in your FTP client, we suggest using FileZilla, CoffeeCup FTP or the Firefox plugin FireFTP.  
      
      
      
      
      
      
      
    | ### **Permissions**     These permissions give all users write permissions for the folder. For more information on permissions, see our article [What Are File Permissions?](https://www.liquidweb.com/help-docs/what-are-file-permissions/). |
    |---|
    
      
    ![gif showing file permissions being set](https://docs.nexcess.com/wp-content/uploads/2026/06/help.liquidweb.com_FxnXhs.gif)
4. Last, you will need to set the permissions on the /web folder on your site to 751.  
    ![permissions set to 751 for folder](https://docs.nexcess.com/wp-content/uploads/2026/06/help.liquidweb.com_4yhibl.png)

## Create the Stored Procedure

Now you need to create a stored procedure that will perform the backup with an input parameter for the file name. Connect to your MSSQL server database using [myLittleAdmin](https://www.liquidweb.com/help-docs/logging-into-mylittleadmin-from-cloud-sites/) or [Windows SQL Server Management Studio Express ](https://www.liquidweb.com/help-docs/using-windows-sql-server-management-studio-for-cloud-sites/) and run a query similar to the following one. In this example, the stored procedure is DatabaseBackup.

```
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[DatabaseBackup]
@FileName nvarchar(256)
AS

BEGIN

SET NOCOUNT ON;

BACKUP DATABASE [123456_YourDatabase] TO DISK = @FileName WITH COPY_ONLY, NOFORMAT, NOINIT, NAME = N'Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
END
```

## Create the Web Page

Last, you’ll create a web page that has the code to execute the stored procedure. You can use any language supported on Windows such as ASP Classic or ASP.NET. For this task, we recommend ASP Classic so that there is no .dll file and no application restart is needed.

1. Create a new ASP page and call it backupdb.asp. Edit the location path and SQL connection string. The content for the site is below.  
    ```
    <%@LANGUAGE="VBScript" CODEPAGE="65001"%><br></br></br>xhtml1-transitional.dtd"><br></br><br></br><html ><br></br><head><br></br><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br></br><title>Untitled Document</title><br></br><br></br></head><br></br><br></br><body><br></br><br></br><%<br></br>dim thismonth, thisday, thisyear, location, filename, ver, extention, abolutepath<br></br>thismonth= datepart("m", now())<br></br>thisday=datepart("d", now())<br></br>thisyear=datepart("yyyy",now())<br></br><br></br>location="fs1-n03stor1wc1dfw8382492382489www.yoursite.combackups"<br></br>filename="dbBackup-" & thismonth & "-" & thisday & "-" & thisyear & "_"<br></br><br></br>ver=1<br></br>extention=".bak"<br></br><br></br>absolutepath=location & filename & ver & extention<br></br><br></br>set fso = Server.CreateObject("Scripting.FileSystemObject")<br></br><br></br>while (fso.FileExists(absolutepath)=True)<br></br>ver=ver+1<br></br>absolutepath=location & filename & ver & extention<br></br>wend<br></br><br></br>'pre Create the file<br></br>Dim fs,f<br></br>Set fs=Server.CreateObject("Scripting.FileSystemObject")<br></br>Set f=fs.CreateTextFile(absolutepath)<br></br>set f=nothing<br></br>set fs=nothing<br></br>'finished creating the file<br></br><br></br>Set cn = Server.CreateObject("ADODB.Connection")<br></br>cn.connectionString=<br></br>"Provider=SQLOLEDB;Server=mssql12xx.wc1;Database=123456_YourDatabase;Uid=123456_YourUsername;<br></br>Pwd=Yourpassword;"<br></br><br></br>cn.open<br></br><br></br>Set cmd = Server.CreateObject("ADODB.Command")<br></br>Set cmd.ActiveConnection = cn<br></br>cmd.CommandText = "FullBackup"<br></br>cmd.CommandType = 4 'adCmdStoredProc<br></br><br></br>cmd.Parameters.Refresh<br></br>cmd.Parameters(1) = absolutepath<br></br><br></br>cmd.Execute<br></br><br></br>cn.close<br></br><br></br>%><br></br><br></br>Execution complete: Filename=<%= filename & ver & extention%><br></br><br></br></body><br></br></html>
    ```
2. Upload the webpage you just created into the folder created in the first step using your FTP client.

![transferring site file](https://docs.nexcess.com/wp-content/uploads/2026/06/help.liquidweb.com_UwKl1I.png)## Create the Cron Job

The last step in the process is to schedule the cron job. See our article [Creating Cron Jobs in Cloud Sites](https://www.liquidweb.com/help-docs/creating-cron-jobs-in-cloud-sites/) for information on scheduling a cron job.

| ### **Using cURL to Execute** |
|---|
| When setting up the Cron job, it is important that the script file selected is cURL to properly execute the script. Cron jobs that run over 900 seconds (15 minutes) are automatically terminated. |

## Unsupported Commands and Cron

Some functions of commands have been restricted to protect the integrity of the Cloud Sites Platform. See the list below for the commands that are not supported in Cloud Sites and scripts for crons.

- crontab
- df
- dmesg
- du
- find
- getent
- ifconfig
- links
- ln
- netstat
- ps
- pstree
- route
- rpm
- uptime
- ypcat
- yppasswd
- yum

| ### **Cloud Sites Backups** |
|---|
| There are options for setting up automated backups in Cloud Sites, see our article [What is Cloud Sites Backup?](https://www.liquidweb.com/help-docs/what-is-cloud-sites-backup/) for more information. |
