I am trying to create a script that would backup DB on remote SQL server.
This is the SQL backup script:
$sRawString = Get-Content ".\BackupRestore.properties" | Out-String
$timestamp = ((get-date).toString("yyyy_MM_dd_hh_mm"))
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
$connection = New-Object Microsoft.SqlServer.Management.Common.ServerConnection
$server = New-Object Microsoft.SqlServer.Management.Smo.Server $connection
$device = New-Object Microsoft.SqlServer.Management.Smo.BackupDeviceItem ($file, 'File')
$backup.MediaDescription = "Disk"
appreciate the help 🙂
My suspicion is that your problem is hidden somewhere in the properties you're using. Can you share the contents of BackupRestore.properties
I'd also look at stepping through the script one line at a time and checking that variables and properties are what you expect. I suspect something isn't being set correctly
thank you for the quick response 🙂
This is the relevant part of the file
#sql Host Name/IP: the fox DB server host name or IP or FQDN, this address should be accessible from
#sql DB schema name: the fox data base name in SQL instance, the schema that fox application
#sql User Name: the SQL user name is the user name (Windows or SQL) that is used to authenticate
#sql Password: the SQL user password is the password for the user (Windows or SQL) that is used to
I am not sure if you resolved your issue, but may I suggest (if possible) to try using the SQL PowerShell Module. There is a Backup-SqlDatabase cmdlet that would probably simplify your script and eliminate the need for a properties file. Again, I do not know what your requirements are for the backups, but look into it..
You must be logged in to reply to this topic.