Introduction to server management with provisioning tool fairy support run
Basic function introduction 2(Using mysql dump as an example)

Prepare

Last time, Basic function of fairy support run using apache http server installation were introduced
The basic function that could not be introduced last time is introduced using mysql dump as an example this time
Speaking is done by the premise in which you have the last environment
If you have not executed the previous contents, please see this page after executing
Please download a sample from here

Install MySQL

Let's install MySQL to try mysql dump
I will explain using a sample file

folder tree
     |-- fairysupport_run
     |   |-- common
     |   |   |-- common.sh
     |   |   `-- db_user.sh
     |   |-- mysql
     |   |   |-- include.txt
     |   |   |-- my.cnf
     |   |   `-- main.sh
     |   |-- com_fairysupport_run.jar
     |   |-- env.txt
     |   `-- server.properties.local
     |-- vagrant
     |   `-- Vagrantfile

Run fairy support run

fairysupport_run.bat mysql -f server.properties
./fairysupport_run.sh mysql -f server.properties

MySQL installed

Download of file

Let's create a sample to download mysql dump results
I will explain using a sample file

folder tree
     |-- fairysupport_run
     |   |-- common
     |   |   |-- common.sh
     |   |   `-- db_user.sh
     |   |-- dump_db
     |   |-- dump_db_get
     |   |   |-- get.txt
     |   |   |-- include.txt
     |   |   `-- main.sh
     |   |-- com_fairysupport_run.jar
     |   |-- env.txt
     |   `-- server.properties.local
     |-- vagrant
     |   `-- Vagrantfile

Let's look at main.sh in dump_db_get

main.sh
#!/bin/bash

. ../common/common.sh
. ../common/db_user.sh

validate_arg_num $# 1 "please input database name"

mysqldump -u${db_root_user} -p${db_root_pw} -vvv ${1} > ./mysqldump.sql

validate_arg_num is defined in common.sh. This function exits with an error message if the number of arguments is less than the second argument (1 in this case)
Output result of mysqldump to ./mysqldump.sql


There is a file called get.txt in the dump_db_get folder
If there is a file named get.txt, fairy support run will download the file or folder written in get.txt
In get.txt, write the source file or folder name and the destination file or folder name
Contents in get.txt is written as source space destination
Let's look at get.txt in dump_db_get

get.txt
mysqldump.sql ../dump_db/${FILE}_${SERVER}/${1}/${DATE}_${HH}${MM}${SS}/mysqldump.sql

Contents of get.txt
mysqldump.sql is the source file. dump_db_get on the server is the current directory
../dump_db/${FILE}_${SERVER}/${1}/${DATE}_${HH}${MM}${SS}/mysqldump.sql is the file after download. Local dump_db_get becomes the current directory
The part enclosed in ${} is replaced for by the following
${integer}:argument, ${FILE}: Property file name, ${SERVER}: Left side of key period in property file, ${ENV}:contents of env.txt, ${DATE}: Execution date, ${HH}: hour part of the execution time, ${MM}: minute part of the execution time, ${SS}: second part of the execution time

Run fairy support run

Let's run

fairysupport_run.bat dump_db_get mysql -f server.properties
./fairysupport_run.sh dump_db_get mysql -f server.properties

Let's see under dump_db

folder tree
     |-- fairysupport_run
     |   |-- common
     |   |   |-- common.sh
     |   |   `-- db_user.sh
     |   |-- dump_db
     |   |   |-- server_server1
     |   |   |   `-- mysql
     |   |   |      `-- YYYYMMDD_HHMMSS
     |   |   |         `-- mysqldump.sql
     |   |   `-- server_server2
     |   |       `-- mysql
     |   |          `-- YYYYMMDD_HHMMSS
     |   |             `-- mysqldump.sql
     |   |-- dump_db_get
     |   |   |-- get.txt
     |   |   |-- include.txt
     |   |   `-- main.sh
     |   |-- com_fairysupport_run.jar
     |   |-- env.txt
     |   `-- server.properties.local
     |-- vagrant
     |   `-- Vagrantfile

You can see the result of mysql dump is downloaded


On the next page, we will introduce password and passphrase encryption functions

table of contents