Reputation: 207
Could you please someone suggest , how to stop the infinite loop and exclude the directory from the below script ( Here i have to exclude only the logs). Once if the files are copied from source to destination, then the loop should be stopped.
#!/bin/bash
source=/home/ec2-user/source
dest=/home/ec2-user/destination
while true; do
rsync -arv --exclude '/home/ec2-user/source/IntegrationServer/instances/default/logs' $source/ $dest
sleep 1
done
Upvotes: 1
Views: 222
Reputation: 6076
This works as expected. You can add the while loop if you wish for it to continue forever.
#!/bin/bash
source=/home/ec2-user/source
dest=/home/ec2-user/destination
rsync -arv --exclude IntegrationServer/instances/default/logs $source/ $dest
The exclude needs to be relative to the source. So I removed the part common to the source.
Upvotes: 1