Had a hard time using rsync today although I had used this so many times in the past. So I decided to take a note of what I missed. Scenario – pushing and syncing files from master to slave server.
Firstly, make sure you had rsync installed on both servers and not just on the master server. That’s the mistake I made by not installing rsync on the slave server.
sudo apt-get install rsync
Next problem I had was that both my servers were setup on AWS and only had secure login via my private key. So in order for rsync to work, I had to use the execute the ssh with the private key in order to rsync files to the other server. Important not here is that the -e (execute statement) must be the last one to be executed
rsync -av --exclude pg_xlog --exclude postgresql.conf /var/lib/postgresql/9.1/main/ --progress -e 'ssh -i /home/admin/.ssh/pgs-aws.pem' email@example.com:/var/lib/postgresql/9.1/main/