Last active
April 14, 2023 00:29
-
-
Save leskovia/545128714ab068d5122e7fdd217b5848 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
LOGFILE=/var/log/mysql_backup | |
DIR=/var/mariadb/ | |
DIRNEW="${DIR}backup_new/" | |
DIROLD="${DIR}backup_old/" | |
USER=YOUR_DB_USER | |
PASS=YOUR_DB_PASSWORD | |
date +"# Start Backup Mysql at %T %D" >> $LOGFILE | |
if [ ! -f %DIR ]; then | |
mkdir $DIR 2>> $LOGFILE | |
fi | |
rm -r $DIROLD 2>> $LOGFILE | |
mv $DIRNEW $DIROLD 2>> $LOGFILE | |
mariabackup --backup --target-dir=$DIRNEW --user=$USER --password=$PASS 2>> $LOGFILE | |
mariabackup --prepare --target-dir=$DIRNEW --user=$USER --password=$PASS 2>> $LOGFILE | |
date +"# Finish backup at %T %D" >> $LOGFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment