rm -f /yedek/*.*
DATABASE="$($(which mysql) -u root -h localhost -pVERITABANI_SIFRESI -Bse 'show databases')"
for db in $DATABASE
do
if [[ ${db: 0:11} != "information" ]] && [[ ${db: 0:7} != "cphulkd" ]] && [[ ${db: 0:5} != "horde" ]] &&
[[ ${db: 0:12} != "leechprotech" ]] && [[ ${db: 0:5} != "modsec" ]] && [[ ${db: 0:9} != "roundcube"]] && [[
${db: 0:5} != "mysql" ]]; then
echo "veri_tabani.$db.gz"
$(which mysqldump) -u root -h localhost -VERITABANI_SIFRESI $db | $(which gzip) -9 > /yedek/"veri_tabani.$db.gz"
fi
done
for hesap in $(ls /home);
do
if [[ ${hesap: 0:5} != "MySQL" ]] && [[ ${hesap: 0:3} != "tmp" ]] && [[ ${hesap: 0:2} != "cp"
]]; then
echo "/home/$hesap"
tar -czPf /yedek/"dosyalar.$hesap.gz" "/home/$hesap"
fi
done
DATABASE="$($(which mysql) -u root -h localhost -pVERITABANI_SIFRESI -Bse 'show databases')"
for db in $DATABASE
do
if [[ ${db: 0:11} != "information" ]] && [[ ${db: 0:7} != "cphulkd" ]] && [[ ${db: 0:5} != "horde" ]] &&
[[ ${db: 0:12} != "leechprotech" ]] && [[ ${db: 0:5} != "modsec" ]] && [[ ${db: 0:9} != "roundcube"]] && [[
${db: 0:5} != "mysql" ]]; then
echo "veri_tabani.$db.gz"
$(which mysqldump) -u root -h localhost -VERITABANI_SIFRESI $db | $(which gzip) -9 > /yedek/"veri_tabani.$db.gz"
fi
done
for hesap in $(ls /home);
do
if [[ ${hesap: 0:5} != "MySQL" ]] && [[ ${hesap: 0:3} != "tmp" ]] && [[ ${hesap: 0:2} != "cp"
]]; then
echo "/home/$hesap"
tar -czPf /yedek/"dosyalar.$hesap.gz" "/home/$hesap"
fi
done
Yukardaki kodu yedek_al.sh seklinde kaydettikten sonra bir cron job yardımı ile rutin olarak yapılmasını sağlıyoruz.
Önce crontab -e komutuyla cron job listesine ulaşıyoruz
En alt satıra şu eklemeyi yapıyoruz:
40 06 * * * bash /home/yedek_al.gz
Yukarıda hergun saat 06:40 ta yedek almasını istemiş olduk sistemden.

Kaynaklar
- http://www.cyberciti.biz/faq/ubuntu-linux-mysql-nas-ftp-backup-script/
- http://www.mickgenie.com/blog/linux-shell-script-to-backup-mysql-database-to-remote-server/
- http://codeghar.wordpress.com/2008/10/19/problem-running-bash-script-in-cron/
- http://www.mickgenie.com/blog/linux-shell-script-to-backup-mysql-database-to-remote-server/
- http://www.jarrodgoddard.com/linux-web-hosting/a-linux-backup-script-using-the-bash-shell
- http://www.linuxquestions.org/questions/linux-general-1/bin-tar-removing-leading-%60-from-member-names-269508/
- https://help.ubuntu.com/8.04/serverguide/C/backup-shellscripts.html







