I have a list of directories and files that I need to migrate. The directory tree looks something like:
-var
-data
-archive
-111111
-logs
datetime.log
meter.txt
-222222
-logs
datetime.log
meter.txt
-configurations
-rules
config.json
-recycle
When copying, it should satisfy the below conditions:
configurations
directory. Get all contents under configuration irrespective of its creation/modification date time.)recycle
.archive
. That means do not copy directories var
, data
& archive.
After copying the directory should look something like this:
-target
-111111
-logs
datetime.log
meter.txt
-222222
-logs
datetime.log
meter.txt
-configurations
-rules
config.json
I came up with this:
find var/data/archive ! -path "*/recycle*" \( -path "*/configurations*" -o -name "*" -mtime -30 \) | rsync -av --inplace --files-from=- . target
I am able to achieve the first 2 conditions, i.e. copying files that are less than 30 days and excluding the directory recycle
. But not able to exclude var/data/archive
. How do I fix this?
This worked for me.
cd ${HOME}/var/data/archive;\
find . ! -path "*/recycle*" \( -path "*/configurations*" -o -name "*" -mtime -10 \) | rsync -av --inplace --files-from=- . ${HOME}/target