Compare Folders

Discussion topics, Linux related - not requests for help

Moderators: ChrisThornett, LXF moderators

Compare Folders

Postby nigel.taylor » Tue Mar 13, 2012 10:38 am

HI Guys,

I am a complete newbie to Linux and have been chucked in the deepend.

I have a network share with approx 10,000 images hosted on a Windows 2003 server that I need to compare with a folder full of images held on a Ubuntu Server 10.4 LTS.

Does anyone know of any tools that compares folders between the two platforms? or any other approch that I can take to this?

Thanks in advance.

Regards,

Nigel
nigel.taylor
 
Posts: 6
Joined: Tue Mar 13, 2012 10:33 am

Postby Dutch_Master » Tue Mar 13, 2012 10:56 am

Welcome. It depends on what you want to do with the results. If you want to update one folder from the other (that is: see if files on one are present on the other and if not copy them over) then rsync does the job perfectly. But if all you want to do is seeing if there's a difference between the folders, the diff tool has to be your choice. It compares 2 text files, and those text files can be generated by having the output of the ls command piped to a text file. Mind, it's commandline stuff, so get your DOS hat on and be prepared for a shock: bash (the standard Linux shell) is much more powerful then you'd ever imagined ;)

On the Ubuntu machine, enter this in a terminal:
Code: Select all
ls /path/to/image/folder > lsimage.txt
ls /path/to/win-server/folder > win-image.txt
diff [options] lsimage.txt win-image.txt > diff.txt
See the man page for diff to get a sense of what options you need (on the Ubuntu machine)...

Useful link: http://ss64.com/bash/
Dutch_Master
LXF regular
 
Posts: 2459
Joined: Tue Mar 27, 2007 1:49 am

Postby nigel.taylor » Tue Mar 13, 2012 11:44 am

Thanks for the quick response Dutch_Master.

Yes I have a mountain of stuff to learn regarding the Linux OS let alone the web application that we are going to be running our website on.

That is a great idea doing a dump of the outputs to a text file and then comparing them. I know there is then going to be files that I will need to get over to the Ubuntu server. Is there any tools that you would then recommend for then connecting to the machine to be able to copy the files over?

Regards,

Nigel
nigel.taylor
 
Posts: 6
Joined: Tue Mar 13, 2012 10:33 am

Postby nelz » Tue Mar 13, 2012 12:07 pm

[url="http://www.cis.upenn.edu/~bcpierce/unison/"]Unison[/url] sounds like a perfect fit for this job.

Unison is a file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.


I haven't tried the Windows version but use it many times each day for synchronising Linux boxes.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8550
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Postby nigel.taylor » Tue Mar 13, 2012 12:24 pm

Thanks for that Nelz. I will give it a try and let you know how I get on.

Regards,

Nigel
nigel.taylor
 
Posts: 6
Joined: Tue Mar 13, 2012 10:33 am

Postby Bruno » Tue Mar 13, 2012 1:18 pm

I recommend Unison, too, I use it on both Linux and Windows. When installing on Windows, you will also need to install something called GTK+ for Windows Runtime Environment, it's a tool-kit for drawing Unison's GUI. After installing it, you may then need to add its location to your "Path" environment variable (if the installer didn't already do so) which should be here:

Code: Select all
C:\Program Files\GTK2-Runtime\bin


With two collections stored on media that use different file systems (as is the case with Linux and Windows), Unison may throw up an error when it tries to synchronise the permissions of the files. If this happens, add the following lines to Unison's profile files (located at ~/.unison/*.prf on Linux and C:\Documents and Settings\<user>\.unison\*.prf on Windows):

Code: Select all
perms = 0
dontchmod = true


Also watch out for failures to synchronise files whose names contain characters that are illegal in the other file system.
User avatar
Bruno
LXF regular
 
Posts: 139
Joined: Tue Sep 18, 2007 6:07 pm
Location: Cambridgeshire, UK

Postby guy » Tue Mar 13, 2012 9:56 pm

Unison sounds great for what I want too, to sync my files between two boxes with different versions of debian.

But the eternal noob is cautious enough to ask some questions first:

Do I need to install it on one host or both?
If both, does it matter if I install different versions on each box?

And do I need to do anything to make the boxes accessible to each other? This needs a level of security, so that other boxes on my network (e.g. visiting kids' laptops) cannot access them.
"Klinger, do you know how many zoots were killed to make that one suit?" — BJ Hunnicutt
User avatar
guy
LXF regular
 
Posts: 1098
Joined: Thu Apr 07, 2005 12:07 pm
Location: Worcestershire

Postby nelz » Tue Mar 13, 2012 10:07 pm

Install on both. It has to be the same version, but that's unlikely to be a problem. It uses SSH to communicate, so you just need to set up key authentication for the user(s) - but you should have that anyway.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8550
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK


Return to Discussion

Who is online

Users browsing this forum: No registered users and 2 guests