Skip to content
kenu edited this page Oct 4, 2011 · 3 revisions

#Database

##cubrid R3 8.3.1

##Backup

  • database name db_okjsp is not real

###crontab

[root@okjsp ~]# su - cubrid
[cubrid@okjsp ~]$ crontab -l
0 1 * * * "/home/cubrid/bin/cubrid_backup.sh"
0 2 * * * "/home/cubrid/bin/cubrid_unloaddb.sh"
[cubrid@okjsp bin]$ cat cubrid_backup.sh 
#!/bin/bash

## CUBRID Backup sh
SHELL=/bin/bash
. /home/cubrid/.cubrid.sh

#delete 7 days ago
OLD_DATE=`date --date '7 days ago' +%m%d`
rm -rf /home/cubrid/BACKUP/${OLD_DATE}
echo Deleted /home/cubrid/BACKUP/${OLD_DATE} backup

#backup today
BACKUP_DATE=`date +%m%d`
BACKUP_DIR=/home/cubrid/BACKUP/${BACKUP_DATE}
BACKUP_LOG=${BACKUP_DIR}/backup_db_${BACKUP_DATE}.log
mkdir ${BACKUP_DIR}
database=db_okjsp

#level=$1

#if [ $level=0 ]; then
	cubrid backupdb -C -D ${BACKUP_DIR} -l 0 --no-check -z -r $database   >> ${BACKUP_LOG}
#elif [ $level=1 ]; then
#    cubrid backupdb -C -D ${BACKUP_DIR} -l 1 --no-check -z -r $database   >> ${BACKUP_LOG}
#elif [ $level=2 ]; then
#    cubrid backupdb -C -D ${BACKUP_DIR} -l 2 --no-check -z -r $database   >> ${BACKUP_LOG}
#else
#echo "#############################################################"
#echo "####  command. level 0,1,2 .. .....  #####"
#echo "#############################################################"
#exit 1
#fi
exit;
[cubrid@okjsp bin]$ cat cubrid_unloaddb.sh 
#!/bin/bash

## CUBRID Backup sh
SHELL=/bin/bash
. /home/cubrid/.cubrid.sh

BACKUP_DATE=`date +%Y%m%d`
database=db_okjsp
cd /home/cubrid/BACKUP/
mv unload_data.tar.gz unload_data_old.tar.gz
cubrid unloaddb -C -v $database > /home/cubrid/BACKUP/unload_$BACKUP_DATE.log
tar cvfz unload_data.tar.gz db_okjsp*
rm -f db_okjsp_*
[cubrid@okjsp bin]$ 
Clone this wiki locally