Source:MS SQL Restore/de: Difference between revisions

From SEPsesam
(Created page with "SEP sesam bietet die Webschnittstelle ''Aktivitäten'' -> ''Rücksicherungsassistant'', die intuitiver gestaltet ist und zusätzliche erweiterte Optionen im Vergleich zum ''GU...")
(Created page with "==={{anchor|original}}Wiederherstellung von MS SQL-Datenbanken am ursprünglichen Speicherort===")
Line 40: Line 40:
{{Anmerkung|SEP sesam bietet die Webschnittstelle ''Aktivitäten'' -> ''Rücksicherungsassistant'', die intuitiver gestaltet ist und zusätzliche erweiterte Optionen im Vergleich zum ''GUI Restore Wizard'' bietet. Andererseits unterstützt sie noch nicht die Rücksicherung spezieller Aufgabentypen, wie ''MS SQL'', ''PostgreSQL'', ''Oracle'', etc. Für diese Aufgabentypen können Sie nur den GUI-Wiederherstellungsassistenten verwenden, um Ihre Daten wiederherzustellen.}}
{{Anmerkung|SEP sesam bietet die Webschnittstelle ''Aktivitäten'' -> ''Rücksicherungsassistant'', die intuitiver gestaltet ist und zusätzliche erweiterte Optionen im Vergleich zum ''GUI Restore Wizard'' bietet. Andererseits unterstützt sie noch nicht die Rücksicherung spezieller Aufgabentypen, wie ''MS SQL'', ''PostgreSQL'', ''Oracle'', etc. Für diese Aufgabentypen können Sie nur den GUI-Wiederherstellungsassistenten verwenden, um Ihre Daten wiederherzustellen.}}


==={{anchor|original}}Restoring MS SQL databases to the original location===
==={{anchor|original}}Wiederherstellung von MS SQL-Datenbanken am ursprünglichen Speicherort===


When restoring MS SQL database to the original target path (the same as from where it was backed up), you can restore one or more databases at the same time. Note that the existing database files are overwritten when the original target path is used.   
When restoring MS SQL database to the original target path (the same as from where it was backed up), you can restore one or more databases at the same time. Note that the existing database files are overwritten when the original target path is used.   

Revision as of 16:09, 23 September 2021

Other languages:

Copyright © SEP AG 1999-2024. Alle Rechte vorbehalten.

Jede Form der Reproduktion der Inhalte dieses Benutzerhandbuches, ganz oder in Teilen, ist nur mit der ausdrücklichen schriftlichen Erlaubnis der SEP AG gestattet. Bei der Erstellung dieses Benutzerhandbuches wurde mit größtmöglicher Sorgfalt gearbeitet, um korrekte und fehlerfreie Informationen bereit stellen zu können. Trotzdem kann die SEP AG keine Gewähr für die Richtigkeit der Inhalte dieses Benutzerhandbuches übernehmen.

Docs latest icon.png Willkommen in der aktuellsten Version der SEP sesam Dokumentation 4.4.3/4.4.3 Beefalo V2. Frühere Versionen der Dokumentation finden Sie hier: MS SQL.


Übersicht

Die Sicherungs- und Wiederherstellungsoptionen von MS SQL Servern hängen vom eingestellten Datenbankwiederherstellungsmodell im SQL Server Management Studio ab, wie im Abschnitt Auswählen eines Wiederherstellungsmodells für Ihre MS SQL-Datenbank beschrieben ist.

Die folgenden drei Wiederherstellungsmodelle stehen zur Verfügung: einfach, vollständig und Bulk-logged. Normalerweise verwendet eine Datenbank entweder das volle oder das einfache Wiederherstellungsmodell, SEP empfiehlt jedoch das volle Wiederherstellungsmodell. Sie können die Datenbank jederzeit auf ein anderes Wiederherstellungsmodell umstellen. Eine ausführliche Erklärung finden Sie im Microsoft Artikel Recovery Model Overview.

Wiederherstellung von MS SQL-Datenbanken

