Last active
November 25, 2015 03:24
-
-
Save martip07/9b3e67c2c8a3d64375c1 to your computer and use it in GitHub Desktop.
rsync_servers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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