LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-06-2012, 06:24 AM   #1
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Rep: Reputation: 16
Extract backup_files.tgz on Centos 6.2 to a directory


Hello

I was login to ssh and from inside the directory i was run this:

Code:
tar -zcf backup_files.tgz /home/nginx/domains/mydomain.com/public/
And i got on home directory the file backup_files.tgz

Now from home directory how can i extract all files and folders and overwrite the contents back to the folder public ?:

Code:
/home/nginx/domains/mydomain.com/public/
?

Thank you

p.s: I was try from home directory this:

Code:
tar xvf backup_files.tgz -C /home/nginx/domains/mydomain.com/public/
But this was create :

Code:
/home/nginx/domains/mydomain.com/public//home/nginx/domains/mydomain.com/public/myfileshere

Last edited by ASTRAPI; 03-06-2012 at 06:33 AM.
 
Old 03-06-2012, 06:35 AM   #2
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Hi,

Assuming that "/home/nginx/domains/mydomain.com/public/" was all there is in the archive,
then change your dir to /
and execute
tar xvf backup_files.tgz

it will extract from archive relative to your current working dir /
(and if the archive contents were home/nginx/domains/mydomain.com/public/ it will overwrite everything in there with files from archive)

or

you can go to "/home/nginx/domains/mydomain.com/public//home/nginx/domains/mydomain.com/public/myfileshere" directory
and copy everything from this folder to your 'original' where it should be:
Code:
# /home/nginx/domains/mydomain.com/public//home/nginx/domains/mydomain.com/public/myfileshere $> cp -v * /home/nginx/domains/mydomain.com/public/

Last edited by lithos; 03-06-2012 at 06:41 AM. Reason: mistaken
 
Old 03-06-2012, 06:41 AM   #3
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Original Poster
Rep: Reputation: 16
Quote:
then change your dir to /
How?

and if i go to another path that the file backup_files.tgz is not there how it will work?

Thank you
 
Old 03-06-2012, 06:43 AM   #4
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
well

how do you change the working directory is a simple command:
Code:
# cd /
and if you want to extract the archive, you should know where it is located, so execute:
Code:
[server@/]# tar xzvf /path/to/backup_files.tgz

Last edited by lithos; 03-06-2012 at 08:38 AM.
 
Old 03-06-2012, 07:00 AM   #5
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Original Poster
Rep: Reputation: 16
The last command is:

Quote:
/ $> tar xzvf /path/to/backup_files.tgz
or just:

Quote:
tar xzvf /path/to/backup_files.tgz
?

Thank you
 
Old 03-06-2012, 08:37 AM   #6
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
this is right:
Code:
tar xzvf /path/to/backup_files.tgz
/ $ characters were some prompt 'garbage'.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to extract tgz Longinus Linux - Newbie 14 12-21-2015 04:30 AM
how to extract file *.tgz vanhelsing Linux - Software 1 06-05-2004 07:07 AM
gunzip does not extract *.tgz nausicaa3000 AIX 6 02-07-2004 05:06 PM
extract single directory from .tgz rickenbacherus Linux - General 2 02-07-2004 11:37 AM
how do i extract a .tgz ? lax2sman Linux - Networking 4 02-11-2002 05:40 PM


All times are GMT -5. The time now is 10:10 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration