Data Backup

Skenario Backup : Database dan aplikasi dibackup setiap hari jam 1.30 dini hari.

Buat file backup_ake.sh

#!/bin/bash

mysqldump --opt -h localhost -u username -ppassword nama_database | bzip2 -c > $1/nama_database.bak.sql.bz2

rsync -a /var/www/nama_app $2/www

rsync -a $1 $2

Buat entri di cron :

# m h dom mon dow command

30 1 * * 0 /home/ketahananpangan/bin/backup_ake.sh /home/backup/tmp/ /home/backup/ahad/

30 1 * * 1 /home/ketahananpangan/bin/backup_ake.sh /home/backup/tmp/ /home/backup/senin/

30 1 * * 2 /home/ketahananpangan/bin/backup_ake.sh /home/backup/tmp/ /home/backup/selasa/

30 1 * * 3 /home/ketahananpangan/bin/backup_ake.sh /home/backup/tmp/ /home/backup/rabu/

30 1 * * 4 /home/ketahananpangan/bin/backup_ake.sh /home/backup/tmp/ /home/backup/kamis/

30 1 * * 5 /home/ketahananpangan/bin/backup_ake.sh /home/backup/tmp/ /home/backup/jumat/

30 1 * * 6 /home/ketahananpangan/bin/backup_ake.sh /home/backup/tmp/ /home/backup/sabtu/

Referensi