Using Backup-SqlDatabase with Powershell to Remote machine









up vote
0
down vote

favorite












I want to backup SQL Server using Powershell Backup-SqlDatabase command,
The problem is that I want to do it from a remote machine, and Backup-SqlDatabase has not IP address parameter.



Is there any way to use this command, or any other command to back up remotely the database.



I tried the following script:



$secpasswd = ConvertTo-SecureString "myPass" -AsPlainText -Force;
$mycreds = New-Object System.Management.Automation.PSCredential ("sa", $secpasswd);
Backup-SqlDatabase -ServerInstance "192.168.65.149/sqlserver" -Database "ARM" -Credential $mycreds


where sqlserver is the instance of the Database, and 192.168.65.149 is the IP of the server



I got the following error:



Backup-SqlDatabase : Failed to connect to server 192.168.65.149/sqlserver.
At line:1 char:1
+ Backup-SqlDatabase -ServerInstance "192.168.65.149/sqlserver" -Databa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Backup-SqlDatabase], ConnectionFailureException
+ FullyQualifiedErrorId : Microsoft.SqlServer.Management.Common.ConnectionFailureException,Microsoft.SqlServer.Management.PowerShell.BackupSqlDatabaseCommand


Thanks










share|improve this question



















  • 1




    Yes it does? It's the -ServerInstance switch. Backup-SqlDatabase
    – Larnu
    Nov 11 at 15:10











  • @Larnu -ServerInstance is not accepting the ip info, its getting the database server name, for example SQL-01INSTANCE
    – daniel the man
    Nov 11 at 15:43










  • 10.0.0.1/SqlExpress and srvSql/SqlExpress are synonyms, if the IP representative of the server. Post the script your tried.
    – Larnu
    Nov 11 at 15:49










  • Can you see the connection attempt on the SQL servers's logs? I suspect you'll see something there. I'd also recommend against using the sa account for this. You should be using a user/login with adaquet permissions; preferably an AD account. Have you tried using the format in example 4 to see if the prompt for the password works? (Backup-SqlDatabase -ServerInstance "ComputerInstance" -Database "MainDB" -Credential (Get-Credential "sa"))
    – Larnu
    Nov 11 at 16:00










  • Have you enabled the remote connection in SQL Express? They are disabled by default. support.webecs.com/kb/a868/…
    – reverpie
    Nov 12 at 9:12















up vote
0
down vote

favorite












I want to backup SQL Server using Powershell Backup-SqlDatabase command,
The problem is that I want to do it from a remote machine, and Backup-SqlDatabase has not IP address parameter.



Is there any way to use this command, or any other command to back up remotely the database.



I tried the following script:



$secpasswd = ConvertTo-SecureString "myPass" -AsPlainText -Force;
$mycreds = New-Object System.Management.Automation.PSCredential ("sa", $secpasswd);
Backup-SqlDatabase -ServerInstance "192.168.65.149/sqlserver" -Database "ARM" -Credential $mycreds


where sqlserver is the instance of the Database, and 192.168.65.149 is the IP of the server



I got the following error:



Backup-SqlDatabase : Failed to connect to server 192.168.65.149/sqlserver.
At line:1 char:1
+ Backup-SqlDatabase -ServerInstance "192.168.65.149/sqlserver" -Databa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Backup-SqlDatabase], ConnectionFailureException
+ FullyQualifiedErrorId : Microsoft.SqlServer.Management.Common.ConnectionFailureException,Microsoft.SqlServer.Management.PowerShell.BackupSqlDatabaseCommand


Thanks










share|improve this question



















  • 1




    Yes it does? It's the -ServerInstance switch. Backup-SqlDatabase
    – Larnu
    Nov 11 at 15:10











  • @Larnu -ServerInstance is not accepting the ip info, its getting the database server name, for example SQL-01INSTANCE
    – daniel the man
    Nov 11 at 15:43










  • 10.0.0.1/SqlExpress and srvSql/SqlExpress are synonyms, if the IP representative of the server. Post the script your tried.
    – Larnu
    Nov 11 at 15:49










  • Can you see the connection attempt on the SQL servers's logs? I suspect you'll see something there. I'd also recommend against using the sa account for this. You should be using a user/login with adaquet permissions; preferably an AD account. Have you tried using the format in example 4 to see if the prompt for the password works? (Backup-SqlDatabase -ServerInstance "ComputerInstance" -Database "MainDB" -Credential (Get-Credential "sa"))
    – Larnu
    Nov 11 at 16:00










  • Have you enabled the remote connection in SQL Express? They are disabled by default. support.webecs.com/kb/a868/…
    – reverpie
    Nov 12 at 9:12













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I want to backup SQL Server using Powershell Backup-SqlDatabase command,
The problem is that I want to do it from a remote machine, and Backup-SqlDatabase has not IP address parameter.



Is there any way to use this command, or any other command to back up remotely the database.



I tried the following script:



$secpasswd = ConvertTo-SecureString "myPass" -AsPlainText -Force;
$mycreds = New-Object System.Management.Automation.PSCredential ("sa", $secpasswd);
Backup-SqlDatabase -ServerInstance "192.168.65.149/sqlserver" -Database "ARM" -Credential $mycreds


where sqlserver is the instance of the Database, and 192.168.65.149 is the IP of the server



I got the following error:



Backup-SqlDatabase : Failed to connect to server 192.168.65.149/sqlserver.
At line:1 char:1
+ Backup-SqlDatabase -ServerInstance "192.168.65.149/sqlserver" -Databa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Backup-SqlDatabase], ConnectionFailureException
+ FullyQualifiedErrorId : Microsoft.SqlServer.Management.Common.ConnectionFailureException,Microsoft.SqlServer.Management.PowerShell.BackupSqlDatabaseCommand