SEP sesam ermöglicht die Wiederherstellung der MS SQL Datenbanken an den ursprünglichen oder an einen neuen Ort. Bei der Wiederherstellung an den Originalort, z.B. um ein Disaster Recovery durchzuführen, müssen Sie die Option Overwrite existing items auswählen, wie im Abschnitt Wiederherstellung an den Originalort beschrieben. Dies bedeutet, dass eine Datenbank, die möglicherweise bereits auf dem Zielserver existiert, durch die wiederhergestellte Version ersetzt wird. Um das Überschreiben der vorhandenen Datenbank zu vermeiden, können Sie eine Datenbank an einem neuen Ort wiederherstellen.

SEP Warning.png Achtung
Sie können nur dann eine oder mehrere Datenbanken gleichzeitig wiederherstellen, wenn Sie die MS SQL-Datenbanken an ihrem ursprünglichen Speicherort wiederherstellen. Bei der Wiederherstellung von MS SQL-Datenbanken an einem neuen Speicherort können Sie nur jeweils eine Datenbank wiederherstellen, obwohl die grafische Benutzeroberfläche die Auswahl mehrerer Datenbanken erlaubt. Die Wiederherstellung an einem anderen Ort funktioniert nicht, wenn mehrere Datenbanken ausgewählt sind.

Die Wiederherstellung wird über die Menüleiste -> Aktivitäten -> Rücksicherung ausgelöst. Der Wiederherstellungsassistent führt Sie durch den Prozess der Wiederherstellung Ihrer Daten. Eine Schritt-für-Schritt-Anleitung finden Sie unter Standard Rücksicherungsverfahren.

Information sign.png Anmerkung
SEP sesam bietet die Webschnittstelle Aktivitäten -> Rücksicherungsassistant, die intuitiver gestaltet ist und zusätzliche erweiterte Optionen im Vergleich zum GUI Restore Wizard bietet. Andererseits unterstützt sie noch nicht die Rücksicherung spezieller Aufgabentypen, wie MS SQL, PostgreSQL, Oracle, etc. Für diese Aufgabentypen können Sie nur den GUI-Wiederherstellungsassistenten verwenden, um Ihre Daten wiederherzustellen.

Wiederherstellung von MS SQL-Datenbanken am ursprünglichen Speicherort

When restoring MS SQL database to the original target path (the same as from where it was backed up), you can restore one or more databases at the same time. Note that the existing database files are overwritten when the original target path is used.

Erstellen Sie einen neuen Rücksicherungsauftrag für die MS SQL-Datenbank(en), die Sie wiederherstellen möchten.

  1. Wählen Sie in der Menüleiste der SEP sesam GUI Aktivitäten -> Rücksicherung. Das Fenster Neuer Rücksicherungsauftrag öffnet sich.
  2. Wählen Sie aus, was Sie zurücksichern möchten. Sie können die Savesets nach Auftragsname oder nach Datei- oder Pfadname durchsuchen.
  3. Geben Sie in den Dropdown-Listen Gesichert im Zeitraum den Zeitraum an, für den Sie die Suche durchführen möchten. Klicken Sie auf Weiter.
  4. Die Suchergebnisse werden angezeigt. Klicken Sie in der Liste der Savesets, die Ihrer Anfrage entsprechen, auf die Version, die Sie wiederherstellen möchten. Klicken Sie auf Weiter.
  5. MS SQL restore select task Beefalo V2 de.jpg
  6. In the Select Files dialog, select the data you want to restore and click Next.
  7. Under the Target Settings (previously Save and Start), set additional options.
    • Under the Target path settings, select Restore to original target path (set by default). By selecting this option the data will be restored to the same location from which it was backed up.
    • Under the Execution options drop-down list, select the following options:
      • Select Overwrite existing items. If a database already exists on the target server, the existing database files are overwritten.
      • From the second drop-down list, select Auto recover after restore to store the data directly into the database without caching in the file system; as the data is written directly into the database, it is not possible to modify it.
        If you want to modify the data before you import it into the database, you may select No recover after restore. The restored data is stored on the file system rather than written over an existing database; in this case, you need to import the data into the database manually by using the command line on the server. Note that you can still recover the MS SQL database once the restore is completed by using the following command:
      • sbc -r -a recover -v 3 sbcmsql:<server_name>/<instance>/<DB_name>

    MS SQL restore target Beefalo V2 de.jpg

  8. In the final step of the restore wizard, you can review all the settings of your restore task. You can also edit the settings by using Change Selection button. If you want to start your restore immediately, click Start. If you want to save the restore task, click Save.
