cronrsyncpostfix-mtadovecotmaildir

How do I setup an rsync cron job to synchronize Maildir?


I want to move to a new server and automate the process of moving the contents of Maildir/ keeping it synchronized up to the switch-over point by utilizing a cron job. I don't want to enable root login nor do I want to enable login for the LDA username, postalworker. The server is CentOS 5 running postfix/dovecot.

What is the best way to handle this? I already have public/private key ssh working for another username but how do I get around logging in as postalworker directly? The contents of Maildir/ are all owned by postalworker and seem to all have 0600 permissions. Thus, using group permissions would require resetting all the permissions. There must be an easier way that I'm missing. Any help is appreciated.


Solution

  • You could use rsync on the source server running as root

    run as root on source

     rsync -avz -e ssh --delete /stuff/ user@desktop ip:/home/laptop/stuff/
    

    If the destination user doesn't have the correct privileges could then run a rync cron as root then sync the directories

    So it would look like this at source

    */2 * * * * root rsync -avz -e ssh --delete /stuff/ user@desktop ip:/home/laptop/stuff/
    

    Then

    */10 * * * * root rsync -avz --delete /home/laptop/stuff /Maildir/