?
Solved

Rsync to list files that did not get copied to destination directory

Posted on 2014-09-15
9
Medium Priority
?
570 Views
Last Modified: 2014-09-18
rsync -avzh path/to/directory/A/ path/to/directory/B

The above commands copies everything under directory A to directory B. Sometimes during the copy the files in destination B are locked by some other process which makes the copy incomplete. Is there a way in Rsync to list all such locked files that did not get copied over to the destination.
0
Comment
Question by:gaurav sharma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40323400
Add "--dry-run" to the options of your command.

rsync will tell you which files are still to be copied without actually transferring anything.
0
 

Author Comment

by:gaurav sharma
ID: 40323519
Dry run gives me the list of all the objects that get copied to the destination.
I only need the list of files that are not transferred from source.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 1200 total points
ID: 40323542
Since rsync (the way you use it) will copy only files which do not yet exist (or are newer than those) on the destination "--dry-run" should do what you desire. In other words, "--dry-run" will list only files or file versions that have not been transferred from source yet.
If you don't want to see files which have been created or modified in the meantime (after the failed run but before "--dry-run") on the source I fear you will have to rely on the error log of the previous (failed) run in question to find out the non-copied files.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40324255
Try adding a log file and check that you've run the rsync command:

--log-file=FILE
0
 
LVL 13

Expert Comment

by:Sandy
ID: 40324578
Gaurav.. but i would suggest doing the rsync on open files won't be done.. i tried it numerous times but always it has a need of downtime to get the migration done.

I would suggest take the downtime with app owner and do the rsync, else open or locked files will always be acting like this only.

Ty/SA
0
 

Author Comment

by:gaurav sharma
ID: 40328223
Thank you for all the comments. I have a folder of size 4 gb that needs to be copied to a location. It should overwrite everything each time on the destination. The copy fails many a times since the files in the destination are locked. I need something that would tell me which files could not be copied due to that encountered lock.
0
 

Author Comment

by:gaurav sharma
ID: 40328225
The copy can be done using cygwin or windows.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40328232
Consult the logfile, I keep telling you.
0
 
LVL 30

Assisted Solution

by:serialband
serialband earned 800 total points
ID: 40328617
I concur with woolmilkporc.  Consult the log file.  You'll have to generate it.

It sounds like you're running rsync on a Windows system.  In the Linux/Unix world, files do not get locked that way.  They are locked by inodes and file names are overwritten with new files with different inodes.  The old files may still be running, but the file names are replaced.  You only need to restart the process for it to disappear and load the new file.


On Windows, you can't ever overwrite the locked files because those are locked by the file names.  No matter which method you use to copy to a locked file, you can't overwrite it.  You also can't load it to read.  The only workaround for reading a locked file for copying is to enable VSS.  You can then use an open sourced 3rd party tool called hobocopy to make the copy.  http://hobocopy.sourceforge.net/ https://candera.github.io/hobocopy/

Unless you're copying from a linux or unix box to your windows box, it's better to use robocopy or hobocopy if you want to presevere windows ACLs.  rsync is better for unix copies.  Even with the windows tools, you need to consult the log file.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month10 days, left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question