Solved

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

Posted on 2014-09-15
9
554 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 300 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
Independent Software Vendors: 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!

 
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 200 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

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…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

690 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