-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.sh
109 lines (76 loc) · 5.2 KB
/
config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
# Все настройки скриптов
# Автор: Олег Букатчук
# Версия: 1.9
# e-mail: oleg@bukatchuk.com
# Создаём константу из абсолютного пути к директории скриптов и выставляем правильные права доступа.
export DB_SUITE="/path/to/db_suite"
# Создаём константу из абсолютного пути к директории со скриптами для уведомлений.
export EMAIL="${DB_SUITE}/action"
# Создаём константу из смонтированной ftp-директории.
export FTP_MOUNT_DIR="/mnt/ftp"
# Создаём константу из ftp-коннекта.
export FTP_STORAGE="/path/to/ftp/dir"
# Создаём константу с обозначением имени сервера
export SERVER_NAME=hostname
# Создаём константу из абсолютного пути к скрипту и делаем скрипт исполняемым.
export RUN_MYSQL_BACKUP="${DB_SUITE}/mysql/mysql_backup.sh"
# Создаём константу из абсолютного пути к скрипту и делаем скрипт исполняемым.
export RUN_POSTGRESQL_BACKUP="${DB_SUITE}/postgresql/postgresql_backup.sh"
# Создаём константу для директории хранения бекапов.
export STORAGE="/path/to/backup/postgresql"
# Создаём константу для размера директории с бэкапами.
export SPACE_USED=`du -sh ${STORAGE}`
# Создаём константу для директории эталонной конфигурации MySQL.
export DEFAULT_MYSQL="${DB_SUITE}/config/mysql/my.cnf"
# Создаём константу для директории эталонной конфигурации PostgreSQL.
export DEFAULT_POSTGRESQL="${DB_SUITE}/config/postgresql/postgresql.conf"
# Создаём константу для директории пакетов.
export PACKAGE="${DB_SUITE}/package"
# Создаём константу для директории хранения конфигов сервера MySQL.
export LOCAL_MYSQL="/etc/mysql/my.cfg"
# Создаём константу для директории хранения конфигов сервера PostgreSQL.
export LOCAL_POSTGRESQL="/etc/postgresql/9.6/main/postgresql.conf"
# Выясняем статус пакета MySQL в системе и создаём константу.
export MYSQL_OK=$(dpkg-query -W --showformat='${Status}\n' mysql | grep "install ok installed")
# Выясняем статус пакета PostgreSQL в системе и создаём константу.
export POSGRESQL_OK=$(dpkg-query -W --showformat='${Status}\n' postgresql | grep "install ok installed")
s
# Выясняем статус пакета pv в системе и создаём константу.
export PV_OK=$(dpkg-query -W --showformat='${Status}\n' pv | grep "install ok installed")
# Выясняем статус пакета sendemail в системе и создаём константу.
export SENDEMAIL_OK=$(dpkg-query -W --showformat='${Status}\n' sendemail | grep "install ok installed")
#####################################################################################################################
# Настройки MySQL
# Объявляем переменные для авторизации в MySQL
# export HOST_MYSQL=localhost
# export USER_MYSQL=login
# export PASS_MYSQL=password
# export DB_MYSQL=database
#####################################################################################################################
# Настройки PostgreSQL
# Создаём константу для подключеня к базе данных PostgeSQL.
# export CONNECT_POSTGRESQL=postgresql://password:login@127.0.0.1:5432/database
#####################################################################################################################
# Настройки режима отладки
# Режим отладки скрипта (любое действие можно отслеживать: любая команда >> $LOG_FILE)
# export LOG_DIR=/var/log/db_suite && sudo mkdir $LOG_DIR
# export LOG_FILE="${LOG_DIR}/postgresql_backup.log" && sudo touch "${LOG_DIR}/${LOG_FILE}"
# Выставляем пользователя под которым будут запускаться скрипты.
sudo chown -R user:user ${DB_SUITE}
# Выставляем права доступа на директорию со скриптами.
sudo chmod -R 777 ${DB_SUITE}
# Делаем скрипты для MySQL исполняемыми.
sudo chmod +x ${RUN_MYSQL_BACKUP}
# Делаем скрипты для PostgreSQL исполняемыми.
sudo chmod +x ${RUN_POSTGRESQL_BACKUP}
# Подключаем файл
source "${DB_SUITE}/mysql/mysql_backup.sh"
# Подключаем файл
source "${DB_SUITE}/mysql/mysql_tunning.sh"
# Подключаем файл
source "${DB_SUITE}/postgresql/postgresql_backup.sh"
# Подключаем файл
source "${DB_SUITE}/postgresql/postgresql_tunning.sh"
# Подключаем файл
source "${DB_SUITE}/notice/email.sh"