cdouglas_souza
(usa Ubuntu)
Enviado em 27/01/2020 - 17:51h
Olá pessoal, boa tarde!!
Estou com o seguinte problema, tenho 3 arquivos .sh aos quais gostaria de utilizar no windows, convertendo-os para .bat, pelo que ví não existe automação para esta tarefa tendo que ser feito manualmente. Como não tenho essa habilidade gostaria de saber se alguém poderia me ajudar fazendo esta conversão. Desde de já agradeço pelo apoio!
Os arquivos são os seguites:
----------------------------------------------------------------------------------------------------------------------------
config.sh
FREEZE_MYSQL_TIMEOUT=300
FREEZE_SNAPSHOT_TIMEOUT=60
FREEZE_LOCKFILE=/var/lib/Acronis/mysql/mysql-freeze.lock
FREEZE_LOGFILE=/var/lib/Acronis/mysql/mysql-freeze.log
---------------------------------------------------------------------------------------------------------------------------
pre-freeze-script.sh
#!/bin/bash
source config.sh
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"
echo "$(date -Ins) - Starting MySQL freeze session..." >> "$FREEZE_LOGFILE"
mysql \
--defaults-extra-file=/root/.my.cnf \
--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>/dev/null &
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"
-----------------------------------------------------------------------------------------------------------------------------------------------------------
post-thaw-script.sh
#!/bin/bash
source config.sh
echo "$(date -Ins) - Post-thaw script started." >> "$FREEZE_LOGFILE"
FREEZE_SESSION_PID=$(cat "$FREEZE_LOCKFILE")
echo "$(date -Ins) - Terminating freeze session. PID is $FREEZE_SESSION_PID." >> "$FREEZE_LOGFILE"
pkill -9 -P $FREEZE_SESSION_PID
echo "$(date -Ins) - Deleting freeze lock file..." >> "$FREEZE_LOGFILE"
rm -f "$FREEZE_LOCKFILE"
echo "$(date -Ins) - Unfreeze successful." >> "$FREEZE_LOGFILE"
-----------------------------------------------------------------------------------------------------------------------------------------------------