컴퓨터스킬

우분투환경에서 mysql 백업 자동화

by 마인드진 2017. 4. 21. 15:10

mysqldump -uroot -p {talbe_name} > {program_name}_xxxx.sql


패스워드를 자동화 하기 위해서 명령어에 넣을 경우 다음과 같이 워닝을 볼 수 있다.

아래와 같이 해결 할 수 있다.


Warning: Using a password on the command line interface can be insecure

출처: http://knight76.tistory.com/entry/mariadbmysqldbWarning-Using-a-password-on-the-command-line-interface-can-be-insecure



sh 내용


#!/bin/sh


mysqldump --login-path=localhost weddingmoney > /home/plutonic/backup/{program_name}_$(date +%Y%m%d).sql


하루에 한번 저장하기 위해 날짜 값을 가져왔다.


우분투 자동화를 위해 cron 를 사용하면 쉽게 반복 작업을 할 수 있다.


출처: https://mytory.net/archives/601