Information sign.png Anmerkung
A restore task can be scheduled like any other task. If you want to add a restore task to the schedule, see Scheduling Restore.

You can view the status of your restore jobs by selecting Job State -> Restores from the Main Selection. Restore overview provides detailed information on the last run of restore jobs, including the task name, status (successful, error, in queue ...), start and stop time of the last backup, data size, throughput, client and message.

As of 4.4.3 Beefalo V2, you can also monitor the restore progress using the Web UI. For details, see SEP sesam Web UI.

Rücksicherung einer Datenbank an einem neuen Ort mit Hilfe der GUI-Option "Relocate" oder "Verschieben"

Wenn Sie eine MS SQL Datenbank auf den gleichen Rechner zurücksichern wollen, aber unter einem anderen Datenbanknamen und an einem anderen Ort, ohne die ursprüngliche Datenbank zu beeinträchtigen, können Sie je nach SEP sesam Version eine der beiden folgenden Optionen verwenden:

> GUI relocation (≥ 4.4.3.45 Tigon V2)

> Verschiebe Option (≤ 4.4.3.42 Tigon)

Information sign.png Anmerkung
Bei der Rücksicherung von MS SQL-Datenbanken an einem neuen Speicherort können Sie nur eine Datenbank auf einmal zurücksichern, obwohl die GUI die Auswahl mehrerer Datenbanken erlaubt. Die Rücksicherung einer Datenbank in einem neuen Zielpfad funktioniert nicht, wenn mehrere Datenbanken ausgewählt sind!

Mit dem GUI-Rücksicherungs-Assistenten relocation (≥ 4.4.3.45 Tigon V2)

Ab 4.4.3.45 Tigon V2, können Sie den Rücksicherungs-Assistenten verwenden, um den logischen Dateinamen der MS SQL-Datenbank auszuwählen und den relozierten physischen Dateinamen zu konfigurieren.

  1. Wählen Sie in der Menüleiste der SEP sesam GUI Aktivitäten -> Rücksicherung. Das Fenster Neuer Rücksicherungsauftrag öffnet sich.
  2. Wählen Sie die Datenbank aus, die Sie zurücksichern möchten, und wählen Sie dann die gewünschte Version.
  3. Im Dialogfeld Zieleinstellungen (früher Speichern und Starten) lassen Sie die Optionen so, wie sie standardmäßig eingestellt sind, und wählen nur Neues Rücksicherungsziel unter den Zielpfadeinstellungen. Klicken Sie dann auf die Schaltfläche Expertenoptionen.
  4. Information sign.png Anmerkung
    Experte UI Modus]] verfügbar. Sie ist nicht verfügbar für Benutzer, die die GUI im Basis oder Fortgeschritten Modus betreiben. Im letzteren Fall müssen Sie, wenn Sie auf die Expertenoptionen zugreifen wollen, zuerst den Basis/Fortgeschritten UI-Modus auf Experte ändern, wie in UI-Modus auswählen beschrieben.
  5. Im neuen Fenster Rücksicherung: Expertenoptionen wechseln Sie zur Registerkarte Relokation und wählen die Option Mit Relokation.
    In the field Will be restored directly in the following target path, the original path of the physical file is listed.
    If the original database is still running or it must not be overwritten, you have to modify the physical path by clicking New and specifying a new path for each logical name.
  6. Information sign.png Anmerkung
    If the original database does not run and the relocation is not configured, the files will be overwritten even if you have previously specified a new database name.

    MS SQL restore relocation Beefalo V2 de.jpg
    Click OK to set a new path for the database, and then click Next.

  7. To start your database restore immediately, click Start. Otherwise, save your restore task.
