0

I want to simulate bad backup file with ultreadit, but I don't know how as I know nothing about ultreadit. Please help me with that.

I simply want to make the SSMS fail to read the pages of a bad file.

1

You don't need UltrEdit to destroy a backup file.
Actually, this really powerful text editor will allow you to nose around inside a backup file and even save it without rendering the file completely unusable ...

Not that you should, obviously.

Good old Notepad is far more capable of causing this sort of damage.

Just open [a copy of] a Backup file and save it again. Mischief Managed.

Notepad's lack of acknowledgement of Operating Systems other than Windows - and the line endings that they use - will cause it to rewrite the file with extra characters that make its contents complete nonsense to Sql Server.

1

No need to use an editor to corrupt a backup file. You can use a PowerShell script like the example below to write binary zeros at the beginning of the file to corrupt file header.

$backupFile = New-Object System.IO.FileStream("E:\Backups\AdventureWorks.bak", [System.IO.FileMode]::Open, [System.IO.FileAccess]::Write)
$garbage = New-Object System.Byte[] 100
$backupFile.Write($garbage, 0, $garbage.Length)
$backupFile.Close()

Similarly, you can write garbage at a greater offset into the file using Seek corrupt data/structures, to cause other errors:

$backupFile = New-Object System.IO.FileStream("E:\Backups\AdventureWorks.bak", [System.IO.FileMode]::Open, [System.IO.FileAccess]::Write)
$backupFile.Seek(1024000, [System.IO.SeekOrigin]::Begin)
$garbage = New-Object System.Byte[] 100
$backupFile.Write($garbage, 0, $garbage.Length)
$backupFile.Close()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.