I am trying to backup a SQL Server 2008 R2 database, name of the database is test.
I am using the following PowerShell script but I get an error message that database does not exist, but I can see the test database and tables and I can query it.
Backup-SqlDatabase -ServerInstance testpc-001\SQLEXPRESS -Database test -BackupAction
Database
and if I try an edit the above script using
$date = Get-Date -Format yyyyMMddHHmmss
$dbname = 'test'
Backup-SqlDatabase -ServerInstance SQLEXPRESS -Database $dbname -BackupFile
"C:\DBbackups\$($dbname)_db_$($dt).bak"
I am getting an error failed to connect to SQLEXPRESS
$date = Get-Date -Format yyyyMMddHHmmss
$dbname = 'test'
Backup-SqlDatabase -ServerInstance testpc-001\SQLEXPRESS -Database $dbname -BackupFile
"C:\DBbackups\$($dbname)_db_$($date).bak"
there was a typo in the -ServerInstance parameter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With