I've got a server where I do my web development and testing, and I have a bunch of frontend servers that sit behind a load balancer. I wrote a simple bash script to rsync a directory on my dev server to all of the production servers when I fix a bug, etc.
The rsync APPEARS to work, but when I actually go to the other servers, none of the files have been updated. What am I doing wrong?
#!/bin/bash
directory=$1
echo "$directory"
set -x
for host in "xxx.xxx.xxx.xxx"
do
rsync -avz -e ssh ${directory} root@${host}:${directory}
done
At the moment I only have one ip address in the for loop, but I'll be adding more as time goes on. This is how I'm executing the script and the abbreviated output:
[root@admin vhosts]# ./rsync_to_frontend.sh /var/www/scripts
/var/www/scripts
+ for host in '"xxx.xxx.xxx.xxx"'
+ rsync -avz -e ssh /var/www/scripts [email protected]:/var/www/scripts
sending incremental file list
scripts/
scripts/fetchTweets.php
scripts/syncMediaFiles.log
scripts/syncMediaFiles.php
.....
sent 7395053 bytes received 1252 bytes 2113230.00 bytes/sec
total size is 36718000 speedup is 4.96
[root@admin vhosts]#
If I run the command again, rsync appears to work appropriately and as expected does not show any files in the list, ostensibly because they've all been updated. However, when I go and look at the files on server xxx.xxx.xxx.xxx, they haven't been updated at all.
find
it in the destination, I think you are looking at (copying) to the wrong folderrsync -av /src/foo /dest
,rsync -av /src/foo/ /dest/foo