Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 11th November 2010, 16:33
Newton.Tricko.Com.Br Newton.Tricko.Com.Br is offline
Junior Member
 
Join Date: Nov 2010
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Thumbs up Howto create a MX Backup to your ISPConfig 2 with automatically sync

Dear all,

I am so happy now to say: that is my first post and my first contribuition to ISPConfig project.

I hope it may help somebody to do that more fast than normal, that is my proposal.

What you will receive at end of this Howto is a MX backup to your hosted domains over the main ISPConfig 2.

I hope you know, but never is too much say again, what you need.

1 - You need a complete ISPConfig 2 operating and running
2 - Another machine with Postfix installed and running, you just need Postfix running at that other machine, that machine will be the MX backup.

Letīs get started!

The steps bellow must be followed on the ISPConfig2 machine.

1 - First, create a new user on your MySQL server named "isp-mx-backup".

2 - Be carefull with the privileges, allow access from the other machine only then grant permission to SELECT on ISPConfig2 database and "isp_isp_web" table.

The steps bellow must be followed on the other machine with Postfix.

1 - Create the query domains script at /root/ispconfig/getMXDomains.php:
Code:
#!/usr/bin/php
<?
  $ispconfigHost = '192.168.0.1'; // set the IP or HOSTNAME to your ISPConfig2
  $ispconfigUser = 'isp-mx-backup'; // change if you created another username than the sugestted
  $ispconfigPass = 'password'; // change to the password of the user
  $ispconfigBase = 'db_ispconfig'; // change to the database name of ISPConfig2

/* No changes needed for the next lines */

  mysql_connect($ispconfigHost,$ispconfigUser,$ispconfigPass) or die('Cannot connect');
  mysql_select_db($ispconfigBase) or die('Cannot select db');
  
  $sql = "SELECT `web_domain` domain FROM `isp_isp_web` WHERE `web_dns_mx`=1";
  $query = mysql_query($sql);
  $num = mysql_num_rows($query);
  if ($num>0){
    $conf = "relay_domains=\"\\\$mydestination";
    while ($data = mysql_fetch_assoc($query)) {
        $conf .= ",{$data['domain']}";
    }
    $conf .= "\"";
  }
  exec("postconf -e {$conf}");
  exec("postconf -e relay_recipient_maps=\"\"");
  exec("/etc/init.d/postfix reload");
  
  mysql_close();
?>
Obs: You may change the interpreter line to the properly path to PHP, if you are not using CentOS distro or RedHat based distro.

2 - Grant execution permission to this script
Code:
chmod +x /root/ispconfig/getMXDomains.php
3 - Put this script to your cronjob
Code:
* */01 * * * /root/ispconfig/getMXDomains.php
4 - Now after create a new domain you must create a new MX entry, the priority must be high then the primary (your ISPConfig 2).

Feel free to comment.

I hope it helps!

Regards!

Last edited by Newton.Tricko.Com.Br; 11th November 2010 at 17:13. Reason: Forget the one step
Reply With Quote
The Following User Says Thank You to Newton.Tricko.Com.Br For This Useful Post:
falko (12th November 2010)
Sponsored Links
Reply

Bookmarks

Tags
backup, ispconfig 2, postfix

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Version 1.3 of the ISPConfig 3 Manual is finally available! falko General 44 2nd December 2011 12:04
Howto Create Multiple Symlinks by Default billcouper81 Tips/Tricks/Mods 5 18th March 2010 08:01
Online Backup : What do you use and how do you setup it ? XZed Technical 5 4th January 2010 18:02
ISPConfig 2 - ISPConfig 3 backup compatibility Up2NoGood General 3 27th February 2009 12:31
Don't Backup, ispconfig, function? misterm Installation/Configuration 3 26th October 2005 11:52


All times are GMT +2. The time now is 20:00.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.