SEP Warning.png Achtung

Pay special attention if you are using SEP sesam version 4.4.3.48 Tigon V2 on SEP sesam Clients with MS SQL Server. Note that MS SQL Server restore may overwrite the original database if your MS SQL Server version, such as MS SQL Server 2016, allows to overwrite an online database. A patch is available to fix this problem; see Release Notes 4.4.3 Tigon V2 for details.

By using the move option (≤ 4.4.3.42 Tigon)

For versions ≤ 4.4.3.42 Tigon, the move option must be used to relocate each of the database files and avoid collision with existing files.

If the database was created with a different logical file name, you can restore it by using the move to clause (command) or by changing the database name in the SQL Server Management Studio. When restoring by using the move option, the logical file names of the target database are adjusted.

Prerequisites

  • Before restoring a database to a new location, make sure that the database is offline. If a database is in use, e.g., when Open Table in the SQL Server Management Studio is used, the restore fails.
  • When using the move option, make sure that the specified target directory name already exists. Pay attention not to overwrite the database files by mistake!

Use the move option as follows:

-a move={<original_logical_name>}:"<new_file_name_mdf>" -a move={<original_logical_name_ldf>}:"<new_file_name_ldf>"

Example

osql -E -S MIRACULIX\SECOND -Q "select name,physical_name,state_desc from sys.database_files" -d sesam2 
name        physical_name           state_desc
-----------------------------------------------------------------------------------------------------------------------
sesam_db2       D:\Programme\Microsoft SQL Server\MSSQL.3\MSSQL\DATA2\sesam_db2.mdf       ONLINE
sesam_db2_log   D:\Programme\Microsoft SQL Server\MSSQL.3\MSSQL\DATA2\sesam_db2_log.ldf   ONLINE
SEP Tip.png Hinweis
You can use the restore wizard and enter the move option ''-a move=.:.'' as text (without changing lines) by using Expert Options -> tab Option -> Restore options field.
Information sign.png Anmerkung
If the SEP sesam Server is working with a PostgreSQL database, e.g., on Linux x64, you have to enter the \- character twice, if not entered twice it disappears.

Example 1: Restoring the backup of the database sesam_db to sesam2 by using move.

sbc -r -s @sesam_db.save -o over -a recover 
-a move=sesam_db:"D:\Programme\Microsoft SQL Server\MSSQL.3\MSSQL\DATA2\sesam_db2.mdf" 
-a move=sesam_db_log:"D:\Programme\Microsoft SQL Server\MSSQL.3\MSSQL\DATA2\sesam2_db2_log.ldf" 
sbcmsql:"/MIRACULIX/SECOND/sesam2"

Example 2: After the restore the adjusted logical file names will appear as follows:

osql -E -S MIRACULIX\SECOND -Q "select name,physical_name,state_desc from sys.database_files" -d sesam2 
name        physical_name           state_desc
-----------------------------------------------------------------------------------------------------------------------
sesam_db       D:\Programme\Microsoft SQL Server\MSSQL.3\MSSQL\DATA2\sesam_db2.mdf       ONLINE
sesam_db_log   D:\Programme\Microsoft SQL Server\MSSQL.3\MSSQL\DATA2\sesam_db2_log.ldf   ONLINE

Once the restore is completed, you should check the status of your restore jobs by selecting Job state -> Restores from the Main selection, or check the Error Log under Logging to make sure that the restore has completed successfully.

Restoring a database to a new location by changing the database name

