restoring ONLY the home directory from a complete tar backup
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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!
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.
Distribution: Ubuntu, Slackware, Gentoo, Fedora, Red Hat, Puppy Linux
Posts: 370
Rep:
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.