Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   CentOS (http://www.linux-archive.org/centos/)
-   -   compare directories (http://www.linux-archive.org/centos/181002-compare-directories.html)

"David Hláčik" 10-23-2008 09:53 AM

compare directories
 
Hello guys,

I have two mirrors. I need to compare files and directories on both mirrors and as a result print list of those which are missing on mirror 2

What i did

find /data > find.mirror1


find /data > find.mirror2

Now i need to get list of those directories which are missing in mirror1.

Thanks in advance!

David

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

Luciano Rocha 10-23-2008 10:16 AM

compare directories
 
On Thu, Oct 23, 2008 at 11:53:20AM +0200, David Hláčik wrote:
> Hello guys,
>
> I have two mirrors. I need to compare files and directories on both mirrors
> and as a result print list of those which are missing on mirror 2
>
> What i did
>
> find /data > find.mirror1
>
> find /data > find.mirror2
>
> Now i need to get list of those directories which are missing in mirror1.
>
> Thanks in advance!

I use this bash function:
dirdiff ()
{
local src="$1" dst;
dst="${2:-.}";
if [ -z "$src" ]; then
err "missing original directory";
return 1;
fi;
if ! [ -d "$src" ]; then
err "$src: not a directory";
return 1;
fi;
if ! [ -d "$dst" ]; then
err "$dst: not a directory";
return 1;
fi;
diff -u <(cd "$src" && find . | LC_ALL=C sort |
sed -e 's/^..//') <(cd "$dst" && find . | LC_ALL=C sort |
sed -e 's/^..//')
}

--
lfr
0/0
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

Mogens Kjaer 10-23-2008 10:28 AM

compare directories
 
David Hláčik wrote:
> Hello guys,
>
> I have two mirrors. I need to compare files and directories on both mirrors
> and as a result print list of those which are missing on mirror 2

Can you use rsync with the -n switch (dryrun) to mirror from
mirror 1 to mirror 2 and see what would be transferred?

Mogens

--
Mogens Kjaer, Carlsberg A/S, Computer Department
Gamle Carlsberg Vej 10, DK-2500 Valby, Denmark
Phone: +45 33 27 53 25, Mobile: +45 22 12 53 25
Email: mk@crc.dk Homepage: http://www.crc.dk
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

Les Mikesell 10-23-2008 12:45 PM

compare directories
 
David Hlc(ik wrote:

Hello guys,

I have two mirrors. I need to compare files and directories on both mirrors
and as a result print list of those which are missing on mirror 2

What i did

find /data > find.mirror1

find /data > find.mirror2

Now i need to get list of those directories which are missing in mirror1.


You can run diff with the two files, but why not just use rsync to fix
it in a single step?


To compare directories with rsync, cd into one of them and:
rsync -avn . /target/path
The -n option says to not actually copy files, but with the -v option
this will list the files that are missing or different. Because the -a
option also sets the owner and modes, this may list files where those
are the only differences. Omit the -n option to make the changes.


The target path may be on a different host if you use the form
user@host:/path/to/target. With older versions of rsync you might have
to add -essh to the arguments but that is the default now. If you would
like any extra files in the target copy to be deleted, you can add the
--delete option, but be sure you know what you are doing first.


--
Les Mikesell
lesmikesell@gmail.com


_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


All times are GMT. The time now is 07:09 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.