Install AutoMySQLBackup di Ubuntu

AutoMySQLBackup adalah aplikasi untuk mem-backup automatis database yang ada di MySQL, aplikasi ini memudahkan kita dalam pengerjaan mem-backup database perhari, perminggu dan perbulan. Selain itu aplikasi ini bisa mengirim hasil backup ke email yang sudah di setting sebelumnya.

1. Download aplikasi AutoMySQLBackup

Anda bisa download aplikasi di sini setelah selesai mendownload anda unpuck :

$ tar zxvf automysqlbackup-v3.0_rc6.tar.gz

dan directory automysqlbackup-v3.0_rc6 akan terbuat terdiri dari : automysqlbackup, automysqlbackup.conf, CHANGELOG, install.sh, LICENSE, and README.

2. Install aplikasi AutoMySQLBackup

Selanjutnya install aplikasi automysqlbackup, masuk ke terminal console linux, masuk ke directory automysqlbackup misal :

$ cd /home/admin/automysqlbackup-v3.0_rc6

$ sudo ./install.sh

akan muncul seperti ini : Select the global configuration directory [/etc/automysqlbackup]:

isi sesuai contoh misal : /etc/automysqlbackup lalu enter.

akan muncul juga : Select directory for the executable [/usr/local/bin]:

isi sesuai contoh misal : /usr/local/bin lalu enter.

Selesai Installasi, install detail seperti di bawah ini :

### Checking archive files for existence, readability and integrity.

automysqlbackup … exists and is readable … md5sum okay🙂
automysqlbackup.conf … exists and is readable … md5sum okay🙂
README … exists and is readable … md5sum okay🙂
LICENSE … exists and is readable … md5sum okay🙂

Select the global configuration directory [/etc/automysqlbackup]: /etc/automysqlbackup
Select directory for the executable [/usr/local/bin]: /usr/local/bin
### Creating global configuration directory /etc/automysqlbackup:

success

### Copying files.

if you are running automysqlbackup under the same user as you run this install script,
you should be able to access it by running ‘automysqlbackup’ from the command line.
if not, you have to check if ‘echo $PATH’ has /usr/local/bin in it

Setup Complete!

Aplikasi sudah bisa digunakan, sekarang sebelum program kita jalankan terlebih dahulu kita konfigurasikan.

3. Konfigurasi aplikasi AutoMySQLBackup

Konfigurasikan aplikasi automysqlbackup supaya maksimal dalam pengerjaannya nanti, adapun konfigurasinya seperti di bawah ini :

$ sudo vi /etc/automysqlbackup/myserver.conf
 
Bagian yang penting di rubah adalah :
# Username to access the MySQL server e.g. dbuser
CONFIG_mysql_dump_username='db_user'
# Password to access the MySQL server e.g. password
CONFIG_mysql_dump_password='db_password'

Configurasi di atas untuk koneksi aplikasi ini ke MySQL Server, db_user di ganti dengan user di MySQL dan
db_password di ganti password MySQL.

# Host name (or IP address) of MySQL server e.g localhost
CONFIG_mysql_dump_host='localhost'
# Backup directory location e.g /backups
CONFIG_backup_dir='/home/admin/backup_db'

Configurasi di atas untuk alamat hosting misal “localhost” dan alamat backup di “/home/admin/backup_db
 
# List of databases for Daily/Weekly Backup e.g. ( 'DB1' 'DB2' 'DB3' ... )
# set to (), i.e. empty, if you want to backup all databases
CONFIG_db_names=('contoh_db')
# List of databases for Monthly Backups.
# set to (), i.e. empty, if you want to backup all databases
CONFIG_db_month_names=('contoh_db')
# List of DBNAMES to EXLUCDE if DBNAMES is empty, i.e. ().
CONFIG_db_exclude=('information_schema' 'contoh_db' )
 
Configurasi di atas untuk nama database yang mau di backup.
 
# Which day do you want monthly backups? (01 to 31)
# If the chosen day is greater than the last day of the month, it will be done
# on the last day of the month.
# Set to 0 to disable monthly backups.
CONFIG_do_monthly="03"
# Which day do you want weekly backups? (1 to 7 where 1 is Monday)
# Set to 0 to disable weekly backups.
CONFIG_do_weekly="6"
# Set rotation of daily backups. VALUE*24hours
# If you want to keep only today's backups, you could choose 1, i.e. everything older than 24hours will be removed.
CONFIG_rotation_daily=7
# Set rotation for weekly backups. VALUE*24hours
CONFIG_rotation_weekly=14
# Set rotation for monthly backups. VALUE*24hours
CONFIG_rotation_monthly=30

Configurasi di atas untuk lama backup bisa perhari, perminggu atau perbulan.
# What would you like to be mailed to you?
# - log   : send only log file
# - files : send log file and sql files as attachments (see docs)
# - stdout : will simply output the log to the screen if run manually.
# - quiet : Only send logs if an error occurs to the MAILADDR.
CONFIG_mailcontent='log'
# Email Address to send mail to? (
 user@domain.com)CONFIG_mail_address='
 carla@tuxcomputing.com'

Configurasi di atas untuk setting email untuk pengiriman file via email.
 
4. Menjalankan program aplikasi
 
Untuk menjalankan program aplikasi automysqlbackup gunakan script ini :
$ sudo automysqlbackup /etc/automysqlbackup/myserver.conf
masuk ke directory ini :
 
$ ls /home/admin/backup_db/
daily/  
fullschema/  
latest/  
monthly/  
status/  
tmp/  
weekly/
5. Buat sceduler crond job
Buat script yang berisi :
 
#!/bin/sh
/usr/local/bin/automysqlbackup /etc/automysqlbackup/myserver.conf
chown root.root /home/admin/backup_db* -R
find /home/admin/backup_db* -type f -exec chmod 400 {} \;
find /home/admin/backup_db* -type d -exec chmod 700 {} \;
 
Save script dengan nama : “backupscript”
 
# chmod 755 backupscript
 
# crontab -e
 
0 20 * * * /usr/local/bin/backupscript
 
# /etc/init.d/crond restart
 
Aplikasi sudah siap jalan dengan normal.
 
Terimakasih
Efran Karunia
https://efrankarunia.wordpress.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s