---
title: "Data Backup"  
description: "Data Backup"  
author: "Amresh Kushwaha"  
published: 2011-05-12  
updated: 2011-05-14  
canonical: https://www.mindstick.com/forum/242/data-backup  
category: "mssql server"  
tags: ["mssql server"]  
reading_time: 1 minute  

---

# Data Backup

How to take [backup](https://www.mindstick.com/interview/1205/what-is-the-command-to-take-backup-and-restore-for-sharepoint-site) of sel [server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) 2005

## Replies

### Reply by Amresh Kushwaha

Thanku Awadhendra Tiwari Sir Your Database Backup Code is Very Helpful\
\
\
\

### Reply by Anonymous User

Write down following code snippet in c# to take backup. One thing remeber that creadential should be changed..

```
    using System;
    using System.Data;
    using System.Collections;    using Microsoft.SqlServer.Management.Common;
    using Microsoft.SqlServer.Management.Smo;    class Program
    {
        static void Main(string[] args)
        {
            BackupDeviceItem bdi =
                new BackupDeviceItem("AdventureWorks.bak", DeviceType.File);            Backup bu = new Backup(  );
            bu.Database = "AdventureWorks";
            bu.Devices.Add(bdi);
            bu.Initialize = true;            // add percent complete and complete event handlers
            bu.PercentComplete +=
                new PercentCompleteEventHandler(Backup_PercentComplete);
            bu.Complete +=new ServerMessageEventHandler(Backup_Complete);            Server server = new Server("localhost");
            bu.SqlBackup(server);            Console.WriteLine(Environment.NewLine + "Press any key to continue.");
            Console.ReadKey(  );
        }        protected static void Backup_PercentComplete(
            object sender, PercentCompleteEventArgs e)
        {
            Console.WriteLine(e.Percent + "% processed.");
        }        protected static void Backup_Complete(object sender, ServerMessageEventArgs e)
        {
            Console.WriteLine(Environment.NewLine + e.ToString(  ));
        }
    }
```

### Reply by Amresh Kushwaha

I want to command

### Reply by Uttam Misra

In Management Studio select database >> right click on selected database >> tasks >> back up


---

Original Source: https://www.mindstick.com/forum/242/data-backup

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
