physical Backup of database directory/var/lib/mysql every 3 days back up the data to the system/opt/dbbak directory
#!/bin/bash
Day= ' date+%y-%m-%d '
Size= ' Du-sh/var/lib/mysql '
Cd/opt/dbbak 2>/dev/null | | Mkdir/opt/dbbak
echo "Date: $DAY" >/opt/dbbak/dbinfo.txt
echo "Total Database Size: $SIZE" >>/opt/dbbak/dbinfo.txt
Tar-zcf/opt/dbbak/mysqlbak-${day}.tgz/var/lib/mysql/opt/dbbak/dbinfo.txt &>/dev/null
Rm-rf/opt/dbbak/dbinfo.txt
: Wq
chmod+x/shell/mysqlbak.sh
Crontab-e
*/3 * */shell/mysqlbak.sh
Service Cornd Start
2#!/bin/bash
Cp-a/var/lib/mysql/tmp/backup/' Date +%f%h%m '
3
2
[Root[email protected] desktop ]# chmoda+x/myslbk.sh
[[email protected] Desktop ]# cat/myslbk.sh
#!/bin/bash
tarpzcfp/tmp/sqlbak/mysql-' Date +%f%h%m '. Tar.gz/var/lib/mysql
[[email protected] Desktop ]# crontab-l
* * */3 * * tarpzcfp/myslbk.sh
#!/bin/bash
Day= ' date+%f '
Size= ' du-sh/var/lib/mysql/'
Bakdir=/opt/dbbak
Cd$bakdir | | mkdir $bakdir
echo ""
TAR-ZCVF dbbak-${day}.tar.gz/var/lib/mysql/*
Script-/var/lib/mysql every 3 days to a physical backup of the database directory to back up the data to the system/opt/dbbak directory