SQL script na opravu DB Veeam

Toto je konkrétní script k odstranění duplicitního ID pro Veeam Proxy server, ale jde spíš o syntaxi, že 😉
Nejprve stopnout všechny služby VeeamXY na serveru (po ukončení akce  spustit a rescan proxy)

1. Backup databáze

Spouštěcí dávka (runscript_backup.bat):

@REM How to manually backup a SQL DB (https://www.veeam.com/kb1471)
 
@REM HKLM\Software\VeeaM\Veeam Backup and Replication\SqlServerName 
SET SqlServerName=VEEAMSERVER
@REM HKLM\Software\VeeaM\Veeam Backup and Replication\SqlInstanceName
SET SqlInstanceName=VEEAMSQL2012

SET SCRIPT=script_backup.sql
SET RESULT=backupresult.txt

sqlcmd -S %SqlServerName%\%SqlInstanceName% -i %SCRIPT% -o %RESULT% -I

Sql file (script_backup.sql):

BACKUP DATABASE VeeamBackup TO DISK = 'C:\TEMP\Veeam\VeeamDB_backup.bak'
GO
;

2. Spuštění scriptu

Spouštěcí dávka (runscript.bat):

@REM How to apply a SQL script (https://www.veeam.com/kb1443)

@REM HKLM\Software\VeeaM\Veeam Backup and Replication\SqlServerName 
SET SqlServerName=VEEAMSERVER
@REM HKLM\Software\VeeaM\Veeam Backup and Replication\SqlInstanceName
SET SqlInstanceName=VEEAMSQL2012
@REM HKLM\Software\VeeaM\Veeam Backup and Replication\SqlDatabaseName
SET SqlDatabaseName=VeeamBackup

SET SCRIPT1=script.sql
SET RESULT1=resetresult.txt

sqlcmd -S %SqlServerName%\%SqlInstanceName% -d %SqlDatabaseName% -i %SCRIPT1% -o %RESULT1% -I

Sql file (script.sql):

DECLARE @uniqueID uniqueidentifier
SET @uniqueID = 'E6E8BB2X-080X-4EBX-86AX-0B2685B4487X'

delete from [hosts] where id = @uniqueID delete from [hosts] where parent_id = @uniqueID delete from [folder_host] where host_id = @uniqueID delete from [tombstones] where uid = @uniqueID delete from [BObjects] where host_id = @uniqueID delete from [Backup.Model.Storages] where host_id = @uniqueID delete from [Backup.Model.BackupTaskSessions] where object_id = @uniqueID delete from [Backup.Model.OIBs] where object_id = @uniqueID delete from [ObjectsInJobs] where object_id = @uniqueID delete from [Backup.Model.Backups] where job_id = @uniqueID
;

About Author:

Error! Keyboard not detected. Press any key to continue.