Skip to content

AO MSSQL Database restore (Azure)

Azure DB copy and restore -> on-prem

Azure: SQL databases: online sub take copy of customers prod db - name it better like: _AttracsCustomer_CopyToTest (delete after restore process is done) - change Backup storage redundancy -> Locally-redundant backup storage - apply

Export "CopyToTest" db select storageaccount -> attracsdbbackups -> containers: customers container

.bacbak will be found in Storage Browser -> Blob Container

MSSQL : connect to database instance Databases -> Import Data-tier Application - Import from Windows Azure - Storage account -> connect -> sing in with your azure account - Select Storage account (attracsdbbackup) + Select Blob container - remember to check, blob container is correct (there might be some lagging) - Select wanted file Name new database, how you want it to be like (Attracs"Customer"_RC_New_date). Old db can be named as "_old" and new db can be named as old was, then test connection with new db

If new db is ok you can delete the old db Database -> * Delete * close existing connections (check box)


Restore new database (copy database)

If you need to copy or restore new database e.g. in on-prem

MSSQL:

Database ➝ Restore database * Device ➝ select .bak file * Select destination ➝ Restore to: give new name to database * Files tab: change "Restore as" .log.ldf and .mdf names, so it won't use existing files and it actually can create new db from "new" files. * apply AO requirements (https://app.clickup.com/2496230/docs/2c5q6-29301/2c5q6-183841)


How-to add new user to db in azure sql:

CREATE USER user_name FOR LOGIN user_name WITH DEFAULT_SCHEMA = dbo;
ALTER ROLE db_owner ADD MEMBER user_name;

References: https://ystatit.medium.com/azure-for-beginners-add-users-to-azure-sql-database-5f5a6748d617