Combine 2 rsync scripts into one by using a generic pattern

Viewed 15

I have a BASE/ directory in server1 that contains folders in YYYYMMDD format. Every day a new folder is created for that day and some files are being written into it intraday.

I have two processes running on server2, one runs every 5 mins and tries to rsync last 2 days worth of data from server1:BASE/ and another one runs once a day and tries to rsyncs directories for the current year (using $(date "+%Y*") as a pattern).

I don't want to maintain 2 separate scripts for these tasks. I wonder if my script can support a pattern parameter, that I can pass to rsync to copy either last 2 days or all directories for the current year. Note that I want the parameter to specify a dates pattern that I can pass to rsync, not a flag that will specify the logic of the code with branching.

0 Answers
Related