Server IP : 184.154.167.98 / Your IP : 18.216.56.58 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 8.2.26 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/libexec/cloudlinux-backup/ |
Upload File : |
#!/bin/bash source /etc/cloudlinux-backup/mysql_freeze.config echo "$(date -Ins) ---------------------------------------------------------------------" >> "$FREEZE_LOGFILE" echo "$(date -Ins) - Pre-freeze script started." >> "$FREEZE_LOGFILE" echo "$(date -Ins) - Deleting freeze lock file..." >> "$FREEZE_LOGFILE" rm -f "$FREEZE_LOCKFILE" if ! which mysql 1>/dev/null; then echo "$(date -Ins) - No MySQL found. Skip." >> "$FREEZE_LOGFILE" exit 0 fi if [ -f /root/.my.cnf ]; then MYSQL_AUTH_OPTION='--defaults-extra-file=/root/.my.cnf' elif [ -f /etc/psa/.psa.shadow ]; then MYSQL_AUTH_OPTION='--user=admin' export MYSQL_PWD=$(cat /etc/psa/.psa.shadow) elif [ -f /usr/local/directadmin/conf/my.cnf ]; then MYSQL_AUTH_OPTION='--defaults-extra-file=/usr/local/directadmin/conf/my.cnf' else echo "$(date -Ins) - Can't determinate MySQL user and password. Abort." >> "$FREEZE_LOGFILE" exit 3 fi echo "$(date -Ins) - Starting MySQL freeze session..." >> "$FREEZE_LOGFILE" mysql \ $MYSQL_AUTH_OPTION \ --execute="FLUSH TABLES WITH READ LOCK; SYSTEM touch \"$FREEZE_LOCKFILE\"; SYSTEM echo \"\$(date -Ins) - Freeze lock aquired.\" >> \"$FREEZE_LOGFILE\"; SYSTEM sleep $FREEZE_SNAPSHOT_TIMEOUT; SYSTEM echo \"\$(date -Ins) - Freeze session terminated.\" >> \"$FREEZE_LOGFILE\";" \ 1>/dev/null 2>>$FREEZE_LOGFILE & FREEZE_SESSION_PID=$! echo "$(date -Ins) - Started MySQL freeze session, PID is $FREEZE_SESSION_PID..." >> "$FREEZE_LOGFILE" attempts=0 while [ ! -f "$FREEZE_LOCKFILE" ]; do if ! ps -p $FREEZE_SESSION_PID 1>/dev/null; then echo "$(date -Ins) - Seems like MySQL freeze statement failed. Aborted." >> "$FREEZE_LOGFILE" exit 1 fi sleep 1s attempts=$((attempts+1)) if [ $attempts -gt $FREEZE_MYSQL_TIMEOUT ]; then echo "$(date -Ins) - MySQL cannot freeze in suitable time. Aborting..." >> "$FREEZE_LOGFILE" kill $FREEZE_SESSION_PID exit 2 fi echo "$(date -Ins) - Waiting for MySQL to freeze tables. Making try $attempts..." >> "$FREEZE_LOGFILE" done echo $FREEZE_SESSION_PID > "$FREEZE_LOCKFILE" echo "$(date -Ins) - Freeze successful." >> "$FREEZE_LOGFILE"