Backup SQL Server on a shared folder from Azure DevOps / Command line
0
votes
0
answers
16
views
I need to back up my database using a command line instruction. I launch the backup instruction from a Azure DevOps Release Pipeline to back up my SQL server database on a share folder on another server. Here is my deployment group and task:
What is wrong? Of course I'm in a active directory domain. I can also access AD server if needed.

echo Current user: %username%
whoami
SqlCmd -S myserver1 -U myuser -P mypassword -Q "BACKUP DATABASE [mydatabase] TO DISK='\\Server7\DatabaseBackup\Backup.bak' WITH INIT"
Here is my log of these instructions:
2023-03-09T00:49:26.6349085Z ##[section]Starting: Backup Prod Database
2023-03-09T00:49:26.6973085Z ==============================================================================
2023-03-09T00:49:26.6973085Z Task : Command line
2023-03-09T00:49:26.6973085Z Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2023-03-09T00:49:26.6973085Z Version : 2.212.0
2023-03-09T00:49:26.6973085Z Author : Microsoft Corporation
2023-03-09T00:49:26.6973085Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2023-03-09T00:49:26.6973085Z ==============================================================================
2023-03-09T00:49:27.4461085Z Generating script.
2023-03-09T00:49:27.4773085Z ========================== Starting Command Output ===========================
2023-03-09T00:49:27.4929085Z ##[command]"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "C:\azagent\A1\_work\_temp\013b8436-8475-40dd-9d49-f6166ea509cd.cmd""
2023-03-09T00:49:27.5085085Z Current user: SERVER15$
2023-03-09T00:49:27.5397085Z nt authority\system
2023-03-09T00:49:27.7269085Z Msg 3201, Level 16, State 1, Server SERVER6, Line 1
2023-03-09T00:49:27.7269085Z Cannot open backup device '\\server7\DatabaseBackup\Backup.bak'. Operating system error 5(Access is denied.).
2023-03-09T00:49:27.7269085Z Msg 3013, Level 16, State 1, Server SERVER6, Line 1
2023-03-09T00:49:27.7269085Z BACKUP DATABASE is terminating abnormally.
2023-03-09T00:49:27.7737085Z ##[section]Finishing: Backup Prod Database
It seems the issue us related to the access to share folder. I go on my server7 where I created the shared folder.
Here is my sharing rules:

Asked by Bastien Vandamme
(163 rep)
Mar 9, 2023, 01:05 AM