Skip to content

Instantly share code, notes, and snippets.

@erayalakese
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erayalakese/7acbeb5e95cb02d0be26 to your computer and use it in GitHub Desktop.
Save erayalakese/7acbeb5e95cb02d0be26 to your computer and use it in GitHub Desktop.
Bir CentOS sunucuda ihtiyaç duyduğum yedekleri alması için bir çırpıda yazdığım bash script
#!/bin/bash
# gerekli paketleri kontrol et ve kur
if ! rpm -qa | grep -qw tar; then
yum -y install tar
fi
if rpm -qa | grep -qw mysql; then
# mysql yüklü, yedekle
mysqldump -uroot -p --all-databases > mysqlbackup.sql
echo "MySQL YEDEKLEME TAMAM"
else
echo "MySQL YOK, YEDEKLENMEDI"
fi
if crontab -l > cron-backup.txt
then
echo "CRON YEDEK TAMAM"
else
echo yedeklenemedi
fi
now="$(date +'%d%m%Y-%H%M%S')"
tar -cf YEDEK-$now.tar /var/www/html/ mysqlbackup.sql cron-backup.txt
rm -f mysqlbackup.sql cron-backup.txt
echo "DOSYA YEDEKLEME TAMAM"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment