Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Member This forum account has been confirmed by cPanel staff to represent a vendor. aarondwyer's Avatar
    Join Date
    Mar 2005
    Location
    Brisbane
    Posts
    72

    Default Using rsync to enable automatic backup MX mail server domains

    Hi

    This is for the techies out there. So flex your techie muscle on this...

    I have a redundant mail server setup and I've got a crontab setup to rsync copy my /etc/localdomains on the primary to /etc/secondarymx on the fallback mail server.

    Like this from the backup mailserver crontab

    0 1 * * * rsync -e ssh -avz root@primaryserver:/etc/localdomains /etc/secondarymx 2>&1 > /var/log/nightly_email_backup.log

    However I'm noticing that the rsync takes a direct copy of the file from the primary server, but I thought it would just append by default.

    I have domains that I've manually put into the /etc/secondarymx on the backup server that keep dissapearing after the crontab has run. So the rsync is removing them as well as adding in the new domains.

    I just want the rsync to append the new domains that end up in the /etc/localdomains on the primary at the end of each day, whatever is in /etc/secondarymx can stay there even if the domains are removed from the primary.

    Does anyone know how I can do this with rsync or scp or whatever.?

    Thanks
    Aaron

  2. #2
    Member
    Join Date
    Nov 2006
    Posts
    76

    Default

    Seems like it might be as easy as creating a script that looks like this:
    rsync -e ssh -avz root@primaryserver:/etc/localdomains /tmp/secondarymx
    cat /etc/secondarymx >>/tmp/secondarymx
    cat /tmp/secondarymx |sort |uniq >/tmp/secondarymx.new
    mv /tmp/secondarymx.new /etc/secondarymx
    rm /tmp/secondarymx



    Then, put that script in cron and it should do what you want. Mine is probably not the only way to go, and there may be ways to optimize, but that's what I can pull out of my head at the moment.

  3. #3
    Member This forum account has been confirmed by cPanel staff to represent a vendor. aarondwyer's Avatar
    Join Date
    Mar 2005
    Location
    Brisbane
    Posts
    72

    Default

    Thank you I will try that out tonight, the logic looks very sound, and I'm sure that would work so I'll report back my results.

    Just a thought, doesn't rsync have an append function, would that work I wonder? I'll have to test that as well.

    Thanks
    Aaron

  4. #4
    Member
    Join Date
    Nov 2006
    Posts
    76

    Default

    rsync does have an append fucntion, but it doesn't do what you think. Here is the man page excerpt:
    --append
    This causes rsync to update a file by appending data onto the
    end of the file, which presumes that the data that already
    exists on the receiving side is identical with the start of the
    file on the sending side. If that is not true, the file will
    fail the checksum test, and the resend will do a normal
    --inplace update to correct the mismatched data. Only files on
    the receiving side that are shorter than the corresponding file
    on the sending side (as well as new files) are sent. Implies
    --inplace, but does not conflict with --sparse (though the
    --sparse option will be auto-disabled if a resend of the
    already-existing data is required).

    So, essentially, it is just another, more bandwidth efficient method to transfer the whole file.

    Note: my rough script above would not remove a domain that was deleted from secondarymx on primaryhost. Otherwise, I think it'll work too.
    Last edited by jerrybell; 08-09-2007 at 08:51 PM.

Similar Threads & Tags
Similar threads

  1. rsync Server Backup, Minor Issues After Restore
    By Magotchi in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 02-16-2011, 04:00 PM
  2. Rsync script for backup of cpanel server
    By zigzam in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 06-08-2009, 02:54 PM
  3. Backup alternative: rsync + external server
    By stormrider in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 02-05-2008, 10:18 PM
  4. rsync backup to my local Windows server - what should I install?
    By spaceman in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 10-26-2006, 05:14 PM
  5. rsync backup
    By bazzi in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 10-26-2004, 12:02 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube