LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   writing a script using find and rsync stuck at some issues (https://www.linuxquestions.org/questions/linux-newbie-8/writing-a-script-using-find-and-rsync-stuck-at-some-issues-4175546804/)

lexian 06-30-2015 08:08 AM

writing a script using find and rsync stuck at some issues
 
Hi
What I'm trying to do is to have a script that search for a file changed last day than rsync the file and its parent directory.
Tried for the past month or two. read about
https://gist.github.com/evgenius/6019316
https://github.com/drunomics/syncd
https://github.com/gregghz/Watcher
as well as incron,incorntab,iwatch,inotify and many more (I just used google), before I landed on trying to write the script because of the main reason being. The parent directory is unknown and randomly generated each day, so I wanted to use wild cards e.g. /path/*/filename.txt but the use of wild cards in path is not supported on those scripts I read or I'm to newbie to figure it out anyway the script so far is this:
I will be running this with incron daily.
#!/bin/sh
find /parent-path-to-unknown-dir -name "filename.txt" -type -f -mmin -$((60*24)) -exec rsync --ignore-exsiting -azR --log-file=/path/ {} /source /destination \;


I'm truly grateful for any pointers and maybe there is even a better way to accomplish the same thing.

procfs 06-30-2015 12:10 PM

Hi hope this will help but I amy be wrong there is no restrictions in while-cards in shell scripts, I am using them all the time (not that I am an expert script writer)

lexian 07-01-2015 01:58 AM

Quote:

Originally Posted by procfs (Post 5385140)
Hi hope this will help but I amy be wrong there is no restrictions in while-cards in shell scripts, I am using them all the time (not that I am an expert script writer)

Hi
Yes you are correct on that, and that is why I'm trying to use script.
What I need helping to figure out is, if there is a way for rsync to sync the file and the parent folder of the find command.
#this command I find the file called filename.txt that is newer than a day.
find /path/ -name "filename.txt" -type f -mmin -$((60*24))

Than I need rsync to sync not just the file "filename.txt" but also the parent folder.
just not sure how i do this last part?


All times are GMT -5. The time now is 08:40 PM.