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
sql-server powershell database-backups
add a comment |
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
sql-server powershell database-backups
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
andsrvSql/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 thesa
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
add a comment |
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
sql-server powershell database-backups
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
sql-server powershell database-backups
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
andsrvSql/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 thesa
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
add a comment |
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
andsrvSql/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 thesa
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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
andsrvSql/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