Gentoo Archives: gentoo-user

From: Alex Schuster <wonko@×××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Cloning a directory hierarchy, but not the content
Date: Sat, 29 Jan 2011 16:46:54
Message-Id: 201101291745.31007.wonko@wonkology.org
In Reply to: Re: [gentoo-user] Cloning a directory hierarchy, but not the content by Etaoin Shrdlu
1 Etaoin Shrdlu writes:
2
3 > On Sat, 29 Jan 2011 15:27:59 +0100 Alex Schuster <wonko@×××××××××.org>
4 > wrote:
5 > > > > I just wrote a little script that does this, but it does not do the
6 > > > > sparse file thing yet, and would have problems with newline in file
7 > > > > names. And I guess someone already wrote such a utility?
8 > > >
9 > > > IIUC, try
10 > > >
11 > > > find / -type d -exec sh 'mkdir -p target"$1"' - {} \;
12 > >
13 > > Hmm, that does not really seem to work. It tries to execute the whole
14 > > stuff between single quotes as a command. And I don't really understand
15 > > what it is supposed to do, shouldn't this be something like mkdir -p
16 > > /destination/$1/\{\} ?
17 >
18 > No. That recreates the full directory hierarchy based at / under
19 > /target/, with no files in it. Just the directory hierarchy.
20
21 Ah, now I get it. There's a -c missing after the sh command.
22
23 > I should
24 > have added that, to do it safely, the target should reside higher than
25 > the source in the hierarchy, or it should be on a different filesystem
26 > and in that case -xdev should be specified to find (otherwise an
27 > recursive loop would result).
28
29 Right, but not important in my case. I want to mount my backup drive to
30 /mnt, cd /mnt, and duplicate all stuff soemwhere else, without taking up
31 much space. Then I can remove the backup drive and I only have to mount it
32 again when I need a file's content, but not for finding out which files
33 there are and how much space they take. Well, the space already is in the
34 file created by du -m, but I'd like to directly navigate around.
35
36
37 > Ok, I misunderstood. You also want the files but empty. Why do you need
38 > support for sparse files? Do you need to manage other types of file
39 > (symlinks, FIFOs, etc.)
40
41 Yes, symlinks would ne nice, too, I forgot about them. The rest is
42 unimportant, as this would be data only, not root file systems. I backup
43 that with rdiff-backup to a 2nd drive, but there's much other stuff that I
44 would like to put on one of the old drives that lie around here.
45
46 Sparse files would be nice because then I do not only have the same logical
47 structure, the files also appear to have the same size as the originals,
48 instead of having a size of 0. I could navigate and explore the directory
49 structure with mc, and with du --apparent-size I could find out how much
50 space a subdirectory takes. Again, my du -m file already has this
51 information, but while navigating in the directory tree, being able to use
52 du would be nice.
53
54 Wonko

Replies

Subject Author
Re: [gentoo-user] Cloning a directory hierarchy, but not the content Etaoin Shrdlu <shrdlu@×××××××××××××.org>