Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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/"


  2. #2
    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.:
    files=$(ssh $S_LOGIN find $download_path -maxdepth 1 -type f)
    if [ -n "$files" ]; then
      rsync ...
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts