I wrote a rsync script which uses find
command to find all files which are older than 10 minutes and copies them to a remote server.
The relevant part of the code is:
print_log "------ Starting $0 -------"
find $filedir -name \*.gz -mmin +10 >> $varfile
for line in $(awk -F"/" '{print $4}' $varfile); do
rsync -raPv --ignore-existing --remove-source-files --chmod=u+rwx $filedir/$line rsync://appuser@10.11.X.X/hpfiles/ --password-file /etc/rsync.passwd
done
The problem I have is related to the find command, when running the script I get the following response while it hangs there and won't continue:
[appadmin@srv01 ~]$ /nfs/hadooper/rsync_hpfiles-lock.sh >> /var/log/rsync_hpfiles.log
find: File system loop detected; `/mass1/hpfiles_staging/.snapshot' is part of the same file system loop as `/mass1/hpfiles_staging'.
find: File system loop detected; `/mass1/hpfiles_staging/.snapshot' is part of the same file system loop as `/mass1/hpfiles_staging'.
^C^Z
I've tried the following things but to no avail:
find $filedir -name \*.gz -a ! -name ".snapshot" -mmin +10 >> $varfile
find $filedir -name \*.gz -a ! -type d -name ".snapshot" -mmin +10 >> $varfile
find $filedir -name -a ! -path "*/.snapshot/*" \*.gz -mmin +10 >> $varfile
How does my command should look in order to be able to exclude the .snapshot
directory from the find command output?