- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Copying one directory to another. tar?
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
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
тАО09-07-2006 07:37 AM
тАО09-07-2006 07:37 AM
I am not going to use the cp command, because the last time I used it on some of the key partitions, I hosed the system.... it may not preserve links and dot files... etc. now how about tar.
I know I can create a tar ball with
tar -cvf dir1.tar /dir1/subdir1
but how do I untar it, i.e. where do I put it?
If i put in /dir2/subdir2, it will create
/dir2/subdir2/dir1/subdir1 tree.. which is not good.
Ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2006 07:47 AM
тАО09-07-2006 07:47 AM
Solutioncd to desired starting directory, e.g.
cd /dir1
tar cvf /var/tmp/dir1.tar . # this will get everything from the CWD down and the paths will be relative
Now cd to the directory above the desired destination, e.g
cd /xxx/yyy
mkdir dir2
chown me:mygroup dir2 # or whoever
chmod 750 dir2 # or whatever
cd dir2
tar xvf /var/tmp/dir1.tar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2006 07:48 AM
тАО09-07-2006 07:48 AM
Re: Copying one directory to another. tar?
if it is not a live system directory.
1. take tar archive backup
2. rename /dir1 & /dir1/subdir1 to /dir2 & /dir2/subdir2
3. extract the tar archive.
#tar -cvf dir1.tar /dir1/subdir1
#mv /dir1 /dir2
#mv /dir2/subdir1 /dir2/subdir2
#tar -xvf dir1.tar
regards
V.Manoharan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2006 07:51 AM
тАО09-07-2006 07:51 AM
Re: Copying one directory to another. tar?
tar cvf dir1.tar |(cd /dest; tar -xvf .)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2006 08:01 AM
тАО09-07-2006 08:01 AM
Re: Copying one directory to another. tar?
This uses 'fbackup' and 'frecover' and hence handles largefiles *and* does not inflate sparse files like 'cp' would:
# cd srcdir && fbackup -i . -f - | ( cd dstdir && frecover -Xsrf - )
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2006 08:09 AM
тАО09-07-2006 08:09 AM
Re: Copying one directory to another. tar?
tar -cvf - /dir1/subdir1/ | (cd /dir2/subdir2 ; tar -xvf - )
Hope this helps.
Kofi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2006 08:09 AM
тАО09-07-2006 08:09 AM
Re: Copying one directory to another. tar?
cd /olddir
tar cf - * | (cd /newdir; tar xvf - )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2006 08:10 AM
тАО09-07-2006 08:10 AM
Re: Copying one directory to another. tar?
tar -cvf - ./dir1/subdir1/ | (cd ./dir2/subdir2 ; tar -xvf - )
Hope this helps.
Kofi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2006 08:32 AM
тАО09-07-2006 08:32 AM
Re: Copying one directory to another. tar?
cd into the directory. The use the tar command to create a tar ball.
create tar ball
#tar -cvf dir.TAR dir
Mv or copy tar file to directory
# mv dir.TAR /dir2
Untar the tar ball
#cd /dir2
#tar -xvf dir.TAR
sp,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2006 08:49 AM
тАО09-07-2006 08:49 AM
Re: Copying one directory to another. tar?
mkdir /some_new_dir
cd /old_dir
find . | cpio -pudlmv /some_new_dir
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2006 08:53 AM
тАО09-07-2006 08:53 AM
Re: Copying one directory to another. tar?
If the users exist on both systems:
scp -rp /dir2/subdir2/* system2:/dir2/subdir2
I suppose you are using tar to preserve the links.
Are they soft or hard links?
tar -cvf dir1.tar /dir1/subdir1
tar -rvf dir1.tar /dir2/subdir2
if it must be one tar file.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2006 09:10 AM
тАО09-07-2006 09:10 AM
Re: Copying one directory to another. tar?
I will save these cool one-liners for the next time..