Projects
jsj
jsj-installtools
PrepareMysqlBackup
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File PrepareMysqlBackup of Package jsj-installtools (Revision 11)
Currently displaying revision
11
,
Show latest
#!/bin/bash if [ -f /etc/SuSE-release ]; then VERSION=$(egrep VERSION /etc/SuSE-release | cut -f2 -d= | tr -d " ") else echo No file /etc/SuSE-release available. Stop. exit 1 fi if [ ${VERSION%%.*} -lt 12 ]; then rcmysql status else systemctl status mysql.service fi RET=$? if [ $RET != 0 ] ; then if [ ${VERSION%%.*} -lt 12 ]; then rcmysql start else systemctl start mysql.service fi fi ADMINPW=$1 mysqladmin password $ADMINPW # generate random password of length 16 PASSWRD=$(dd if=/dev/urandom count=14 bs=1 | mimencode | cut -c3-18) # add crontab entry to dump all databases to /srv/backup/mysql.dump ( crontab -l; echo "0 5 * * * /usr/bin/mysqldump -u mysqlbackup -p$PASSWRD -A --add-drop-database > /srv/backup/mysql.dump" ) | egrep -v "^#" | crontab - # create mysql backup directory mkdir -p /srv/backup # add two users with limited rights for the backup and Nagios checking ( echo "grant SHOW DATABASES, SELECT, LOCK TABLES, RELOAD on *.* to 'nagiosuser'@'%' identified by 'NidBmT.';" echo "grant SHOW DATABASES, SELECT, LOCK TABLES, RELOAD on *.* to 'mysqlbackup'@'localhost' identified by '$PASSWRD';" ) | mysql -u root -p$ADMINPW
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.