Restore SQL DB in RDS using SMO?

0

Im trying to create a new Database to use within in my .net web app using an existing one as a template using SMO. The code I have, which works when pointing to my local db instance, is the following:

var server = new Server(serverConnection);
server.ConnectionContext.Connect();

var newDatabase = new Database(server, newDBName);
newDatabase.Create();

var existingDatabase = server.Databases.Cast<Database>().Where(x => x.Name == existingDBName).FirstOrDefault();

Transfer t = new Transfer(existingDatabase);
t.CopyAllTables = true;
t.Options.WithDependencies = true;
t.Options.ContinueScriptingOnError = true;
t.DestinationServer = connection.DataSource;
t.DestinationDatabase = newDBName;
t.DestinationLoginSecure = true;
t.CopySchema = true;
t.CopyData = true;
t.TransferData();

When testing the code locally it works fine. It created a new DB and copied all the schema and data from the existing one. But when testing the code pointing to the RDS template database I'm getting the following error when calling TransferData()

Login Failed. The login is from an untrusted domain and cannot be used with integrated authentication.

I'm assuming is not the connection string in the web.config since the new DB is created successfully in RDS. Its only the copy portion that is not working. Is this something limited by an RDS config/permission that I can set?

Or is there an alternative to SMO that will work for RDS databases?

Any help or guidance will be much appreciated!

----EDIT---- This are the logs I see in the aws console

2020-07-14 13:40:48.74 spid65 Starting up database 'TEST_4fasa3bvpp2vpnjnnuzucqob'.
2020-07-14 13:40:48.92 spid65 Parallel redo is started for database 'TEST_4fasa3bvpp2vpnjnnuzucqob' with worker pool size [1].
2020-07-14 13:40:48.94 spid65 Parallel redo is shutdown for database 'TEST_4fasa3bvpp2vpnjnnuzucqob' with worker pool size [1].
2020-07-14 13:40:49.66 spid65 Starting up database 'TEST_4fasa3bvpp2vpnjnnuzucqob'.
2020-07-14 13:40:49.67 spid65 Parallel redo is started for database 'TEST_4fasa3bvpp2vpnjnnuzucqob' with worker pool size [1].
2020-07-14 13:40:49.69 spid65 Parallel redo is shutdown for database 'TEST_4fasa3bvpp2vpnjnnuzucqob' with worker pool size [1].
2020-07-14 13:41:04.13 Logon Error: 17806, Severity: 20, State: 14.

2020-07-14 13:41:04.13 Logon SSPI handshake failed with error code 0x8009030c, state 14 while establishing a connection with integrated security; the connection has been closed. Reason: AcceptSecurityContext failed. The operating system error code indicates the cause of failure. The logon attempt failed [CLIENT: 34.230.197.53]

2020-07-14 13:41:04.13 Logon Error: 18452, Severity: 14, State: 1.

2020-07-14 13:41:04.13 Logon Login failed. The login is from an untrusted domain and cannot be used with Integrated authentication. [CLIENT: 34.230.197.53]

----------------------- END OF LOG ----------------------
.net
amazon-rds
restore
smo
asked on Stack Overflow Jul 13, 2020 by CGal • edited Jul 14, 2020 by CGal

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0