Backup SQL objects using mssql-scripter

Viewed 30

I'm making backup sql objects by mssql-scripter and it works like a charm if it comes to my local server (here I don't have to provide any user, just pointing server and db). The problem is I have to backup sql objects from client's database wchich has Azure Active Directory authentication method. I'm providing server, database and my credentials (mail as user)

mssql-scripter -S server -d database -U user -P password -f destination --file-per-object

But I'm getting error:

Failed to connect to server 'server_name'. ---> System.Data.SqlClient.SqlException: Cannot open server "my_mail_domain" requested by the login.  The login failed.

Where im mistaking? I've read info to backup sql object using mssql-scripter, authentication has to be set as 'Windows Authentication'. Is this true or I can backup providing Azure credentials?

1 Answers

This has been documented as an issue already.

This is only supported with a custom connection-string parameter

mssql-scripter
  --connection-string "Server=server;Database=database;User Id=user;Password=password;Authentication=Active Directory Password" `
  -f destination `
  --file-per-object

Assuming you actually meant that you have a on-premises SQL Server, but the domain is Azure AD, then you just need to use Integrated Security ie normal Windows Authentication.

mssql-scripter
  --connection-string "Server=server;Database=database;Integrated Security=true" `
  -f destination `
  --file-per-object

Note that usernames and passwords are not used here, the currently logged in user is used.

Related