Results 1 to 2 of 2
Hi All, I need to transfer my daily backups from remote source to remote destination if only directories are not empty because source have 10 directories and some time some ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 01-04-2012 #1
- Join Date
- Nov 2010
Transfer files between source and destination
I need to transfer my daily backups from remote source to remote destination if only directories are not empty because source have 10 directories and some time some directories get empty so no need to copy those directories. simply I used rsync command for this purpose but I cant validate empty folders using rsync, can any one give some idea for this (different method more Appreciated).
"rsync -v -dn $S_LOGIN:$download_path/ 11_30_Nov_12-36/"
- 01-04-2012 #2
- Join Date
- May 2011
What's the harm in doing an rsync of an empty directory?
Anyway, is it the $download_path directory that might be empty? Is it files that it will contain, or subdirectories, or both?
I assume you have ssh keys set up already (so you are not prompted for a password)? If so, then you could generate a list and see if the list is empty before doing the rsync, e.g.:
#!/bin/bash files=$(ssh $S_LOGIN find $download_path -maxdepth 1 -type f) if [ -n "$files" ]; then rsync ... fi