first commit
This commit is contained in:
commit
86e50ca1eb
1 changed files with 19 additions and 0 deletions
19
mysql_backup_split.sh
Normal file
19
mysql_backup_split.sh
Normal file
|
@ -0,0 +1,19 @@
|
|||
timenow=$(date \+\%Y\%m\%d)
|
||||
|
||||
#common variables:
|
||||
retention_days="31" #after this value your dumps will be automatically pruned
|
||||
basedir="/mnt/backup/_MYSQLDUMP/" #leave a trailing "/" . basedirectory where you will save the backups, the folders up to mysql_basedir must be manually created
|
||||
|
||||
#specific variables:
|
||||
mysql_basedir="MYSQL_PRD/" #leave a trailing "/" . directory where your backup will be saved (in $basedir)
|
||||
mysql_host="CHANGEME" #your mysql/mariadb db host
|
||||
mysql_user="bck_user" #your mysql/mariadb READONLY user
|
||||
mysql_pass="CHANGEME" #your mysql/mariadb READONLY user pass
|
||||
mysql_suff="CHANGEME_" #leave a trailing unserscore. suffix for the folder that will be created like this: /basedir/mysql_basedir/mysql_suff_timenow
|
||||
mysql_dir=$basedir$mysql_basedir$mysql_suff$timenow
|
||||
|
||||
mkdir $mysql_dir
|
||||
cd $mysql_dir
|
||||
mysql -h $mysql_host -u $mysql_user -p$mysql_pass -N -e 'show databases' | while read dbname; do mysqldump -h $mysql_host -u $mysql_user -p$mysql_pass --compress "$dbname" | gzip -c > "$dbname".sql.gz; done
|
||||
|
||||
find $basedir$mysql_basedir -type d -mtime +$retention_days -name $mysql_suff* -exec rm -rf {} \;
|
Loading…
Reference in a new issue