Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

/var/spool/asterisk/backup/hooks/prebuhook.sh

cat << 'EOL'>/var/spool/asterisk/backup/hooks/prebuhook.sh
#!/bin/bash

sqldump="/usr/bin/mysqldump --defaults-extra-file=/var/spool/asterisk/backup/hooks/.my.cnf"
rm /var/spool/asterisk/backup/hooks/*.sql

#DB1
db1="test"
$sqldump $db1 > /var/spool/asterisk/backup/hooks/$db1.sql

EOL
chown asterisk:asterisk /var/spool/asterisk/backup/hooks/ -R
chmod +x /var/spool/asterisk/backup/hooks/*

/var/spool/asterisk/backup/hooks/prerestorehook.sh

cat << 'EOL' >/var/spool/asterisk/backup/hooks/postrestorehook.sh
#!/bin/bash

sql="/usr/bin/mysql --defaults-extra-file=/var/spool/asterisk/backup/hooks/.my.cnf"

#DB1
db1="test"
db1exists="$($sql -e 'show databases;' | grep -w $db1)"
if [ -z "$db1exists" ]; then
	$sql -e "create database $db1;"
fi
$sql $db1 < /var/spool/asterisk/backup/hooks/$db1.sql

EOL
chown asterisk:asterisk /var/spool/asterisk/backup/hooks/ -R
chmod +x /var/spool/asterisk/backup/hooks/*

.my.cnf variables

  • No labels