Skip to content

Commit ea7c03f

Browse files
committed
optimize the script using best practice of backup policy
1 parent 85260f0 commit ea7c03f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

projects/backupOps/MySQL/backup-mysql-using-mysqldump.sh

+11
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ mysql_backup_dir=/backup/db/mysql
6161
date_format_type_dir=$(date +%Y-%m-%d)
6262
date_format_type_file=$(date +%Y%m%d%H%M%S)
6363

64+
# TODO(DingGuodong) we can send backups to oss(object store service)
65+
66+
# do this ONLY once
67+
lock_file=$mysql_basedir/.backup_lock_file # do NOT set to $DEST, make sure $DEST (backup disk) exist
68+
if [[ ! -f $lock_file ]]; then
69+
mkdir -p $mysql_backup_dir
70+
touch $lock_file
71+
fi
72+
73+
test ! -d $mysql_backup_dir && echo "backup dir not exist, disk is down? exit now." && exit 1
74+
6475
echo "------------------------------------------------------------------------"
6576
echo "=> do backup scheduler start at $(date +%Y%m%d%H%M%S)"
6677

0 commit comments

Comments
 (0)