Backup A Database On A Hdd With A Different Sector Size
Solution 1:
All you have to do is back it up with a different name.
Solution 2:
This issue is caused by different sector sizes used by different drives.
You can fix this issue by changing your original backup command to:
BACKUP DATABASE MyDB TODISK= N'D:\MyDB.bak' WITH INIT , NOUNLOAD , NAME = N'MyDB backup', STATS = 10, FORMAT
Note that I've changed NOFORMAT to FORMAT and removed NOSKIP.
Found a hint to resolving this issue in the comment section of the following blog post on MSDN: SQL Server–Storage Spaces/VHDx and 4K Sector Size
And more information regarding 4k sector drives: http://blogs.msdn.com/b/psssql/archive/2011/01/13/sql-server-new-drives-use-4k-sector-size.aspx
Solution 3:
Just remove the existing .bak file and re-run.
Solution 4:
I ran into the same issue as the OP. On a dev machine, we had a PowerShell script that backed up databases from remote database servers and stored the backup files locally. The script overwrote the same backup files, over and over, and the script had been working fine for a couple years. Then I cloned the spinning media drive to an SSD in the dev machine. Suddenly, we were getting the same error as the OP:
Backup-SqlDatabase : System.Data.SqlClient.SqlError: Cannot use the backup file '\DevMachine\Back-Up\Demo.bak' because it was originally formatted with sector size 4096 and is now on a device with sector size 512.
Sure, I could delete all of the existing .bak files to fix the problem. But what if it happens, again? I wanted a command line solution that consistently worked.
Here's our original code:
Backup-SqlDatabase -ServerInstance "DBServer1" -Database "Demo" -BackupFile "\\DevMachine\Back-Up\Demo.bak" -BackupAction Database -CopyOnly -CompressionOption On -ConnectionTimeout 0 -Initialize -Checksum -ErrorAction StopAfter some fiddling around, I changed it to the following to fix the problem:
Backup-SqlDatabase -ServerInstance "DBServer1" -Database "Demo" -BackupFile "\\DevMachine\Back-Up\Demo.bak" -BackupAction Database -CopyOnly -CompressionOption On -ConnectionTimeout 0 -Initialize -Checksum -FormatMedia -SkipTapeHeader -ErrorAction StopBasically, the following options were added to fix the issue:
-FormatMedia -SkipTapeHeaderNote that if you read the documentation for the Backup-SqlDatabase cmdlet, -FormatMedia is listed as only applying to tapes and not to disk backups. However, it appears to do the job of blowing away the existing backup file when backing up to disk.
- https://docs.microsoft.com/en-us/powershell/module/sqlps/backup-sqldatabase
I found that if I used the -FormatMedia option by itself, it generated the following error:
Backup-SqlDatabase : The FormatMedia and SkipTapeHeader properties have conflicting settings.
I fixed the second error by adding an additional option: -SkipTapeHeader. Clearly that's also intended for tape backups, but it worked.
Solution 5:
We had the same problem going from 2005 to 2008. The problem was that we were trying to use the same backup file in 2008 that we used in 2005 (appending backups together into 1 file).
We changed the script to backed up to a different file and the problem was resolved. I would imagine that moving/deleting the old file would have the same affect
Post a Comment for "Backup A Database On A Hdd With A Different Sector Size"