How to setup automysql backup/dump scripts for regular backups

    Posted in Linux Servers on Jul 30, 2018

    First download it via following link :-

    root@cloudtechtiq.com:~$ wget http://ncu.dl.sourceforge.net/project/automysqlbackup/AutoMySQLBackup/AutoMySQLBackup%20VER%203.0/automysqlbackup-v3.0_rc6.tar.gz

    Create a directory in /root named as automysqlbackup and Unzip file :-

    root@cloudtechtiq.com:~$ tar zxvf automysqlbackup-v3.0_rc6.tar.gz /root/automysqlback

    After unzip install that file :-

    root@cloudtechtiq.comk:~$ sh install.sh

    -> Press enter

    -> Press enter

    then open:- /etc/automysqlbackup/automysqlbackup.conf

    root@cloudtechtiq.com:~$ vim /etc/automysqlbackup/automysqlbackup.conf
    make following changes in file

    -- CONFIG_mysql_dump_username='root'

    -- CONFIG_mysql_dump_password='web@123'

    -- CONFIG_mysql_dump_host='localhost'

    -- CONFIG_backup_dir='/autobackup' //don’t forget that you hav to create this directory

    -- CONFIG_multicore='no'

    -- CONFIG_db_names=()

    -- CONFIG_db_month_names=()

    -- CONFIG_db_exclude=('information_schema' 'test' 'mysql')

    -- CONFIG_do_monthly="01"

    -- CONFIG_do_weekly="1"

    -- CONFIG_rotation_daily=2

    -- CONFIG_rotation_weekly=14

    -- CONFIG_rotation_monthly=30

    -- CONFIG_mailcontent='log'

    -- CONFIG_mail_address='sachin@gmail.com,raviraj@gmail.com'

    Run following command(For taking backup locally in /autobackup folder)

    root@cloudtechtiq.com:~$ automysqlbackup

    cronjob settings :-

    A :- create a file :-

    root@cloudtechtiq.com:~$ vim /etc/automysqlbackup/autobackup.sh

    B :- Put this script in this file :-

    #!/bin/sh
    /usr/local/bin/automysqlbackup /etc/automysqlbackup/automysqlbackup.conf 
    chown root.root /autobackup/db* -R 
    find /autobackup/db* -type f -exec chmod 400 {} \;
    find /autobackup/db* -type d -exec chmod 700 {} \;
    :wq

    C :- Give execut permission to that file :-

    root@cloudtechtiq.com:~$ chmod +x autobackup.sh

    D :- Than put entry in crontab for automatically running backup according to given timing :-

    root@cloudtechtiq.com:~$ crontab -e
    
    0 0 * * * /etc/automysqlbackup/autobackup.sh
    :wq

    E :- Restart the crond service for validate changes :-

    root@cloudtechtiq.com:~$ service crond restart

    If you want to send backup on another Server than follow Below Commands :-

    Install EPEL repository for CentOS 6:-
    root@cloudtechtiq.com:~$ wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    
    root@cloudteh.com:~$ sudo rpm -Uvh epel-release-6*.rpm
    After which you can install NcFTP:
    root@cloudtechtiq.com:~$ yum install ncftp -y
    Send backup on Destination server :-
    root@cloudtechtiq.com:~$ ncftpput -u Destination-username -p Dest.-password -Rm Destination-hostname/IP /Path on Destination server /autobackup/*
    Now or regular backup according to time (time,daily,weekly,monthly) follw below commands:-

    A :- create a script :-

    root@cloudtechtiq.com:~$  vim back.sh

    put this command in this :-

    ncftpput -u Destination-username -p Dest.-password -Rm Destination-hostname/IP /Path on Destination server /autobackup/*
    :wq

    B :- Give execute permission to script :-

    root@cloudtechtiq.com:~$  chmod +x back.sh

    C :- add cron job for this script :-

    root@cloudtechtiq.com:~$ crontab -e
    
    30 9 * * * sh /root.back.sh

    send backup daily at 9.30 A.M

    Now on daily basis your backup will be automatically generate and will send to your destination server..