If the database was created with a different logical file name, it is possible to restore it by using either the move to clause (command), as described in the section above, or by changing the database name in the SQL Server Management Studio, as described below.
In our example, the original database name is OriginalDB and the restore database name is RestoreDB.

  1. Back up the OriginalDB and make sure that the backup is successful.
  2. Open the SQL Server Management Studio and create a restore database named RestoreDB. In the create dialog, select a different database location.
  3. Rename the default database logical names (RestoreDB and RestoreDB_log) to original database logical names which should be restored (in our example, OriginalDB and OriginalDB_log).
  4. Rename the default database file names (RestoreDB.mdf and RestoreDB_log.ldf) to the original database file names which should be restored (in our example, OriginalDB.mdf and OriginalDB_log.ldf).
  5. After you have created the RestoreDB, set the database offline.
  6. Open SEP sesam restore wizard and select the OriginalDB database for the restore.
  7. In the Target Settings dialog (previously Save and Start), select the New restore target option and enter the new target path, e.g., W2K8R2SQL/MSSQLSERVER/RestoreDB. Under the Execution options, select options Overwrite existing items and Auto recover after restore.
  8. Start the restore.
  9. Once the restore is completed successfully, set the RestoreDB database online.

Disaster recovery

In some cases you have to perform a disaster recovery, e.g., if MS SQL Server is installed but the MS SQL Server service is no longer running. This can be caused due to different reasons, e.g., because all database files including the system databases are corrupted.

Note that the following section describes two possible solutions to perform the MS SQL disaster recovery. To learn more about preparation for MS SQL disaster recovery and get step-by-step instructions to rebuild databases, refer to official MS SQL documentation.

1st scenario: MS SQL backups and the database files are available

In addition to MS SQL backups, the database files (including system databases) are available in a VSS path backup.

  1. Stop MS SQL Server service.
  2. Only the files (.mdf and .ldf) of the system databases are restored from the last path backup to the original path with overwrite.
  3. Restart MS SQL Server service.
  4. You can now restore single DBs from the last MS SQL backup.

2nd scenario: Only MS SQL backups are available

Only MS SQL backups exist, but there are no database files in a path backup.

  1. Create a new MS SQL instance with the MS SQL setup files. Note that the setup files must be the same as the ones the MS SQL Server was originally installed with.
  2. You can now restore single DBs to the newly created instance.

Restoring MS SQL databases from the command line

You have to be a system administrator to be able to perform CLI restore. You can restore to the original location, to the identical location or to a new location (instance).

Restoring to the original location

In the following example, the database is restored to the original location with the options overwrite and recover:

sbc -r -s @sesam_db.save -o over -a recover -v 3 sbcmsql:<server_name>/<instance>/<DB_name>

If the database is online during the restore, no changes will be shown. In case that no changes are shown, set the database offline and online again to be able to check the restore status.

Restoring to the identical location

If you are performing a restore to the identical location as the original database location and with the identical logical file names, proceed as follows:

sbc -r -s @sesam_db.save -o over -a recover -v 3 sbcmsql:"/<server_name>/<instance>/<DB_name>"

In our example:

sbc -r -s @sesam_db.save -o over -a recover -v 3 sbcmsql:"/MIRACULIX/SECOND/sesam_db"

You have to check the location and logical file names by using SQL Server Management Studio or by specifying the following command, where the name means logical file name:

osql -E -S MIRACULIX\SECOND -Q "select name,physical_name,state_desc from sys.database_files" 
-d sesam_db 
name        physical_name           state_desc
---------------------------------------------------------------------------------------------------- 
-------------------
sesam_db       D:\Programme\Microsoft SQL Server\MSSQL.3\MSSQL\DATA2\sesam_db.mdf       ONLINE
sesam_db_log   D:\Programme\Microsoft SQL Server\MSSQL.3\MSSQL\DATA2\sesam_db_log.ldf   ONLINE

For MS SQL Server 2000 you have to use the following command to check the location and logical file names, for example:

osql -E -S COSINUS\ZWEITE_DB -Q "select * from sysfiles" -d sesamdb

You can retrieve all logical file names by using the command:

osql -E -S w2003enterprise -Q "select name, filename from sysdatabases" -d master

Siehe auch

MS SQL Sicherung