sql server - powershell sqlbackup and copy file -


I am writing a PS script to back up a database and copy .bak to a different server. However, the backup is being done in asynchronous form. And sometimes it reaches every pre-matureest command

I have tried these suggestions but it does not work much.

sqlbackup.Wait () ... It looks like what I'm doing (at least on paper) but it's working Does not seem to be. Before the file can be generated now it reaches my copy command to get any idea how to do this work ... here is what I am doing.

  $ smoBackup = New-item -TypeName Microsoft.SqlServer.Management.Smo.Backup $ smoBackup.Action = "Database" $ smoBackup.BackupSetDescription = + $ dBNAME $ smoBackup.BackupSetName = $ dBNAME + "Backup" $ smoBackup.Database = $ dBNAME $ smoBackup.MediaDescription = "disc" $ smoBackup.Devices.AddDevice ("full backup" $ sourcepath, "file") $ smoBackup.CopyOnly = "true" $ smoBackup.SqlBackup ($ SourceSrv) copy-item-path $ sourcePathUNC -Destination $ destinationPathUNC    

Worked around enough ... just ask it to wait. During {{test-path $ sourcePathUNC} start ({-Sleep-M 500}) / Pre>

In this way, it waits for half a second until it sees the file , And then tries again.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -