mariadb: Initial version of mariadb module.
This commit is contained in:
parent
f069517a7a
commit
d82e3021a4
4 changed files with 238 additions and 0 deletions
32
mariadb/templates/mariadb-backup.cron.erb
Normal file
32
mariadb/templates/mariadb-backup.cron.erb
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
|
||||
umask 077
|
||||
|
||||
DESTDIR="<%= @datadir %>"
|
||||
MAXAGE="<%= @maxage %>"
|
||||
|
||||
DATE=`date "+%Y-%m-%d"`
|
||||
HOME="`getent passwd ${USER} | cut -d : -f 6`"
|
||||
OPTS=""
|
||||
|
||||
if [ ! -d ${DESTDIR} ]; then
|
||||
echo "ERR: MariaDB backup directory [${DESTDIR}] does not exist" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd ${DESTDIR} && {
|
||||
find . -xdev -mindepth 2 -maxdepth 2 -type f -mtime +<%= @maxage %> -execdir rm -f -- {} \;
|
||||
find . -xdev -depth -mindepth 1 -maxdepth 1 -type d -empty -execdir rmdir -- {} \;
|
||||
}
|
||||
|
||||
DESTDIR=${DESTDIR}/${DATE}
|
||||
mkdir -p ${DESTDIR}
|
||||
|
||||
for db in `mysql -e 'show databases' -s` ; do
|
||||
case ${db} in
|
||||
Database|information_schema|performance_schema)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
mysqldump -E --add-drop-table ${OPTS} ${db} | gzip > ${DESTDIR}/${db}.${DATE}.gz
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue