Linux / UNIX Tech Support Forum
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 ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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
__________________
Vivek Gite Linux Evangelist |
|
|||
|
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. |
|
|||
|
Dear All
Thanks a bunch, Ya I have got it. This script works properly. regards. Puppen
__________________
someone somewhere is made for you. LOVE is Journey not a destination. ALL I want is EVERYTHING. |
![]() |
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 | 23-10-2007 11:12 AM |
| writing a shell script to find out my shell name | jaymob123 | Shell scripting | 1 | 08-10-2007 12:36 AM |
| rsync folder | zafar466 | Shell scripting | 1 | 28-04-2007 03:28 AM |
| Require Shell Script Which sends all server info on mail | puppen | Linux software | 3 | 25-10-2006 08:07 PM |
| require shell script | puppen | Shell scripting | 4 | 12-04-2006 09:42 PM |