LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Extract backup_files.tgz on Centos 6.2 to a directory (https://www.linuxquestions.org/questions/linux-newbie-8/extract-backup_files-tgz-on-centos-6-2-to-a-directory-932993/)

ASTRAPI 03-06-2012 05:24 AM

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
:(

lithos 03-06-2012 05:35 AM

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/

ASTRAPI 03-06-2012 05:41 AM

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

lithos 03-06-2012 05:43 AM

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

ASTRAPI 03-06-2012 06:00 AM

The last command is:

Quote:

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

Quote:

tar xzvf /path/to/backup_files.tgz
?

Thank you

lithos 03-06-2012 07:37 AM

this is right:
Code:

tar xzvf /path/to/backup_files.tgz
/ $ characters were some prompt 'garbage'.


All times are GMT -5. The time now is 07:25 AM.