BASH sync a folder on multiple servers
The script will copy all the files from a folder on multiple servers.
If you run it in cron at every 5 minutes you will make sure that the files that are new on one of the servers will be copied on all the servers.
by darie 2 years, 4 months ago and tagged with: backup bash rsync sync
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#!/bin/bash # Path for the file containing the servers ips SERVERS='/home/user/servers' USER="user" DIR='/home/user/public_html/files' OPTS="--archive --perms --update --rsh=ssh " # don't consume all the bandwidth local_path='/path/whatever/folder' # the path to the folder that will be copied on all servers remote_path='/path/to/remote/folder' /# the path of the folder where the folder to be copied on the remote servers for i in `cat $SERVERS`;do rsync $OPTS $local_path $USER@$i:$remote_path ssh $USER@$i "chmod 777 $DIR" # will execute chmod 777 after the folder is copied done; |

Currently 0 comments