/etc/cron.daily/backup.sh
====================================
#!/bin/sh
LANG=en
PATH=/usr/bin:/bin
DOW=`date +%a`
DOM=`date +%d`
HOMEDIR=/home/user
BACKUPDIR=/backup
MYSQLPASSWD="*******"
cd ${HOMEDIR}
for USER in *; do
if [ $DOW = "Sun" ]; then
NOW=`date +%d-%b`
echo $NOW > ${BACKUPDIR}/last-full-date
mv -f ${BACKUPDIR}/data/${USER}-${DOW}.tar ${BACKUPDIR}/data/${USER}-${DOW}.old.tar
tar -cpf ${BACKUPDIR}/data/${USER}-${DOW}.tar ${USER}
else
NEWER="--newer=`cat ${BACKUPDIR}/last-full-date`"
tar -cp ${NEWER} -f ${BACKUPDIR}/data/${USER}-DOW.tar ${USER}
fi
done
DATABASE=`mysql -u root -p${MYSQLPASSWD} -e "show databases;" -s`
for DB in ${DATABASE}; do
mysqldump -u root -p${MYSQLPASSWD} --opt ${DB} --default-character-set=euckr --extended-insert=false > ${BACKUPDIR}/db/${DB}-${DOW}.sql
done
cd /
tar -cpf ${BACKUPDIR}/data/etc-${DOW}.tar etc
====================================
#!/bin/sh
LANG=en
PATH=/usr/bin:/bin
DOW=`date +%a`
DOM=`date +%d`
HOMEDIR=/home/user
BACKUPDIR=/backup
MYSQLPASSWD="*******"
cd ${HOMEDIR}
for USER in *; do
if [ $DOW = "Sun" ]; then
NOW=`date +%d-%b`
echo $NOW > ${BACKUPDIR}/last-full-date
mv -f ${BACKUPDIR}/data/${USER}-${DOW}.tar ${BACKUPDIR}/data/${USER}-${DOW}.old.tar
tar -cpf ${BACKUPDIR}/data/${USER}-${DOW}.tar ${USER}
else
NEWER="--newer=`cat ${BACKUPDIR}/last-full-date`"
tar -cp ${NEWER} -f ${BACKUPDIR}/data/${USER}-DOW.tar ${USER}
fi
done
DATABASE=`mysql -u root -p${MYSQLPASSWD} -e "show databases;" -s`
for DB in ${DATABASE}; do
mysqldump -u root -p${MYSQLPASSWD} --opt ${DB} --default-character-set=euckr --extended-insert=false > ${BACKUPDIR}/db/${DB}-${DOW}.sql
done
cd /
tar -cpf ${BACKUPDIR}/data/etc-${DOW}.tar etc
'서버.보안' 카테고리의 다른 글
apache .htaccess (0) | 2014.01.17 |
---|---|
아파치 SSL인증서 비번묻지않기 (0) | 2011.03.02 |
FTP커맨드..서버에서버서로 통째로복사하기 (0) | 2009.02.18 |
Tar 사용법 (0) | 2008.11.17 |
iptables 중국IP걸러내기룰셋 (0) | 2008.07.11 |
댓글