Skip to content

Instantly share code, notes, and snippets.

@martip07
Last active November 25, 2015 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martip07/9b3e67c2c8a3d64375c1 to your computer and use it in GitHub Desktop.
Save martip07/9b3e67c2c8a3d64375c1 to your computer and use it in GitHub Desktop.
rsync_servers
#!/bin/bash
backend_list=/usr/local/backends.list
cat $backend_list | while read backend;
do
rsync -avz /my/file/location/file.txt root@$backend:/my/servers/location/file.txx
done
1. Create id_rsa.pub key on server with file edited if you don't have one.
ssh-keygen -t rsa
(type enter to all questions)
2. Copy id_rsa.pub file to servers
ssh-copy-id root@remoteserverip (1.1.1.1, 2.2.2.2, 3.3.3.3, etc). Do it with each single server.
Type yes and enter when is required.
3. create the file on your current server with the file edited
nano /usr/local/backends.list or vim /usr/local/backends.list or vi /usr/local/backends.list
- Add youre remote server IP's, line by line.
8.8.8.8
4.4.4.4
1.1.1.1
etc
4. Create the sync script.
nano sync.sh or vim sync.sh or vi sync.sh
- Copy the code aboive.
5. Give exec. permissions to sync file
chmod +x sync.sh
6. Exec script.
sh sync.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment