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.
I want to pretend I've had a total disk failure. I've got a brand new disk. And I've got a full tar backup created with the following tar command:
Code:
cd /
tar -czvpf /media/backups/fullbackup0.tar.gz --directory=./ --exclude=proc --exclude=sys --exclude=dev/pts --exclude=media .
Assume that I'll create the previous partition structure from memory. (Ideally I'd like to be an idiot that can't remember that.)
This question is for a new Debian Wheezy install.
So, how do I do this?
And even better, is there a webpages somewhere that tells me how to do this?
FOR STARTERS and for context, let me make an uninformed guess.
Boot into any other system on my disks
build the desired partition structure on the new disk
cd to the / partition on that disk
tar -xzvpf /media/backups/fullbackup0.tar.gz
rebuild GRUB2 somehow
update the MBR somehow (done by reinstall-grub, I think)
But this likely won't work since /etc/fstab (and others???) have UUID's set to the previous (pretend broken) system. So how do I reassociate to the new UUIDs?
If I can do that, is that all I need to do?
Thanks for your help.
Last edited by linuxStudent11; 09-07-2013 at 11:37 PM.
Reason: I found the grub udate stuff + more info
You restore it from a LiveCD/other installed system, as you wrote it. Then you need to
1. change uuid in /etc/fstab. Run 'blkid' as root to find out the new uuid.
2. regenerate grub's configuration file. Usually by running 'update-grub'.
3. install grub in mbr.
You said you have other system on the same machine. Depending on which distro is "owning" mbr, you might need to run update-grub on that system instead, and don't install grub in mbr.
It doesn't matter if you create the same partitions or if you make it different. Just mount all partitions where they should be in the new system before restoring the backup. At least this is true for rsync. As I haven't used tar for this I can't say for sure. You better test your backup before your disk fails.
cd /path/to/newroot_partition
tar -zxvf /media/backups/fullbackup0.tar.gz
mkdir /path/to/newroot_partition/{proc,sys,media, dev/pts}
.
Before I would put too much trust in that, I would check if gzip writes a temp file. If it does (and I have a notion it does), then you'll need a lot of tmp space to sort out a zip that size. That could scupper a recovery. In that case you could pipe it through split (man split). You may also need to exclude dev, except for basic devices.
I think that cpio is a better option for such full system backups than tar is. The way tar handles things varies from version to version, and really isn't designed for this.
@H_TeXMeX_H: The traditional cpio file formats have various limitations, including file size limitations that you might actually hit on a modern system so I would not advise anyone use them.
The two most common cpio formats are odc and newc. Both of these are old, effectively legacy, formats and as such have little place in backing up modern systems. odc, an old posix standard cannot have individual entries larger than 8Gb (personally I have media files bigger than that). newc, never a posix standard but faily ubiquitous nonetheless (not least because it is the archive container within most rpm files), can actually only hold smaller files (2Gb) despite being a newer format (it is less limited than odc in other areas such as pathname length).
A more modern posix archive format is pax (an extension of the tar format), which can be written by modern tar versions and has no practical limits, e.g. individual file entries can be 9Eb in size. Standardisation means there are no longer any worries about format variance for tar versions that support pax (GNU tar, BSD tar, Star, etc.) and yes tar is very much designed for this type of backup.
If one really wants to use cpio for backup, they have three options: use BSD Cpio, which can write pax archives; use Heirloom cpio (from The Heirloom Toolchest), which can also write pax archives or use non-standard extensions to the traditional cpio formats (e.g. SCO extensions to newc allowing file entries of up to 9Eb); use Afio, which can extend odc past practical limits. I would avoid GNU Cpio at all costs since it supports neither pax nor extensions to odc or newc, making it largely useless for modern backup. I'd also add that GNU Cpio appears to be in maintenance mode, receiving tiny updates and fixes only. If you were to judge the cpio and tar wars by only the GNU utilities, then you would have concluded that cpio had been beaten to a pulp.
The easiest is to use dd from a live cd and make a bit-for-bit copy of the root drive to a backup drive. The tar/rsync/cpio method is more relevant if you are cloning to a smaller size ssd drive. dd will work for a same size or larger drive. In case of the latter, just use gparted to resize the partition to fill the entire drive.
Quote:
Originally Posted by linuxStudent11
Boot into any other system on my disks
build the desired partition structure on the new disk
cd to the / partition on that disk
tar -xzvpf /media/backups/fullbackup0.tar.gz
rebuild GRUB2 somehow
update the MBR somehow (done by reinstall-grub, I think)
But this likely won't work since /etc/fstab (and others???) have UUID's set to the previous (pretend broken) system. So how do I reassociate to the new UUIDs?
Assuming you are backing up to /dev/sdb1 and /dev/sdb1 is mounted on /mnt/new:
Fix /mnt/new/etc/fstab with blkid - this will print out the UUID for each partition in the system. Just copy and paste the UUID for the root drive.
mount --bind /dev /mnt/new/dev
mount --bind /sys /mnt/new/sys
mount --bind /proc /mnt/new/proc
chroot /mnt/new
update-grub
exit
umount /mnt/new/dev
umount /mnt/new/sys
umount /mnt/new/proc
If you would like to keep the same network device name (eth0) edit /mnt/new/etc/udev/rules.d/70-persistent-net.rules:
# PCI device 0x8086:0x294c (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
Just remove lines which look like this.
WOW! Thanks for everybody's help on this. It sounds like tar is NOT a universal answer, instead use dd,rsync,apio (as approprate) with variations on grub (I'm using grub2 at the moment). tar looks like its good only for limited local backups.
I'll be saving this thread in my websaves dir. Thanks again everybody.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.