티스토리 뷰
[SQL Server] MSSQL CLI Backup
Linux backup sh 파일 설정
dateTimeString=$(date '+%Y-%m-%d_%H%M%S')
backupPath=/data/mssql/backup
if ! [ -d $backupPath ]
then
mkdir -p "${backupPath}"
fi
dbName=
dbUser=
dbPassword=
backFile=${dbName}_${dateTimeString}.bak
/opt/mssql-tools18/bin/sqlcmd -S localhost -C -U ${dbUser} -P ${dbPassword} -Q "BACKUP DATABASE [${dbName}] TO DISK = N'${backupPath}/${backFile}' WITH NOFORMAT, NOINIT, NAME = '${dbName}-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10"
Windows backup bat 파일 설정
set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
::Korean
set year=%date:~0,4%
set month=%date:~5,2%
if "%month:~0,1%" == " " set month=0%month:~1,1%
set day=%date:~8,2%
if "%day:~0,1%" == " " set day=0%day:~1,1%
::English
::set year=%date:~-4%
::set month=%date:~4,2%
::if "%month:~0,1%" == " " set month=0%month:~1,1%
::set day=%date:~7,2%
::if "%day:~0,1%" == " " set day=0%day:~1,1%
set dbName=
set datetimstr=%year%%month%%day%_%hour%%min%%secs%
set backupdir=D:\Database\Backup
set filename=Backup_%dbName%_%datetimstr%.bak
set filepath=%backupdir%\%filename%
if not exist %backupdir% mkdir %backupdir%
sqlcmd -E -S "127.0.0.1" -Q "backup database %dbName% to disk='%filepath%'"
'Database > MS SQL Server' 카테고리의 다른 글
[SQL Server] How to change MSSQL Server data folder on Linux (0) | 2023.03.08 |
---|---|
[SQL Server] How to use MSSQL Server custom port on Linux (0) | 2023.03.08 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- dotnet core
- php
- c#
- DART
- express
- 자바
- 이클립스
- Java
- Fedora
- Windows
- ubuntu
- 전자정부
- Spring
- Linux
- Entity Framework Core
- eGovFrame
- MySQL
- asp.net core
- MariaDB
- Flutter
- CentOS
- egoverment
- egov
- .NET Core
- high1
- 하이원
- jQuery
- JSP
- 스프링
- Eclipse
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
글 보관함