- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Recreate exact directory structure in another ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-2007 08:06 PM
тАО11-15-2007 08:06 PM
I like to recreate a directory hierachy structure from one server to another. Is there a script to do this?
Requirements
1. Recreated dir must have same permissions, user name and group name
2. Symbolic links to directory must also be recreated as symbolic links (no deferencing)
I was thinking of using tar together with find. But find command cannot differentiate symbolically linked directories and symbolic linked files
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-2007 08:33 PM
тАО11-15-2007 08:33 PM
Re: Recreate exact directory structure in another server
find . ! -type f | cpio -ovH newc > /tmp/dir.structure.cpio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-2007 08:36 PM
тАО11-15-2007 08:36 PM
Re: Recreate exact directory structure in another server
Thanks, but using
find . ! -type f
will also back up symbolically linked files which I have to exclude
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-2007 09:08 PM
тАО11-15-2007 09:08 PM
SolutionUgh, that makes life a bit more difficult because of 2).
Ok, try:
find . ! -type f ! -xtype f | ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 03:38 AM
тАО11-16-2007 03:38 AM
Re: Recreate exact directory structure in another server
Linux/GNU has features that one would like to see in Unix!
An approach other than Stuart's very elegant one is to use Perl:
# cat ./showdir
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
use Cwd qw( realpath );
my @dir = @ARGV ? @ARGV : ('.');
find(
sub {
lstat;
my $name = $File::Find::name;
if ( -d _ ) { print "d $name\n" }
elsif ( -l _ && -d realpath($name) ) {
print "l $name -> ", realpath($name), "\n";
}
},
@dir
);
1; #_jrf_
...run as:
# ./showdir /path
For example:
# .showdir /home/jrf
d /home/jrf
l /home/jrf/linktotmp -> /tmp
d /home/jrf/Mail
...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 04:13 AM
тАО11-16-2007 04:13 AM
Re: Recreate exact directory structure in another server
You may already know about this. But your in luck.
http://hpux.cs.utah.edu/hppd/hpux/Gnu/findutils-4.2.31/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 04:32 AM
тАО11-16-2007 04:32 AM
Re: Recreate exact directory structure in another server
tar cf -
I hope you find it useful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2007 04:32 AM
тАО11-16-2007 04:32 AM
Re: Recreate exact directory structure in another server
Court, thanks, and yes I was aware of the HP-UX port. I'm a tool-builder for a variety of reasons, not the least of which --- TMTOWTDI.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2007 01:50 PM
тАО11-18-2007 01:50 PM
Re: Recreate exact directory structure in another server
Thanks for the tip..
I will use
# find . ! -type f ! -xtype f
But now I have a strange problem regarding file modification time
I used your suggested method to create the cpio file.
# find /home ! -type f ! -xtype f | cpio -ovH newc > file.cpio
I transfer file.cpio to another server and do an extraction using
# cpio -ivmH newc < file.cpio
Did an "ls -l" command and found that all the directories created have a modification time of "now". Very strange..
Run the same command again
# cpio -ivmH newc < file.cpio
Did an "ls -l" command and this time the file modification time is set to the correct original value!
Is there a bug in cpio or did I use the command wrongly?
Thanks