I have a problem setting the BackupFile
-attribute on the Backup-SqlDatabase
command (in Powershell for Linux). It expects a Windows path.
What I did:
I've installed PowerShell on a centos Linux. I started Powershell with pwsh
and installed the SqlServer
module. I store my db-credentials in $cred
.
I then run:
PS /> Backup-SqlDatabase -ServerInstance "-----" -Database "MyDatabase" -BackupFile "~/db-backup.bak" -Credential $cred
The output is:
Backup-SqlDatabase: System.Data.SqlClient.SqlError: Cannot open backup device 'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Backup\~\db-backup.bak'. Operating system error 3(The system cannot find the path specified.).
If I omit the BackupFile attribute, it'll actually do a backup - but I have no idea, where it stored the .bak-file (if it even did?)
So, how can I make the BackupFile
-attribute accept a Linux path?