LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-10-2008, 08:33 AM   #1
irishbitte
Senior Member
 
Registered: Oct 2007
Location: Brighton, UK
Distribution: Ubuntu Hardy, Ubuntu Jaunty, Eeebuntu, Debian, SME-Server
Posts: 1,213
Blog Entries: 1

Rep: Reputation: 88
Unhappy restoring ONLY the home directory from a complete tar backup


Hi folks,

Having a bit of bother here. Made a silly mistake on production file server, and have basically messed it up.

The thing is, I have a backup from about 2 months ago, which is a complete system image with settings, config, LDAP, NFS, the works, so we are back in business. On a separate HDD, I have all of the users home directories, along with the messed up system. I am trying to use tar to restore only the users home directories, and leave everything else alone, obviously with file permissions intact.

Any ideas? I am pulling my hair out here!
 
Old 11-10-2008, 08:46 AM   #2
AuroraCA
Member
 
Registered: Jul 2008
Location: Northern CA USA
Distribution: Ubuntu, Slackware, Gentoo, Fedora, Red Hat, Puppy Linux
Posts: 370

Rep: Reputation: 35
Here is a very good references with examples that may give you some help:

http://www.gnu.org/software/tar/manu...n/extract.html

http://www.washington.edu/computing/unix/tar.html

Specifically refer to Section2.8.2 Extracting Specific File

You can always use the -v or --verbose and -t or --list flags to check your command before extracting.

Last edited by AuroraCA; 11-10-2008 at 08:53 AM.
 
Old 11-10-2008, 09:40 AM   #3
irishbitte
Senior Member
 
Registered: Oct 2007
Location: Brighton, UK
Distribution: Ubuntu Hardy, Ubuntu Jaunty, Eeebuntu, Debian, SME-Server
Posts: 1,213

Original Poster
Blog Entries: 1

Rep: Reputation: 88
Thanks for your help AuroraCA, I guess I'm more of a newbie at this than I thought!

What I guess I'm really looking for is examples of commands using tar, both to archive and to extract the home directory. Currently, I am using a command something like:
Code:
cd /                               # change to root
tar -cvpf --exclude=proc /home    # archive home directory
obviously, there are a few more excludes!
Then to extract, I'm doing something like:
Code:
cd /
tar -xvpf /home
There are obviously things I am missing, the archive command seems not to produce anything, even though it is going through all the directories which I can see with -v.

Can you give me an idea of what you would do? Most appreciative of your help!
 
Old 11-10-2008, 09:44 AM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
You can always create a temporary directory, untar the backup there and mv or cp the contents you want into the final destination, then remove the remaining backup bits you untarred.
 
Old 11-10-2008, 10:26 AM   #5
AuroraCA
Member
 
Registered: Jul 2008
Location: Northern CA USA
Distribution: Ubuntu, Slackware, Gentoo, Fedora, Red Hat, Puppy Linux
Posts: 370

Rep: Reputation: 35
Your problem is that you have not created a tar archive with your create command.
Code:
tar -cvpf --exclude=proc home.tar /home      # create archive of /home
When you create an archive you must specify the -cf flags. The "c" is to create an archive and the "f" indicates the name of the file in which the archive will be stored. The first argument following the "f" will be used as the name of the archive. You do not need to use the .tar extension on the filename but it is good practice to indicate that the file is a "tar" archive.

The restore command would then be:
Code:
tar -xvpf home.tar                           # extract home.tar archive to restore /home
The command to restore a file or directory from a tarball would be:
Code:
tar -xvpf full.tar /home/*                   # extract /home directory from full archive
Here is another tar tutorial with examples and explanations of the commands.

http://www.bellevuelinux.org/tar.html

Last edited by AuroraCA; 11-10-2008 at 10:37 AM.
 
Old 11-11-2008, 08:24 AM   #6
irishbitte
Senior Member
 
Registered: Oct 2007
Location: Brighton, UK
Distribution: Ubuntu Hardy, Ubuntu Jaunty, Eeebuntu, Debian, SME-Server
Posts: 1,213

Original Poster
Blog Entries: 1

Rep: Reputation: 88
To AuroraCA and trickykid: Thanks for all your help, I got there in the end! Never really had to use tar before, but was very glad to be able to use it! Thanks for all your help.
 
  


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
Backup My Home Dir Using Tar? carlosinfl Linux - General 2 03-19-2008 01:30 PM
restoring desktop directory in /root (or any home directory) mel_lai Linux - Newbie 3 02-04-2008 03:13 AM
New installation: restoring the old home folder? Backup advices bruno321 Linux - General 4 11-18-2007 08:55 AM
Restoring Home Directory Ownership taylortbb Linux - General 1 08-27-2004 09:40 AM
restoring /etc files from tar backup hdagelic Linux - General 1 09-24-2003 07:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:20 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