찐쿵
bluedrugs
찐쿵
  • 전체보기 (42)
    • 똑똑해진느낌 (39)
      • C# (7)
      • VB (4)
      • Python (11)
      • MySQL (4)
      • Linux (6)
      • Appium (1)
      • Selenium (1)
      • Sikuli (1)
      • Win10 (2)
      • 기타 (1)
      • 제작 (1)
      • Tensorflow (0)
    • 일상적인느낌 (1)
hELLO · Designed By 정상우.
찐쿵

bluedrugs

[MySQL] 데이터베이스 백업 스케줄링 (mysqldump)
똑똑해진느낌/MySQL

[MySQL] 데이터베이스 백업 스케줄링 (mysqldump)

2019. 8. 26. 14:03

1. 명령어

mysqldump -u유저 -p비밀번호 --result-file="c:\backup.sql" 데이터베이스명

2. 배치파일 적용

@echo off
echo DB Backup Start ...

FOR /F "tokens=1-3 delims=- " %%a IN ('DATE /T') DO (SET dt=%%a-%%b-%%c)
FOR /F "tokens=1-4 delims=:." %%a IN ('ECHO %TIME%') DO (SET tm=%%a%%b%%c%%d)
SET backupfilename=%dt%_%tm%.sql

"c:\Program Files\MySQL\MySQL Server 8.0\bin\"mysqldump -u유저명 -p비밀번호 --result-file="c:\db_%backupfilename%" 데이터베이스명
echo DB Backup Done !!!

3. 배치파일 실행결과

4. 30일 경과된 백업파일 삭제 기능 추가

FORFILES /P "c:\bakcup" /S /M *.sql /D 30 /C "cmd /c del @file"

5. 스케줄러 담기 (매 월요일,금요일 오후 8시에 실행)

at 20:00 /every:M,F c:\backup\test.bat

​

저작자표시 비영리 동일조건 (새창열림)

'똑똑해진느낌 > MySQL' 카테고리의 다른 글

[MySQL] Client Connect Error (Unable to connect to any of the specified MySQL hosts)  (0) 2019.08.26
[MySQL] Insert 속도 향상 시키는 방법  (0) 2019.08.26
[MySQL] GUI Editor (SQLyog)  (0) 2019.08.26
    '똑똑해진느낌/MySQL' 카테고리의 다른 글
    • [MySQL] Client Connect Error (Unable to connect to any of the specified MySQL hosts)
    • [MySQL] Insert 속도 향상 시키는 방법
    • [MySQL] GUI Editor (SQLyog)
    찐쿵
    찐쿵
    기록하는느낌

    티스토리툴바