Link to home
Start Free TrialLog in
Avatar of Zack
ZackFlag for Australia

asked on

DB Restore Suspended when loading from Powershell.

Hi EE,

I am running a backup in PowerShell:

# Backup existing SQL databases
		Write-Host ""
		Write-Host -ForegroundColor Cyan "$(Get-Date) - Backing up $($DbName[0]) databases. Please wait..."
		Try {
			$DbName | Foreach-Object {
				Backup-SqlDatabase -BackupAction Database -BackupSetDescription "Data refresh from Prod" -CopyOnly -Database $_ -Path $SqlPsPath -BackupFile ($BackupPath + $_ + "_" + (Get-Date -UFormat %Y%m%d-%H%M%S) + ".bak")
				Write-Host -ForegroundColor Green "$(Get-Date) - $_ database backup completed."
			}
		}

Open in new window


It's parsing in the databases just fine, but the process keeps showing up as SUSPENDED in the SQL Server and stays like that never resuming I have waited for 17 minutes no go.

The server it's has very little activity on it as it is a UAT environment.

Any ideas as what could be causing this or commands to drill into the cause of the suspension any assistance is welcome.

Attached is metadata from sysprocesses.

Additional ran the following query get some insight:
SELECT r.wait_type
	   command,
            s.text,
            start_time,
            percent_complete,
            CAST(((DATEDIFF(s,start_time,GetDate()))/3600) as varchar) + ' hour(s), '
                  + CAST((DATEDIFF(s,start_time,GetDate())%3600)/60 as varchar) + 'min, '
                  + CAST((DATEDIFF(s,start_time,GetDate())%60) as varchar) + ' sec' as running_time,
            CAST((estimated_completion_time/3600000) as varchar) + ' hour(s), '
                  + CAST((estimated_completion_time %3600000)/60000 as varchar) + 'min, '
                  + CAST((estimated_completion_time %60000)/1000 as varchar) + ' sec' as est_time_to_go,
            dateadd(second,estimated_completion_time/1000, getdate()) as est_completion_time
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) s
WHERE r.command like '%Backup%'

Open in new window


Results of the query attached as well nothing seems wrong to me.

Thank you.
SPID-Details-1.csv
SQL-Diagnostic-Query.csv
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zack

ASKER

Hi Icohan,

Got it after a close inspection of the results of this query:

SELECT r.wait_type
	   command,
            s.text,
            start_time,
            percent_complete,
            CAST(((DATEDIFF(s,start_time,GetDate()))/3600) as varchar) + ' hour(s), '
                  + CAST((DATEDIFF(s,start_time,GetDate())%3600)/60 as varchar) + 'min, '
                  + CAST((DATEDIFF(s,start_time,GetDate())%60) as varchar) + ' sec' as running_time,
            CAST((estimated_completion_time/3600000) as varchar) + ' hour(s), '
                  + CAST((estimated_completion_time %3600000)/60000 as varchar) + 'min, '
                  + CAST((estimated_completion_time %60000)/1000 as varchar) + ' sec' as est_time_to_go,
            dateadd(second,estimated_completion_time/1000, getdate()) as est_completion_time
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) s
WHERE r.command like '%Backup%'

Open in new window


I realized their was '/' missing the backup path when I corrected the PowerShell script problem resolved.

Thank you.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial