Collection for database management systems
Go to file
2024-05-19 11:50:04 +03:00
.gitignore Initial commit 2024-05-19 10:29:38 +03:00
LICENSE Initial commit 2024-05-19 10:29:38 +03:00
mysqldump-wrapper.sh add mysqldump-wrapper.sh 2024-05-19 11:50:04 +03:00
README.md add mysqldump-wrapper.sh 2024-05-19 11:50:04 +03:00

dbms

Collection for database management systems


mysqldump-wrapper.sh

Description:

creating database dump, copying to additional smb share, copies rotating and sending report to email

Dependencies:

POSITION PARAMETERS DESCRIPTION DEFAULT
1 [/path/to/file.conf] path to config file REQUIRED

Installing mysqldump-wrapper.sh and setting up crontab

# edit config
sudo tee /usr/local/bin/mysqldump-wrapper.conf > /dev/null <<'EOF'
# mysql connection parameters
db_host=db-server.domain.zone
db_user=db-username
db_pass=db-password
db_name=database

# dump repository parameters
dump_root=/home/user/backup
dump_save=1

# copy smb-repository parameters
smb_host=smb-server.domain.zone
smb_path=smb-share/backup
smb_user=smb-username
smb_domn=smb-domain
smb_pass=smb-password
copy_save=7

# sendmail parameters
smtp_pyth=/usr/local/opt/python-3.9/bin/python3.9
smtp_send=/usr/local/bin/sendmail.py
smtp_host=mail-server.domain.zone
smtp_port=587
smtp_from=mail-from@domain.zone
smtp_pass=mail-password
smtp_dest=mail-dest@domain.zone
EOF
# download
sudo wget https://git.hmp.today/pavel.muhortov/dbms/raw/branch/master/mysqldump-wrapper.sh -O /usr/local/bin/mysqldump-wrapper.sh
sudo chmod +x /usr/local/bin/mysqldump-wrapper.sh
# sudo sh -c "EDITOR=nano crontab -e"
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
00 20 * * * bash /usr/local/bin/mysqldump-wrapper.sh /usr/local/bin/mysqldump-wrapper.conf