Backup script example, Auto Make directory, Prepare date file name, dump mySQL, Auto rename old backup files with index code, rsync data

#!/bin/bash
basedir=/var/backup/store
sqldir=$basedir/sql
PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH
export LANG=C

for dirs in $basedir
do
        [ ! -d "$dirs" ] && mkdir -p $dirs
done

for dirs in $sqldir
do
        [ ! -d "$dirs" ] && mkdir -p $dirs
done



param1=$(date +%Y-%m-%d-%H-%M-%S)

# Database Backup
sqlusername=root
sqlpassword=Z2PG82SMtQzD
mysqldump=/usr/bin/mysqldump
bwlimit=--bwlimit=100K
#bwlimit=

sqldbname=dbispconfig
sqlsavetarget=$sqldir/$sqldbname.sql
rm -rf $sqlsavetarget.7
mv $sqlsavetarget.6 $sqlsavetarget.7
mv $sqlsavetarget.5 $sqlsavetarget.6
mv $sqlsavetarget.4 $sqlsavetarget.5
mv $sqlsavetarget.3 $sqlsavetarget.4
mv $sqlsavetarget.2 $sqlsavetarget.3
mv $sqlsavetarget.1 $sqlsavetarget.2
mv $sqlsavetarget $sqlsavetarget.1
$mysqldump -u $sqlusername -p$sqlpassword --skip-lock-tables -R $sqldbname > $sqlsavetarget

/usr/bin/rsync -ah $bwlimit --delete /etc $basedir
/usr/bin/rsync -ah $bwlimit --delete /usr/local/ispconfig $basedir