Tuesday, January 5, 2016

Zimbra Mail server Full Backup | Backup Script for Zimbra Folder| Daily Full Backup Zimbra



Backup zimbra folder to external hardisk

  1. Log in to Zimbra server by root login 
  2. mkdir 1
  3. chmod -R 777 mailbackup
  4. cd /opt/                                     // access to opt folder 
  5. touch backup.sh
  6. chmod 777  backup.sh
  7. nano backup.sh
  8. paste the below coding  (Red coding)
  9. format your external hard disk to ext 4 format (Software:- mini partition)
  10. Plug your external hard disk to Zimbra mail server
  11. fdisk -l                  // identity the hard disk mount name such  /dev/sda1/  or  /dev/sdb1
  12. Example :- Disk /dev/sdb1: 160.0 GB, 160041885696 bytes
  13. As per hard disk mount name change the script according line 9 mount /dev/sdb1  /mailbackup or /dev/sda1/ mailbackup 
  14. At final run the script  ./backup.sh
  15. Press 'y' to perform the backup while backup zmcontrol service will be stop
  16. Additional before preform the backup please external hard disk is plugged and mount to correct drive letter.

----------------------------------------------------------------------------------------------------------------------------------
stty intr '^-' kill '^-' susp '^-' stop '^-' quit '^-'
s()
{
echo " Please press y to continue or n to quit :"
read ans;
if [ $ans  = "y" ]; then
su zimbra -c "/opt/zimbra/bin/zmcontrol stop"
sleep 60;
mount /dev/sdb1  /1
echo "BACKUP STARTa"
tar -cvf /1/backup.tar /opt/zimbra
echo "BACKUP COMPLETED"
sleep 60;
umount /1
su zimbra -c "/opt/zimbra/bin/zmcontrol start"
fi
}

restart()
{
echo " Do you really want to restart mail server if yes press y or n to quit :"
read ans;
if [ $ans  = "y" ]; then
        su zimbra -c "/opt/zimbra/bin/zmcontrol stop"
init 6;
        echo "Server Rebooting"
        echo ""
fi
}

menu()
{
option=""
        while ( true )
        do
                echo "\n\n"
  echo "          1 -> Take Backup             "
                echo "          2 -> Restart Server         "
                echo "          q -> QUIT\n                 "
                echo "      To select any of the options, enter the number"
                echo "      Enter your choice : \c"
                read option
                case $option in

                        1) s
;;
2) restart
                        ;;
'q'|'Q')        exit 0
                                ;;

                        *)      echo "Invalid option."
                                echo "Hit return for the menu ...\c"
                               read
                                ;;

                esac
        done
}
menu
------------------------------------------------------------------------------------------------------------

1 comment: