:'( Hello everyone,

i wrote an application that makes database backups and zips them.

Can anyone please tell me what i need to do in order to get the apllication to work on IIS 6 windows server 2003 SQL 05

1. The application works fine on machines for both XP and VISTA.
2. The application runs fine on Win Server 2003 however :

my problem is : obviously the database is in use by the web site.

How can i give my application permission to make the backup while the website is connected to the database ?

regards,

You need to issue a backup command to the SQL Server and then archive the .bak file. You never want to access the .mdf and .ldf files directly.

Use this query:

BACKUP DATABASE [DBName] TO  DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL\BackUpManual\DBName.bak' WITH  INIT ,  NOUNLOAD ,  NAME = N'DBName backup',  NOSKIP ,  STATS = 10,  NOFORMAT

Note: The file path is relative to the machine running the SQL Server, not the client issuing the command

Hi my friend , i have that .

/// <summary>
        /// Backups are done here
        /// </summary>
        #region Backup Methods
        #region Full Backup method
        void Fullbackup()
        {

            method = "Full";
            // Creating connection
            Username = txtUsername.Text;
            Password = txtPassword.Text;
            // specifying connection string
            DBhandler.DbWinHandler dbHandler = new DBhandler.DbWinHandler("Data Source=" + txtServerName.Text + ";Initial Catalog=master;Persist Security Info=True;User ID=" + Username + ";Password=" + Password);

            // Getting the items that has to be backed up
            foreach (string lstItem in listBoxControl2.Items)
            {
                dbName = lstItem;

                if (!Directory.Exists(textEdit1.Text + "/DataSafe Backups/Temp/"))
                {
                    DirectoryInfo newDir = new DirectoryInfo(textEdit1.Text + "/DataSafe Backups/Temp/");
                    newDir.Create();
                }

                lblStatus.Text = "Backing up " + dbName;
                lblStatus.Refresh();
                dbHandler.SmartGetDataSet("BACKUP DATABASE " + dbName + " TO DISK = '" + textEdit1.Text + "/DataSafe Backups/Temp/" + dbName + ".bak' WITH NAME = '" + dbName + ".bak'");

                ZipFile();
            }
        }
        #endregion

        #region Differential Backup method
        void Diffbackup()
        {
            method = "Diff";
            // Creating connection
            Username = txtUsername.Text;
            Password = txtPassword.Text;
            // specifying connection string
            DBhandler.DbWinHandler dbHandler = new DBhandler.DbWinHandler("Data Source=" + txtServerName.Text + ";Initial Catalog=master;Persist Security Info=True;User ID=" + Username + ";Password=" + Password);

            // Getting the items that has to be backed up
            foreach (string lstItem in listBoxControl2.Items)
            {
                dbName = lstItem;

                if (!Directory.Exists(textEdit1.Text + "/DataSafe Backups/Temp/"))
                {
                    DirectoryInfo newDir = new DirectoryInfo(textEdit1.Text + "/DataSafe Backups/Temp/");
                    newDir.Create();
                }

                lblStatus.Text = "Backing up " + dbName;
                lblStatus.Refresh();
                dbHandler.SmartGetDataSet("BACKUP DATABASE " + dbName + " TO DISK = '" + textEdit1.Text + "/DataSafe Backups/Temp/" + dbName + "_Differential.bak' WITH DIFFERENTIAL, NAME = '" + dbName + ".bak'");

                ZipFile();
            }
        }
        #endregion

        #region LOG backup method
        void Logbackup()
        {
            method = "Log";
            // Creating connection
            Username = txtUsername.Text;
            Password = txtPassword.Text;
            // specifying connection string
            DBhandler.DbWinHandler dbHandler = new DBhandler.DbWinHandler("Data Source=" + txtServerName.Text + ";Initial Catalog=master;Persist Security Info=True;User ID=" + Username + ";Password=" + Password);

            // Getting the items that has to be backed up
            foreach (string lstItem in listBoxControl2.Items)
            {
                dbName = lstItem;

                if (!Directory.Exists(textEdit1.Text + "/DataSafe Backups/Temp/"))
                {
                    DirectoryInfo newDir = new DirectoryInfo(textEdit1.Text + "/DataSafe Backups/Temp/");
                    newDir.Create();
                }

                lblStatus.Text = "Backing up " + dbName;
                lblStatus.Refresh();
                dbHandler.ExecuteCommand("BACKUP LOG  " + dbName + " TO DISK = '" + textEdit1.Text + "/DataSafe Backups/Temp/" + dbName + "_LOG.bak' WITH NAME = '" + dbName + ".bak'");

                ZipFile();
            }
        }
        #endregion
        #endregion

PS the DBhandler.DbWinHandler is just a class we use to connect to SQL.

should i add any of the following ?

INIT ,
NOUNLOAD
NOSKIP ,
STATS = 10,
NOFORMAT

????

What is the error you receive?

well it just bounces ...

No error...

however the backup file is 0 bytes

Well try a full backup (using the query I posted) instead of a differential backup. This will indicate if backups are working at all.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.