waldo1001 / Cloud.Ready.Software.PowerShell

waldo's PowerShell Scripts & Modules
http://www.waldo.be
84 stars 94 forks source link

Backup-SQLDatabaseToFile Error Cannot find drive... #51

Open GreatScott000 opened 6 years ago

GreatScott000 commented 6 years ago

This command Backup-SQLDatabaseToFile -DatabaseServer NAVDEV1 -DatabaseName "Demo Database NAV (11-0-21836 GB)" Gives me the following error. Is there an assumption that I am issuing the command from a session on the SQL server machine? "G" (referenced below) is the drive where the SQL backups are put by default.

Join-Path : Cannot find drive. A drive with the name 'G' does not exist. At C:\Program Files\WindowsPowerShell\Modules\Cloud.Ready.Software.SQL\1.0.1.7\Backup-SQLDatabaseToFile.ps1:51 char:27

  • $BackupFileFullPath = Join-Path $Backuplocation $BackupFile
  • 
    + CategoryInfo          : ObjectNotFound: (G:String) [Join-Path], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

Backing up database ... BACKUP DATABASE [Demo Database NAV (11-0-21836 GB)] TO DISK = N'' WITH COPY_ONLY, NOFORMAT, INIT, NAME = N'NAVAPP_QA_MT-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 Invoke-Sqlcmd : Invalid zero-length device name. Reissue the BACKUP statement with a valid device name. BACKUP DATABASE is terminating abnormally. At C:\Program Files\WindowsPowerShell\Modules\Cloud.Ready.Software.SQL\1.0.1.7\Backup-SQLDatabaseToFile.ps1:57 char:5

  • Invoke-Sqlcmd -Query $SQLString -ServerInstance "$DatabaseServer\ ...
  • 
    + CategoryInfo          : InvalidOperation: (:) [Invoke-Sqlcmd], SqlPowerShellSqlExecutionException
    + FullyQualifiedErrorId : SqlError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand

Get-Item : Cannot bind argument to parameter 'Path' because it is null. At C:\Program Files\WindowsPowerShell\Modules\Cloud.Ready.Software.SQL\1.0.1.7\Backup-SQLDatabaseToFile.ps1:59 char:14

  • Get-Item $BackupFileFullPath
  • 
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
waldo1001 commented 6 years ago

is the G-drive known on the SQL machine - since that machine will be executing the backup-procedure?

GreatScott000 commented 6 years ago

Yes the G-drive is a physical drive on the SQL server

waldo1001 commented 6 years ago

Hm - no clue - I must admit, I haven't been using this for quite a while (since docker). And I don't have a system where I can test this. May be it's better to use a drive that's available on both machines?

GreatScott000 commented 6 years ago

If I just give a filename with no path it seems to be happy. That will do for what I need. Thanks.