Thanks










share|improve this question















I want to backup SQL Server using Powershell Backup-SqlDatabase command,
The problem is that I want to do it from a remote machine, and Backup-SqlDatabase has not IP address parameter.



Is there any way to use this command, or any other command to back up remotely the database.



I tried the following script:



$secpasswd = ConvertTo-SecureString "myPass" -AsPlainText -Force;
$mycreds = New-Object System.Management.Automation.PSCredential ("sa", $secpasswd);
Backup-SqlDatabase -ServerInstance "192.168.65.149/sqlserver" -Database "ARM" -Credential $mycreds


where sqlserver is the instance of the Database, and 192.168.65.149 is the IP of the server



I got the following error:



Backup-SqlDatabase : Failed to connect to server 192.168.65.149/sqlserver.
At line:1 char:1
+ Backup-SqlDatabase -ServerInstance "192.168.65.149/sqlserver" -Databa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Backup-SqlDatabase], ConnectionFailureException
+ FullyQualifiedErrorId : Microsoft.SqlServer.Management.Common.ConnectionFailureException,Microsoft.SqlServer.Management.PowerShell.BackupSqlDatabaseCommand


Thanks







sql-server powershell database-backups






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 16:03

























asked Nov 11 at 15:03









daniel the man

53031029




53031029







  • 1




    Yes it does? It's the -ServerInstance switch. Backup-SqlDatabase
    – Larnu
    Nov 11 at 15:10











  • @Larnu -ServerInstance is not accepting the ip info, its getting the database server name, for example SQL-01INSTANCE
    – daniel the man
    Nov 11 at 15:43










  • 10.0.0.1/SqlExpress and srvSql/SqlExpress are synonyms, if the IP representative of the server. Post the script your tried.
    – Larnu
    Nov 11 at 15:49










  • Can you see the connection attempt on the SQL servers's logs? I suspect you'll see something there. I'd also recommend against using the sa account for this. You should be using a user/login with adaquet permissions; preferably an AD account. Have you tried using the format in example 4 to see if the prompt for the password works? (Backup-SqlDatabase -ServerInstance "ComputerInstance" -Database "MainDB" -Credential (Get-Credential "sa"))
    – Larnu
    Nov 11 at 16:00










  • Have you enabled the remote connection in SQL Express? They are disabled by default. support.webecs.com/kb/a868/…
    – reverpie
    Nov 12 at 9:12













  • 1




    Yes it does? It's the -ServerInstance switch. Backup-SqlDatabase
    – Larnu
    Nov 11 at 15:10











  • @Larnu -ServerInstance is not accepting the ip info, its getting the database server name, for example SQL-01INSTANCE
    – daniel the man
    Nov 11 at 15:43










  • 10.0.0.1/SqlExpress and srvSql/SqlExpress are synonyms, if the IP representative of the server. Post the script your tried.
    – Larnu
    Nov 11 at 15:49










  • Can you see the connection attempt on the SQL servers's logs? I suspect you'll see something there. I'd also recommend against using the sa account for this. You should be using a user/login with adaquet permissions; preferably an AD account. Have you tried using the format in example 4 to see if the prompt for the password works? (Backup-SqlDatabase -ServerInstance "ComputerInstance" -Database "MainDB" -Credential (Get-Credential "sa"))
    – Larnu
    Nov 11 at 16:00










  • Have you enabled the remote connection in SQL Express? They are disabled by default. support.webecs.com/kb/a868/…
    – reverpie
    Nov 12 at 9:12








1




1




Yes it does? It's the -ServerInstance switch. Backup-SqlDatabase
– Larnu
Nov 11 at 15:10





Yes it does? It's the -ServerInstance switch. Backup-SqlDatabase
– Larnu
Nov 11 at 15:10













@Larnu -ServerInstance is not accepting the ip info, its getting the database server name, for example SQL-01INSTANCE
– daniel the man
Nov 11 at 15:43




@Larnu -ServerInstance is not accepting the ip info, its getting the database server name, for example SQL-01INSTANCE
– daniel the man
Nov 11 at 15:43












10.0.0.1/SqlExpress and srvSql/SqlExpress are synonyms, if the IP representative of the server. Post the script your tried.
– Larnu
Nov 11 at 15:49




10.0.0.1/SqlExpress and srvSql/SqlExpress are synonyms, if the IP representative of the server. Post the script your tried.
– Larnu
Nov 11 at 15:49












Can you see the connection attempt on the SQL servers's logs? I suspect you'll see something there. I'd also recommend against using the sa account for this. You should be using a user/login with adaquet permissions; preferably an AD account. Have you tried using the format in example 4 to see if the prompt for the password works? (Backup-SqlDatabase -ServerInstance "ComputerInstance" -Database "MainDB" -Credential (Get-Credential "sa"))
– Larnu
Nov 11 at 16:00




Can you see the connection attempt on the SQL servers's logs? I suspect you'll see something there. I'd also recommend against using the sa account for this. You should be using a user/login with adaquet permissions; preferably an AD account. Have you tried using the format in example 4 to see if the prompt for the password works? (Backup-SqlDatabase -ServerInstance "ComputerInstance" -Database "MainDB" -Credential (Get-Credential "sa"))
– Larnu
Nov 11 at 16:00












Have you enabled the remote connection in SQL Express? They are disabled by default. support.webecs.com/kb/a868/…
– reverpie
Nov 12 at 9:12





Have you enabled the remote connection in SQL Express? They are disabled by default. support.webecs.com/kb/a868/…
– reverpie
Nov 12 at 9:12


















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53250012%2fusing-backup-sqldatabase-with-powershell-to-remote-machine%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53250012%2fusing-backup-sqldatabase-with-powershell-to-remote-machine%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto