사이트 내 전체검색
Cron을 이용한 증분백업 + FTP백업
로빈아빠
https://cmd.kr/server/78 URL이 복사되었습니다.

본문

cron.daily

#!/bin/bash
cd /

#########################################################
# 백업용 FTP 서버 정보
#########################################################
FTP_SERVER=서버주소
FTP_ID=아이디
FTP_PW=비밀번호
FTP_DIR=./

#########################################################
# DB 백업
#########################################################
BACKUP_DIR=home/backup/mysql

# MYSQL
DATA_DIR=usr/local/mysql/data
BACKUP_NAME=mysql
DATE=$(date +%Y%m%d%H%M)

tar -cf $BACKUP_DIR/$BACKUP_NAME$DATE.tar $DATA_DIR

ncftpput -u$FTP_ID -p$FTP_PW $FTP_SERVER $FTP_DIR $BACKUP_DIR/$BACKUP_NAME$DATE.tar


#########################################################
# 웹 디렉토리 백업
#########################################################
BACKUP_DIR=home/backup/web

# cnote - 일반증분백업
DATA_DIR=home/cnote
BACKUP_NAME=cnote
SNAPSHOT=cnote-snap-shot
DATE=$(date +%Y%m%d%H%M)

tar -c -g $BACKUP_DIR/$SNAPSHOT -f $BACKUP_DIR/$BACKUP_NAME$DATE.tar $DATA_DIR

ncftpput -u$FTP_ID -p$FTP_PW $FTP_SERVER $FTP_DIR $BACKUP_DIR/$SNAPSHOT
ncftpput -u$FTP_ID -p$FTP_PW $FTP_SERVER $FTP_DIR $BACKUP_DIR/$BACKUP_NAME$DATE.tar


# hgtt - 분할증분백업
DATA_DIR=home/hgtt
BACKUP_NAME=hgtt
SNAPSHOT=hgtt-snap-shot
DATE=$(date +%Y%m%d%H%M)

tar -c -g $BACKUP_DIR/$SNAPSHOT -f $BACKUP_DIR/$BACKUP_NAME$DATE.tar $DATA_DIR
tar -c -g $BACKUP_DIR/$SNAPSHOT $DATA_DIR | split -b 4455m - $BACKUP_DIR/$BACKUP_NAME$DATE.tar_

ncftpput -u$FTP_ID -p$FTP_PW $FTP_SERVER $FTP_DIR $BACKUP_DIR/$SNAPSHOT
ncftpput -z -u$FTP_ID -p$FTP_PW $FTP_SERVER $FTP_DIR $BACKUP_DIR/$BACKUP_NAME*


cron.monthly

#!/bin/bash
rm -rf /home/backup/web_old
rm -rf /home/backup/mysql_old
mv /home/backup/web /home/backup/web_old
mv /home/backup/mysql /home/backup/mysql_old
mkdir /home/backup/web
mkdir /home/backup/mysql

댓글목록

등록된 댓글이 없습니다.

1,139 (5/23P)

Search

Copyright © Cmd 명령어 3.144.42.205