username and password for rsync in script

Posted by sims on Server Fault See other posts from Server Fault or by sims
Published on 2010-03-29T07:31:31Z Indexed on 2010/03/29 7:33 UTC
Read the original article Hit count: 325

Filed under:
|
|
|
|

I'm creating a cron job to keep two dirs in sync. I'm using rsync. I'm running an rsync daemon. I read the manual and it says:

   RSYNC_PASSWORD
          Setting  RSYNC_PASSWORD  to  the required password allows you to
          run authenticated rsync connections to an rsync  daemon  without
          user  intervention. Note that this does not supply a password to
          a shell transport such as ssh.

   USER or LOGNAME
          The USER or LOGNAME environment variables are used to  determine
          the  default  username  sent  to an rsync daemon.  If neither is
          set, the username defaults to 'nobody'

I have something like:

#!/bin/bash
USER=name
RSYNC_PASSWORD=pass
DEST="server::module"

/usr/bin/rsync -rltvvv . $DEST

I also tried exporting (dangerous, I know) USER and RSYNC_PASSWORD. I also tried with LOGNAME. Nothing works. Am I doing this correctly?

© Server Fault or respective owner

Related posts about bash

Related posts about rsync