제가쓰는 데이터 백업 스크립트 정보
OS 제가쓰는 데이터 백업 스크립트
본문
MySQL 데이터 디렉토리를 통째로 압축해서 격리보관하는 경우입니다.
아래에도 비슷한 내용이 있는데요..
저같은 경우에는 30일 지난 파일은 삭제하는 기능까지 해놓았네요.
db_backup.sh
---------------------------------------------------------------------
#/bin/sh
today=`date +%Y%m%d`
#Database backup
tar -cvzf /home/backup/db_backup_$today.tgz /usr/local/mysql/data/
#Old Data Delete
find /home/backup/ -atime 30 -print -exec rm -f {} \;
---------------------------------------------------------------------
-atime 30 요부분이 30일 지난 파일 찾는거에요..
추천
2
2
댓글 1개
man find 입니다.
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago.
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago.