Last active
February 22, 2019 04:08
-
-
Save Nill-R/f5a1fbc0fefc8001ff684cfb3b6fdcc0 to your computer and use it in GitHub Desktop.
Script for install mariadb-backup and scripts for it(for Debian/Ubuntu)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash | |
rm -rf /etc/apt/sources.list.d/mariadb.list.old* | |
apt update | |
apt -y install git mariadb-server mariadb-backup qpress | |
red=$'\e[1;31m' | |
grn=$'\e[1;32m' | |
yel=$'\e[1;33m' | |
blu=$'\e[1;34m' | |
mag=$'\e[1;35m' | |
cyn=$'\e[1;36m' | |
end=$'\e[0m' | |
MYSQL=`which mysql` | |
PASS=`tr -cd '[:alnum:]' < /dev/urandom | fold -w24 | head -n1` | |
printf "${cyn}MariaDB backup user password:${end} ${red}$PASS${end}\n\n" | |
Q0="DROP USER IF EXISTS 'backup'@'localhost';" | |
Q1="CREATE USER 'backup'@'localhost' IDENTIFIED BY '$PASS';" | |
Q2="GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT, CREATE TABLESPACE, PROCESS, SUPER, CREATE, INSERT, SELECT ON *.* TO 'backup'@'localhost';" | |
Q3="FLUSH PRIVILEGES;" | |
SQL="${Q0}${Q1}${Q2}${Q3}" | |
$MYSQL -e "$SQL" | |
printf "[client]\nuser=backup\npassword=$PASS\n" >/etc/mysql/backup.cnf | |
cd /tmp | |
git clone https://github.com/Nill-R/debian-ubuntu-mariadb-backup.git | |
cd debian-ubuntu-mariadb-backup | |
chmod +x ./{backup,extract,prepare}-mysql.sh | |
sudo mv ./{backup,extract,prepare}-mysql.sh /usr/local/bin | |
cd .. | |
rm -rf debian-ubuntu-mariadb-backup | |
printf "\n${mag}Backup scripts install done${end}\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment