3

I have a backup repository on a different domain than the one where I have SQL Server. Is there any way I can define the credentials to access the repository on the backup itself? (domains are isolated from each other)

2
  • Are you getting an error message? To clarify, you are trying to take a backup on a SQL Server running in Domain 1, but the backup destination is in Domain 2? Mar 23, 2022 at 12:13
  • I do get an error, permissions related, and yes domain 1 to domain 2. Point is, I have no clue where to define the domain 2 credentials to be able to access the repository.
    – Lithium
    Mar 23, 2022 at 12:15

1 Answer 1

3

Your best bet is to try and make the file share accessible to the service account that's running SQL Server. This is the easiest and most reliable method. But if you can't do that, this is the only thing I can think of that will work. It assumes you are on windows but it may be even easier if you are on linux.

This link: https://sqlsunday.com/2021/09/02/set-up-access-to-network-shares/ has an excellent guide to how to do this. Essentially, you need to add the Domain2\user credentials to the local windows credential store (which is maintained per user). Then when the service account on SQL tries to access the file share, the credential you've stored will be used.

The tricky part is making sure that the SQL Server Service Account is used when adding the credential to windows, but the article goes into detail on a few ways to do it. My basic steps are:

Step 1: Get the appropriate Domain2 user and password, make sure it has permissions to the target.

Step 2: craft the CMDKEY command:

cmdkey /add:someserver.mycompany.local /user:networkuser /pass:strongPas$w0rdHere

NOTE: I prefer to save this as a batch file temporarily for step 3.

Step 3: make a CMDEXEC job and make it run the batch file above. Delete the job and batch file when done.

Step 4: Run backup job.

Step 5: Success.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.