5 Replies Latest reply on Sep 16, 2008 8:57 AM by Alexandergx

    How to backup database

    nofear123
      Hi there,

      can someone explain me how to backup epo database with command line of osql?
      I have found articles in knwoledge base but i can´t backup database. I´m always getting error.
      The command should be:

      osql -U sa -P password -S C-VIRUS01\EPOSERVER -n -Q "BACKUP DATABASE [epo4_C-VIRUS01] TO DISK = ´c:\backup.bak´ WITH INIT,SKIP"

      When I type this i´m getting an error:

      [DBNETLIB]SQL Server doesn´t exist or no connection possible.
      [DBNETLIB]ConnectionOpen (Connect())

      Can someone give me a hint whats wrong?
        • 1. RE: How to backup database
          You must use the Instance Name i think.
          For e.g.\\.\pipe\mssql$SQLSERVERXPRESS\sql\query

          I do my Backup with the following Script:


          @echo off
          setlocal
          ::null *** DEKLARATION DER VARIABLEN ***

          ::null Bei SQL2000 muss osql aktiviert werden. Bei den Versionen funktioniert es zwar auch mit osql, aber es sollte sqlcmd.exe
          ::null aktiviert werden. Auerdem muss sich sqlcmd im Pfad befinden (Standard)
          set "SQLCMDoderOSQLexe=sqlcmd.exe"
          @rem set "SQLCMDoderOSQLexe=osql.exe"

          ::null Backupvariablen
          set "backupSpeicherPfad=E:\WSUS_DB_Backup"
          set "backupFileName=EPO.bak"
          set "backupDBname=ePO4_WSUS3"
          set "backupInstance=\\.\pipe\mssql$SQLSERVERXPRESS\sql\query -E"

          ::null Hier nach nichts mehr ndern...

          set "backupSpeicherOrt=%backupSpeicherPfad%\%backupFileName%"
          set "backupscript1=BACKUP DATABASE [%backupDBname%] TO DISK = N'%backupspeicherort%' WITH NOFORMAT, INIT, NAME = N'%backupDBname%-Vollstndig Datenbank Sichern', SKIP, NOREWIND, NOUNLOAD, STATS = 10"
          set "backupscript2=GO"
          set "backupscriptname=backup.sql"

          ::null *** ERSTELLEN DER SKRIPTE ***
          echo %backupscript1% > "%~dp0\%backupscriptname%"
          echo %backupscript2% >> "%~dp0\%backupscriptname%"

          ::null *** AUSFUEHREN DER SICHERUNG ***

          sqlcmd -S %backupInstance% -i "%~dp0\%backupscriptname%"


          set "backupSpeicherPfad=File Path to the Backup Folder"
          set "backupFileName=Filename.bak"
          set "backupDBname=Database Name"
          set "backupInstance=\\.\pipe\mssql$SQLSERVERXPRESS\sql\query -E" <--- instance

          When you are useing osql u have to change
          set "SQLCMDoderOSQLexe=sqlcmd.exe"
          @rem set "SQLCMDoderOSQLexe=osql.exe"
          in
          @rem set "SQLCMDoderOSQLexe=sqlcmd.exe"
          set "SQLCMDoderOSQLexe=osql.exe"
          • 2. RE: How to backup database
            nofear123
            I don´t have sqlcmd.exe on the server. :-(
            Only osql is present.
            • 3. RE: How to backup database
              Hi,
              read the last lines again ;)

               


              When you are useing osql u have to change
              set "SQLCMDoderOSQLexe=sqlcmd.exe"
              @rem set "SQLCMDoderOSQLexe=osql.exe"
              in
              @rem set "SQLCMDoderOSQLexe=sqlcmd.exe"
              set "SQLCMDoderOSQLexe=osql.exe"

              • 4. RE: How to backup database
                nofear123


                Okay, where to set these parameters?
                I´m a little bit confused now.
                • 5. RE: How to backup database
                  In the Script i posted on line 7 and 8.

                  Then change the Variables to your Setup

                  line 11-14
                  set "backupSpeicherPfad=File Path to the Backup Folder"
                  set "backupFileName=Filename.bak"
                  set "backupDBname=Database Name"
                  set "backupInstance=\\.\pipe\mssql$SQLSERVERXPRESS\sql \query -E" <--- instance

                  Then run the Script in the Dos Box or as Task and it should work.

                  I dont know an other way to do an Backup of the Epo Database.
                  Perhaps someone others know.