Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reverse Scripting 1

Status
Not open for further replies.

fmuquartet

Programmer
Sep 21, 2006
60
US
Can some help modify a script that initially initiated on the client as shown below? The idea now, is that I need to run this script on the server for connecting out to the servers, because of new security policies.

Script:
#!/usr/bin/sh
/usr/local/bin/rsync -e ssh -avz --delete --rsync-path=/usr/local/bin/rsync | (cd /some/dir && find server*/log/dir* -mtime -1 -print) --files-from=- /some/dir server:/app/logs/dir


Thanks in advanced,
 
Are you sure you copied that correctly? The syntax looks wrong to me, especially the appearance of the "|" in the middle of the rsync options.

Annihilannic.
 
Annihilannic, this script works fine. Presently, remote machine are connect to a local machine via this script and dumping the most current file in /some/dir (-mtime -1), the problem now is having the local machine run this script in reverse (connecting out to remote machines and doing the same thing). If there is a more effective way on doing this, then I am open for suggestions.

Thanks,
 
What operating system is this running on? As I expected, when I try to run that command I get a syntax error from the shell.

Annihilannic.
 
Currently, I am running the script on HPUX, but it should work on and *NIX flavor I would expect with some modifications.

Thanks.
 
Maybe I have not been clear here, but all I am wanting to do is pull **specific* (files modified in one day) files from a **remote** machine's directory.

I am working on something like this, but am having luck:
/usr/local/bin/rsync -e ssh -avz --delete --rsync-path=/usr/local/bin/rsync --files-from=- /some/dir remoteuser@martins:/home/remoteuser | find server*/adhoc/remotedir* -mtime -1 -print /local/dir/

Thanks.
 
I think you want something more like this:

[tt]ssh remoteuser@martins 'find /some/dir/server*/adhoc/remotedir* -mtime -1' | /usr/local/bin/rsync -e ssh -avz --delete --rsync-path=/usr/local/bin/rsync --files-from=- remoteuser@martins:/ /local/dir/'[/tt]

However that is completely untested, so... no guarantees. But the main point is that you will need to ssh to the remote server to obtain the file listing, otherwise the find command will be running on the local host.

Annihilannic.
 
Annihilannic,
This looks like it should work but I am not having any look with it, when I run it I see in the shell "building list" although no files are coming over.

Appreciate the effort, I will let you know if anything changes.
 
This syntax seems to work for me to synchronise files less than a day old from /tmp/test on the remote system to the local system:

[tt]ssh remoteuser@martins 'cd /tmp && find test -mtime -1' | /usr/local/bin/rsync -e ssh -avz --delete --rsync-path=/usr/local/bin/rsync --include-from=- --exclude '*' remoteuser@martins:/tmp/ /tmp[/tt]

Note that there does not appear to be a --files-from option in the version of rsync I'm using (2.5.7), what version do you have?

Annihilannic.
 
Annihilannic,
Seems like it is try to work now, only problem is that I running a find with wild card (cd /tmp && find test*/log -mtime -1) that seems to causing problems. I can use the --include-from flag if it will get the files over to my local server, as a replacement from --files-from.

Version:
rsync version 2.6.3 protocol version 28
Copyright (C) 1996-2004 by Andrew Tridgell and others
<
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top