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 #1Just Joined!
- Join Date
- Nov 2010
- Posts
- 26
Transfer files between source and destination
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 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/"
thanks.
- 01-04-2012 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,664
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.:
So the above ssh command would generate a list of files in the remote directory, and only call rsync if not empty. You might have to do some SSH-related things to make sure you're not getting anything else sent to STDOUT/STDERR and creating a false-positive.Code:#!/bin/bash files=$(ssh $S_LOGIN find $download_path -maxdepth 1 -type f) if [ -n "$files" ]; then rsync ... fi


Reply With Quote
