fix: encoding problems
This commit is contained in:
@@ -1,60 +1,60 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# mysql database backup.
|
# mysql database backup.
|
||||||
# executed by duplicati run-script-before-required
|
# executed by duplicati run-script-before-required
|
||||||
# required environment variables:
|
# required environment variables:
|
||||||
|
|
||||||
# MYSQL_HOST
|
# MYSQL_HOST
|
||||||
# MYSQL_USER
|
# MYSQL_USER
|
||||||
# MYSQL_PASSWORD
|
# MYSQL_PASSWORD
|
||||||
# MYSQL_DATABASE
|
# MYSQL_DATABASE
|
||||||
# MYSQL_BACKUP_FOLDER
|
# MYSQL_BACKUP_FOLDER
|
||||||
|
|
||||||
#any error must stop execution
|
#any error must stop execution
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -f "/etc/default/duplicati-mysql" ]; then
|
if [ -f "/etc/default/duplicati-mysql" ]; then
|
||||||
export $(cat /etc/default/duplicati-mysql)
|
export $(cat /etc/default/duplicati-mysql)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "~/.config/duplicati-mysql" ]; then
|
if [ -f "~/.config/duplicati-mysql" ]; then
|
||||||
export $(cat ~/default/duplicati-mysql)
|
export $(cat ~/default/duplicati-mysql)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ $DUPLICATI__OPERATIONNAME == "Backup" ]
|
if [ $DUPLICATI__OPERATIONNAME == "Backup" ]
|
||||||
then
|
then
|
||||||
echo "Backup Job!!"
|
echo "Backup Job!!"
|
||||||
else
|
else
|
||||||
echo "Not a backup operation. exiting!"
|
echo "Not a backup operation. exiting!"
|
||||||
#OK, run operation
|
#OK, run operation
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[-z "$MYSQL_BACKUP_FOLDER" ]]; then
|
if [[-z "$MYSQL_BACKUP_FOLDER" ]]; then
|
||||||
MYSQL_BACKUP_FOLDER="/var/db-dumps"
|
MYSQL_BACKUP_FOLDER="/var/db-dumps"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $MYSQL_BACKUP_FOLDER ]; then
|
if [ ! -d $MYSQL_BACKUP_FOLDER ]; then
|
||||||
mkdir -p $MYSQL_BACKUP_FOLDER;
|
mkdir -p $MYSQL_BACKUP_FOLDER;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TARGETFILENAME=${MYSQL_DATABASE}_dump_$(date -d "today" +"%Y%m%d%H%M%S").sql
|
TARGETFILENAME=${MYSQL_DATABASE}_dump_$(date -d "today" +"%Y%m%d%H%M%S").sql
|
||||||
echo "dump file name:$TARGETFILENAME"
|
echo "dump file name:$TARGETFILENAME"
|
||||||
|
|
||||||
if [ -f /tmp/${TARGETFILENAME} ]
|
if [ -f /tmp/${TARGETFILENAME} ]
|
||||||
then
|
then
|
||||||
rm /tmp/${TARGETFILENAME}
|
rm /tmp/${TARGETFILENAME}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
mysqldump -h ${MYSQL_HOST} --user=${MYSQL_USER} -p"${MYSQL_PASSWORD}" ${MYSQL_DATABASE} > /tmp/${TARGETFILENAME}
|
mysqldump -h ${MYSQL_HOST} --user=${MYSQL_USER} -p"${MYSQL_PASSWORD}" ${MYSQL_DATABASE} > /tmp/${TARGETFILENAME}
|
||||||
|
|
||||||
|
|
||||||
if [ x$(find "$MYSQL_BACKUP_FOLDER" -prune -empty) = x"$MYSQL_BACKUP_FOLDER" ]; then
|
if [ x$(find "$MYSQL_BACKUP_FOLDER" -prune -empty) = x"$MYSQL_BACKUP_FOLDER" ]; then
|
||||||
echo "folder is empty... ignoring clean db dump folder"
|
echo "folder is empty... ignoring clean db dump folder"
|
||||||
else
|
else
|
||||||
rm -r ${MYSQL_BACKUP_FOLDER}/*
|
rm -r ${MYSQL_BACKUP_FOLDER}/*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv /tmp/${TARGETFILENAME} ${MYSQL_BACKUP_FOLDER}/${TARGETFILENAME}
|
mv /tmp/${TARGETFILENAME} ${MYSQL_BACKUP_FOLDER}/${TARGETFILENAME}
|
||||||
|
|||||||
Reference in New Issue
Block a user