Problem restore DBS SQL - Restore-DbaDatabase

Thor El Poderoso 51 Reputation points
2022-02-17T18:31:34.123+00:00

I have a script to restore DBs in SQL 2016. A provider leaves me the backup in an SFTP, I download it and try to restore it.

The source and destination DB have different names and this is my command line:

Restore-DbaDatabase -SqlInstance SERVER\instance -DatabaseName DBDest -Path c:\tmp\DIRBACKUP\backup.bak -WithReplace

I have the following message, but it does not restore the backup

WARNING: [Read-DbaBackupHeader]Problem found with c:\tmp\DIRBACKUP\backup.bak. | You cannot call a method on a null-valued expression.
WARNING: [Restore-DbaDatabase] No backups passed through. This could mean the SQL instance cannot see the referenced files, the file's headers could not be read or some other issue

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,710 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,127 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,363 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CathyJi-MSFT 21,091 Reputation points Microsoft Vendor
    2022-02-18T03:19:54.737+00:00

    Hi @Thor El Poderoso ,

    It seems you have some mistake in your powershell command. Please follow steps from MS document Restore-SqlDatabase or the third part blog Use PowerShell Script to Restore SQL database from backup to restore database back up. Please run the powershell using admin account and make sure your account has the read and write permission to backup folder.

    Below is a sample scripts;

    Restore-SqlDatabase -ServerInstance “node1\SQL2019” -Database “test”  
    -BackupFile " C:\Program Files\Microsoft SQL Server\MSSQL15.SQL2019\MSSQL\Backup\test.bak" –ReplaceDatabase  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments