Jump to content

extract a subdir only from a backup tarball of /home


_Qwerty_
 Share

Recommended Posts

Hello!

 

I have made a tarball of about 200 MB, and inside that is the directory /home/user/public_html/gallery/

and the files and subdirectorys that gallery contains. Now i need to replace the local files of my

~/public_html/gallery/* files, how would i do that if the backup tarball is in /mnt/cdrom/backup.tar.gz ??

 

I have tried to read the manual page for "tar", and i have looked through two diffrent howtos, and from them i have guessed it should be something like this

 

cd /mnt/cdrom

tar xzvf backup.tar.gz /home/user/public_html/gallery/* -C ~/public_html/gallery/

 

but that causes lots of lines stating

 

home/user/public_html/gallery/UPGRADING

tar: home/user/public_html/gallery/UPGRADING: Cannot open: No such file or directory

 

and so forth for diffrent files...

 

any tips would be appreciated :)

Link to comment
Share on other sites

Hello!

 

I have made a tarball of about 200 MB, and inside that is the directory /home/user/public_html/gallery/

and the files and subdirectorys that gallery contains. Now i need to replace the local files of my 

~/public_html/gallery/* files, how would i do that if the backup tarball is in /mnt/cdrom/backup.tar.gz ??

 

as follows:

 

~$ cd /

~$ tar xvfz /mnt/cdrom/backup.tar.gz home/user/public_html/gallery

 

the syntax is: tar xvfz "tarball.gz" "file(s) you want to extract"; notice the "cd /" and the relative path to gallery (that is important if the tarball wasn't created with the -P flag)

 

Also notice that, AFAIK, the "file(s) you want to extract" must match the filenames of the files included in the tarball. I mean that must match not only the name of the file, but the full path to it as is in the tarball list; so in case of doubt do a "tar tvfz tarball.gz" to get a list of all the files included in the tarball.

 

HTH

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...