[server] 리눅스 디렉토리별 백업하기
본문
#!/bin/sh
Today="`date '+%y-%m-%d'`"
backup_dir="/data/backup"
##### 일주일 지난 백업삭제 #####
dirlists=`/bin/ls -t /data/backup 2>/dev/null`
i=1
for dir in $dirlists ; do
if [ "$i" -ge 7 ] ; then
/bin/rm -rf $backup_dir/$dir
fi
i=$(($i+1))
done
#### 백업폴더 생성 ####
/bin/mkdir -p $backup_dir/$Today
cd $backup_dir/$Today
#### 디렉토리별 백업 ####
home_dir=`/bin/ls -t /home 2>/dev/null`
for dir in $home_dir ; do
tar -zcpf $backup_dir/$Today/$dir.tar.gz --exclude /home/$dir/logs /home/$dir
done
#### MySQL 백업 ####
tar -zcpf $backup_dir/$Today/mysql.tar.gz /data/mysql_data
##### System Backup ####
tar -zcpf $backup_dir/
$Today/system.tar.gz /etc/httpd/conf/httpd.conf /etc/passwd /etc/mail/access
관련링크
- https://www.autoboy.pe.kr/237 718회 연결
댓글목록 0
등록된 댓글이 없습니다.