{"id":5647,"date":"2022-12-20T13:24:09","date_gmt":"2022-12-20T04:24:09","guid":{"rendered":"\/blog\/?p=5647"},"modified":"2023-09-21T09:26:23","modified_gmt":"2023-09-21T00:26:23","slug":"ms-sql-%eb%b0%b1%ec%97%85-%eb%b0%8f-%eb%b3%b5%ec%9b%90-%ec%8a%a4%ed%81%ac%eb%a6%bd%ed%8a%b8-%ec%83%98%ed%94%8c","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=5647","title":{"rendered":"MS-SQL \ubc31\uc5c5 \ubc0f \ubcf5\uc6d0 \uc2a4\ud06c\ub9bd\ud2b8 \uc0d8\ud50c"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@ECHO OFF\nREM =======================================\nREM CODEPAGE\ub97c EUC-KR\ub85c \ubcc0\uacbd\nREM =======================================\nCHCP 949 1> NUL 2> NUL\nCLS\n\nREM =======================================\nREM \ud0c0\uc784\uc2a4\ud0ec\ud504 \ubcc0\uc218 \ub9cc\ub4e4\uae30\nREM =======================================\nSET TIMESTAMP_VAL=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%\nSET TIMESTAMP_VAL=%TIMESTAMP_VAL: =0%\n\nREM =======================================\nREM \ubcc0\uc218 \uc815\uc758\nREM =======================================\nSET \"PATH=%PATH%;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\110\\Tools\\Binn\"\nSET \"BACKUP_DIR=C:\\0_tmp\"\nSET \"BACKUP_SQL=BACKUP DATABASE db_test TO DISK='%BACKUP_DIR%\\%TIMESTAMP_VAL%_db_test.bak' WITH FORMAT,INIT,COMPRESSION\"\nSET \"RESTORE_SQL=RESTORE DATABASE db_test FROM DISK='%BACKUP_DIR%\\20221220_132030_db_test.bak'\"\n\nREM =======================================\nREM \uc2e4\ud589\nREM =======================================\nCALL :RUN_BACKUP\nCALL :RUN_RESTORE\nEXIT \/B 0\n\n:RUN_RESTORE\nECHO =======================================\nECHO \ubc31\uc5c5 \ubcf5\uc6d0\uc744 \uc2e4\ud589\ud569\ub2c8\ub2e4.\nECHO \ubc31\uc5c5 \ud30c\uc77c\uc774 \uc0dd\uc131 \ub41c \uc774\ud6c4 \ud574\ub2f9 DB\uc5d0 \ub300\ud55c\nECHO \ubaa8\ub4e0 \ubcc0\uacbd \uc0ac\ud56d\uc740 \uc190\uc2e4 \ub429\ub2c8\ub2e4.\nECHO.\nECHO SQLCMD -E -Q \"%RESTORE_SQL%\"\nECHO =======================================\nPAUSE\nSQLCMD -E -Q \"%RESTORE_SQL%\"\nEXIT \/B\n\n:RUN_BACKUP\nECHO =======================================\nECHO \ubc31\uc5c5\uc744 \uc2e4\ud589\ud569\ub2c8\ub2e4.\nECHO.\nECHO SQLCMD -E -Q \"%BACKUP_SQL%\"\nECHO =======================================\nPAUSE\nSQLCMD -E -Q \"%BACKUP_SQL%\"\nEXIT \/B<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[40,10],"tags":[],"class_list":["post-5647","post","type-post","status-publish","format-standard","hentry","category-os_win","category-computing_database"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5647"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5647\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}