[SOLVED] Which is the right way to issue a tar command when you restore your system
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
Which is the right way to issue a tar command when you restore your system
Hello!
I've recently created a tarball backup of my Ubuntu system (/ and /home partitions both ext4).
When I was creating a backup I booted off Live DVD and I used a tar command.
Now I wonder which would be the best way to untar the gzipped archive in order to restore the system. More specifically, if I should add --numeric-owner switch at the end of the tar command? I heard that it might be needed to preserve an original ownership permissions. Otherwise, I would get those from a storage media and there could be a mismatch.
On the other hand, both times I use Live DVD to boot from, so maybe it's irrelevant in my particular case? Please let me know. Thanks!
It depends on how you made the backup (you said A tar command, we need to know WHAT tar command), what part of the filesystem you backed up, and what you want to recover.
More specifically, if I should add --numeric-owner switch at the end of the tar command? I heard that it might be needed to preserve an original ownership permissions. Otherwise, I would get those from a storage media and there could be a mismatch.
If your tarball includes /etc then you have the account / UID mappings (/etc/passwd, /etc/group) so if you untar with "-C /" there should be no mismatch?
It depends on how you made the backup (you said A tar command, we need to know WHAT tar command), what part of the filesystem you backed up, and what you want to recover.
In my first post I've written what part of FS I backed up. "/ and /home partitions both ext4)"
Also I've written the answer to your question as to what I want to recover. "Now I wonder which would be the best way to untar the gzipped archive in order to restore the system"
If you're asking what exactly I typed when I originally created my tarball, then it's this command:
Code:
sudo tar -cvzpf /mnt/backup/root.tar.gz /mnt/root/
sudo tar -cvzpf /mnt/backup/home.tar.gz /mnt/home/
If your tarball includes /etc then you have the account / UID mappings (/etc/passwd, /etc/group) so if you untar with "-C /" there should be no mismatch?
Yes, my tarball does include /etc directory. It includes EVERYTHING in root. I haven't excluded anything in either / or /home partitions. Are you asking or answering? I've noticed a question mark at the end of your sentence.
If your tarball includes /etc then you have the account / UID mappings (/etc/passwd, /etc/group) so if you untar with "-C /" there should be no mismatch?
That's true if you are currently running the same system that you are restoring. That's unlikely if you are doing a full restore. When you are running from some recovery medium (which might not even be the same OS), tar will try to preserve user names by mapping those names to UIDs using the /etc/passwd of whatever system is currently running. If some of those are different from the system you are restoring, it will cause trouble. So yes, you do want to use the "--numeric-owner" option.
The tar manpage is almost totally uninformative about that option. The info page is better and describes situations where the option should be used, but describes that option primarily in the context of creating the archive, and just one paragraph indicates it is also effective for extraction:
The `--numeric-owner' option allows (ANSI) archives to be written without user/group name information or such information to be ignored when extracting. It effectively disables the generation and/or use of user/group name information. This option forces extraction using the numeric ids from the archive, ignoring the names.
This is useful in certain circumstances, when restoring a backup from an emergency floppy with different passwd/group files for example. It is otherwise impossible to extract files with the right ownerships if the password file in use during the extraction does not match the one belonging to the file system(s) being extracted. This occurs, for example, if you are restoring your files after a major crash and had booted from an emergency floppy with no password file or put your disk into another machine to do the restore.
Towards the end of the clip the author puts it when he does a restore (untarring). But when he was creating the tarball, he didn't use that option at the end of the tar command. You know, some say that --numeric-owner should be used when you create the tarball...
The old Ubuntu installation would be deleted and wiped (zeroed out). After that, there would be a new formatting (though into the same ext4 FS). Same hardware. I understand that it's what you call NOT the same system, right?
Okay, so I do have to use --numeric-owner at the end of the tar command when restoring (even though I didn't use that switch when I was creating the archive). If that's correct, then the question is solved.
Okay, so I do have to use --numeric-owner at the end of the tar command when restoring (even though I didn't use that switch when I was creating the archive). If that's correct, then the question is solved.
Using --numeric-owner when restoring is sufficient. It blocks use of the user name data in the archive, so tar acts just as though you had never stored it there when creating the archive.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.