This is a discussion on Require shell script using rsync within the Shell scripting forums, part of the Development/Scripting category; Dear All. I require a shell script using rsync. I have two Linux servers both are identical. I want to ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
Dear All.
I require a shell script using rsync. I have two Linux servers both are identical. I want to copy data from one server to another server in every 1 hour using rsync and I want to put in Cron Script. I tried this but when I do rsync it asks for password even I give --password-file option but no luck. Example :- rsync -avz server1:/mail server2:/mail I wan to put this in cron scheduler , so it copy all data every day in a gap of one hour and this script should start every day after 6: PM and stop at 2 AM . Regards. Puppen |
| Sponsored Links | ||
|
|
|
||||
|
Replace your rsync command (assuming that you want to sync server1 with local server2)
Code:
rsync -avz server1:/mail server2:/mail Code:
rsync -avrR --links --rsh=/usr/bin/ssh server1:/mail :/mail Code:
ssh-keygen -t rsa ssh you@server1 "mkdir .ssh" scp .ssh/id_rsa.pub you@server1:.ssh/authorized_keys2 Code:
#!/bin/bash MASTER="server1" DIR="/mail" LDIR="/mail" SSH="/usr/bin/ssh" rsync -avrR --links --rsh=$SSH $MASTER:$DIR $LDIR Setup cronjob using following syntax: Code:
1 18,19,20,21,22,23,0,1,2 * * * /path/to/script.sh Read following docs for more info: How do I add jobs to cron under Linux or UNIX oses SSH Public key based authentication - How-to? How do I sync data between two Load balanced Linux/UNIX servers? if you have more question just reply back and we will be glad to assist you |
|
|||
|
Dear
Thanks a bunch for reply. But I am confused between 2 servers and which command runs on which server. Currently what I am doing is, I am running this command on server2 where I am taking back up i.e on server2 rsync -avz server1:/mail /mail the above command copy files from server1 to server2 One more thing I have so many dir in mail folder but I do not want to take backup of all dir except certain dir. in this case what should I do/ Regards. Puppen
__________________
someone somewhere is made for you. LOVE is Journey not a destination. ALL I want is EVERYTHING. |
|
||||
|
Quote:
Code:
rsync -avz --exclude '/mail/rocky' server1:/mail /mail file.txt Code:
/mail/rocky /mail/xyz /mail/dddd Code:
rsync -avz --exclude-from file.txt server1:/mail /mail
__________________
Rocky Jr. You may have my body & soul, but you will never touch my pride! If you have knowledge, let others light their candles at it. Certified to work on HP-UX / Sun Solaris / RedHat |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| rsync pls help | linuxmanjusha | Web servers | 1 | 10-23-2007 12:12 PM |
| writing a shell script to find out my shell name | jaymob123 | Shell scripting | 1 | 10-08-2007 01:36 AM |
| rsync folder | zafar466 | Shell scripting | 1 | 04-28-2007 04:28 AM |
| Require Shell Script Which sends all server info on mail | puppen | Linux software | 3 | 10-25-2006 09:07 PM |
| require shell script | puppen | Shell scripting | 4 | 04-12-2006 10:42 PM |