LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-22-2007, 08:13 AM   #1
anjanesh
Member
 
Registered: Sep 2004
Location: Navi Mumbai
Distribution: Ubuntu 14.04 64-bit
Posts: 230

Rep: Reputation: 30
tar without full directory hierarchy


Hi

Im trying to back up of a directory using tar with --gzip option.
Its on Fedora Core 2 with Plesk 7.5 loaded.

I download the .tgz file to my PC and opened it with 7z and found that it has also compressed the folder hierarchy. So if I extrac it to C:, it'll create a folder called /var/www/vhosts/mydomain.com/httpdcos which is not what I want.

1. I want it such that if I extract it to C:, all files & directories in httdocs gets extracted to C: directly. What option do I need to specify here ?

2. Later I want to extract it to another linux server to a destination folder, how do I so that ?

Code:
tar --create --gzip --file="mydomain.com.tgz" "/var/www/vhosts/mydomain.com/httpdocs/"
One step behind :
Code:
tar --create --gzip --directory="/var/www/vhosts/mydomain.com/" --file="mydomain.com.tgz" "httpdocs/"
creates a .tgz file with root at httpdocs.

But this doest seem to work :
Code:
tar --create --gzip --directory="/var/www/vhosts/mydomain.com/httpdocs/" --file="mydomain.com.tgz" "/"
I think its start from absolute / folder !
Code:
tar: Removing leading `/' from member names
tar: /proc/acpi/event: Cannot open: Device or resource busy
tar: /proc/kcore: Cannot open: Operation not permitted
tar: /proc/2/task/2/exe: Cannot readlink: No such file or directory
tar: /proc/2/exe: Cannot readlink: No such file or directory
tar: /proc/3/task/3/exe: Cannot readlink: No such file or directory
tar: /proc/3/exe: Cannot readlink: No such file or directory
tar: /proc/4/task/4/exe: Cannot readlink: No such file or directory
tar: /proc/4/exe: Cannot readlink: No such file or directory
tar: /proc/5/task/5/exe: Cannot readlink: No such file or directory
tar: /proc/5/exe: Cannot readlink: No such file or directory
tar: /proc/17/task/17/exe: Cannot readlink: No such file or directory
tar: /proc/17/exe: Cannot readlink: No such file or directory
tar: /proc/98/task/98/exe: Cannot readlink: No such file or directory
tar: /proc/98/exe: Cannot readlink: No such file or directory
tar: /proc/106/task/106/exe: Cannot readlink: No such file or directory
tar: /proc/106/exe: Cannot readlink: No such file or directory
tar: /proc/167/task/167/exe: Cannot readlink: No such file or directory
tar: /proc/167/exe: Cannot readlink: No such file or directory
tar: /proc/166/task/166/exe: Cannot readlink: No such file or directory
tar: /proc/166/exe: Cannot readlink: No such file or directory
tar: /proc/260/task/260/exe: Cannot readlink: No such file or directory
tar: /proc/260/exe: Cannot readlink: No such file or directory
tar: /proc/447/task/447/exe: Cannot readlink: No such file or directory
tar: /proc/447/exe: Cannot readlink: No such file or directory
tar: /proc/452/task/452/exe: Cannot readlink: No such file or directory
tar: /proc/452/exe: Cannot readlink: No such file or directory
tar: /proc/453/task/453/exe: Cannot readlink: No such file or directory
tar: /proc/453/exe: Cannot readlink: No such file or directory
tar: /proc/468/task/468/exe: Cannot readlink: No such file or directory
tar: /proc/468/exe: Cannot readlink: No such file or directory
tar: /proc/1559/task/1559/exe: Cannot readlink: No such file or directory
tar: /proc/1559/exe: Cannot readlink: No such file or directory
tar: /proc/6599/task/6599/exe: Cannot readlink: No such file or directory
tar: /proc/6599/exe: Cannot readlink: No such file or directory
So how to get to my last step ?

(I do want sub-directories of httpdocs though)

Thanks
 
Old 12-22-2007, 11:12 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
CD into the httpdocs directory before running tar.
Then the contents will be of the contents of httpdocs, including it's subdirectories.

Or CD into "/var/www/vhosts/mydomain.com/" and use httpdocs as the file... argument. This way when you extract, it will create an httpdocs directory, so you won't have to do that manually.
 
Old 12-22-2007, 12:42 PM   #3
anjanesh
Member
 
Registered: Sep 2004
Location: Navi Mumbai
Distribution: Ubuntu 14.04 64-bit
Posts: 230

Original Poster
Rep: Reputation: 30
Dont want CD to httpdocs because Im writing a script to do this for many domain directories.
Quote:
This way when you extract, it will create an httpdocs directory
Im moving my sites to another fresh installation server, so httpdocs would already exist.

Anyway, I found the answer to this. As simple as "./" instead of "/"
Code:
tar --create --gzip --directory="/var/www/vhosts/mydomain.com/httpdocs/" --file="mydomain.com.tgz" "./"
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
The / directory is full sunhui Linux - General 5 03-30-2007 12:11 PM
Making an automake project with directory hierarchy in KDevelop g4j31a5 Programming 1 12-11-2006 09:53 PM
/root directory full kpachopoulos Linux - General 6 07-07-2005 12:01 AM
how to remove full directory ? marlor Slackware 9 09-24-2004 07:18 AM
Quicky: searching for files in directory hierarchy leeman_s Linux - General 1 01-25-2003 10:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration