B
B
bnsurg2020-07-13 12:17:18
Database administration
bnsurg, 2020-07-13 12:17:18

How to backup MSSQL to a password protected network folder?

How to backup MSSQL to a password protected network folder? There are backup plans. There is a NAS, there is a folder on it, access to the folder is by login and password.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hint000, 2020-07-13
@hint000

How does SQL tell the username and password to access a folder?
As far as I understand you are trying to do through maintenance plan. And you instead do a cmd-script through the task scheduler. In a cmd script, you can easily register a network drive connection with a password,
net use p: \\192.168.1.100\backup [email protected]$$w0rd /USER:vpupkin
and then the database backup command.
set DATABASENAME=ИмяБазыДанных
set DATESTAMP=%DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%-%time:~0,2%-%time:~3,2%
if "%time:~0,1%" == " " set DATESTAMP=%DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%-0%time:~1,1%-%time:~3,2%
set BACKUPFILENAME=p:\%DATABASENAME%-%DATESTAMP%.bak
set OSQL="C:\Program Files\Microsoft SQL Server\120\Tools\Binn\OSQL.EXE"
%OSQL% -E -Q "BACKUP DATABASE [%DATABASENAME%] TO DISK='%BACKUPFILENAME%' WITH FORMAT"

A
Alexander, 2020-07-13
@NeiroNx

connect as a network drive and run. You can connect the script for the duration of the backup, and then turn it off.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question