How to recover with a full backup?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

How to recover with a full backup?

Volker Wysk
Hi!

I'm making preparations for the case when I can no longer boot my machine, and I'm not able to recover with the GRUB recovery mode.

I have a full backup, which includes the system as well as personal data.

When I can't recover, I would install the system anew, from the Kubuntu installation ISO. Then I would unpack my backup, in some directory /backup. Now, how to get a running system again, from that? Could I just replace the top level directories with ones from the backup? Such as:

cd /
mv /bin bin.tmp
bin.tmp/mv backup/bin bin
rm -r bin.tmp

Now, how to make it bootable? Can I just do:

grub-install /dev/sda

Cheers,
Volker


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Chris Green
On Sat, Dec 09, 2017 at 03:26:29PM +0100, Volker Wysk wrote:

> Hi!
>
> I'm making preparations for the case when I can no longer boot my machine,
> and I'm not able to recover with the GRUB recovery mode.
>
> I have a full backup, which includes the system as well as personal data.
>
> When I can't recover, I would install the system anew, from the Kubuntu
> installation ISO. Then I would unpack my backup, in some directory /backup.
> Now, how to get a running system again, from that? Could I just replace
> the top level directories with ones from the backup? Such as:
>
> cd /
> mv /bin bin.tmp
> bin.tmp/mv backup/bin bin
> rm -r bin.tmp
>
I think the above would be a recipe for disaster!

Work out what you actually *need* to back up.  I.e. what areas have
personal files and what areas have customisation.

Basically this *should* mean that what you need to back up is:-

    /home - all personal files and confguration
    /etc - there may be some system-wide configuration changes here, but only a few
    /usr/local - you might have added some things here

The to restore a working system you:-

    Install the new system
    Copy the backup /home over /home (or move like you suggest above)
    restore /usr/local
    Check what files are different in /etc and copy or not as required

There may be a few other areas to backup/restore, e.g. mysql databases
and web pages in /srv if you run a web server.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Xen
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Xen
In reply to this post by Volker Wysk
Volker Wysk schreef op 09-12-2017 15:26:

> Hi!
>
> I'm making preparations for the case when I can no longer boot my
> machine, and I'm not able to recover with the GRUB recovery mode.
>
> I have a full backup, which includes the system as well as personal
> data.
>
> When I can't recover, I would install the system anew, from the
> Kubuntu installation ISO. Then I would unpack my backup, in some
> directory /backup. Now, how to get a running system again, from that?

If you unpack your backup anyway, you could do so from a live dvd.

You then don't need to install the system, just restore the (root)
filesystem.

Including /boot if it is on a different partition.

At that point you do indeed need to install Grub.

This goes like this. Assuming your backup is in /backup.

# for d in sys dev run proc; do mount --bind /$d /backup/$d; done
# chroot /backup

(This assumes /boot is already mounted on /backup/boot)

# grub-install /dev/sda

That's really all you need to do. Linux has no "special files" that are
hardcoded on your partition; which means you can just do a *file
restore* with the one exception that you need to install grub.

Which you already thought of.

> Could I just replace the top level directories with ones from the
> backup?

Better not do this in the *running* system.

You can do the exact same thing in a live session without interfering
with any files.

> Now, how to make it bootable?

You are right on that.

> Can I just do:
>
> grub-install /dev/sda

Yes. What you proposed might actually work as long as the "mv" binary
and its required libraries remained accessible but if you don't do it
"atomically" corruption could occur. That is why it is much more
reliable to do it from a live session.

Of course you could do the experiment; after all you have nothing to
lose.

But I would not trust my system to be in a completely consistent state
and it saves you time to (not have to do) the install if you do it from
a live session.

In conclusion, there is no reason or *benefit* to be doing it from an
installed system.



(I assumed you wouldn't need to recreate any partitions).

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Colin Law
In reply to this post by Volker Wysk
On 9 December 2017 at 14:26, Volker Wysk <[hidden email]> wrote:
> Hi!
>
> I'm making preparations for the case when I can no longer boot my machine, and I'm not able to recover with the GRUB recovery mode.
>
> I have a full backup, which includes the system as well as personal data.
>
> When I can't recover, I would install the system anew, from the Kubuntu installation ISO. Then I would unpack my backup, in some directory /backup. Now, how to get a running system again, from that? Could I just replace the top level directories with ones from the backup? Such as:

You can use clonezilla running from a bootable image to make a
compressed full disc image. Then to recover you can use clonezilla
again to restore to the same disc or another disc of the same size or
larger.

In addition as Chris suggested you should make regular backups of
important data, and occasionally move one of those offsite.

Colin

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Volker Wysk
In reply to this post by Chris Green
Am Samstag, 9. Dezember 2017, 14:43:42 CET schrieb Chris Green:

> On Sat, Dec 09, 2017 at 03:26:29PM +0100, Volker Wysk wrote:
> > Hi!
> >
> > I'm making preparations for the case when I can no longer boot my machine,
> > and I'm not able to recover with the GRUB recovery mode.
> >
> > I have a full backup, which includes the system as well as personal data.
> >
> > When I can't recover, I would install the system anew, from the Kubuntu
> > installation ISO. Then I would unpack my backup, in some directory /backup.
> > Now, how to get a running system again, from that? Could I just replace
> > the top level directories with ones from the backup? Such as:
> >
> > cd /
> > mv /bin bin.tmp
> > bin.tmp/mv backup/bin bin
> > rm -r bin.tmp
> >
> I think the above would be a recipe for disaster!

That's not so good.. :(
 
> Work out what you actually *need* to back up.  I.e. what areas have
> personal files and what areas have customisation.

Why not backup and restore everything, if that's what's desired?


> Basically this *should* mean that what you need to back up is:-
>
>     /home - all personal files and confguration
>     /etc - there may be some system-wide configuration changes here, but only a few
>     /usr/local - you might have added some things here

There's also /usr/share/dovecot/ and /var/www/html/nextcloud on my system... And there might be more.

 
> The to restore a working system you:-
>
>     Install the new system
>     Copy the backup /home over /home (or move like you suggest above)
>     restore /usr/local
>     Check what files are different in /etc and copy or not as required
>
> There may be a few other areas to backup/restore, e.g. mysql databases
> and web pages in /srv if you run a web server.

I still can't see why this would be better than reverting everything to the last state. Wouldn't this be easier und safer?

Bye
Volker


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Ralf Mardorf-2
I'm not willing to read the whole thread.

IMO it's very simple. Backup everything using another install or a live
media and restore everything using another install or a live media,
using something simple as e.g.  cp -ai  or  tar  with xattrs.

The bootloader is an exception, as well as the MBR or what ever you
are using.

Bootloader as well as MBR or an alternative to MBR should be separated
steps.

IOW if needed format and partition your disk, restore the complete file
system using copy, tar or whatever and after that install your favourite
bootloader.

dd usually is inappropriate, just imagine you need to replace the disk
by a disk with a completely different geometry.

Note, GRUB not necessarily is the best choice for the bootloader that
might fit to your needs. I'm using syslinux, even while it's a PITA, it
still does cause less pain regarding my needs, than GRUB does.







--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Volker Wysk
In reply to this post by Xen
Am Samstag, 9. Dezember 2017, 16:05:39 CET schrieb Xen:

> Volker Wysk schreef op 09-12-2017 15:26:
> > Hi!
> >
> > I'm making preparations for the case when I can no longer boot my
> > machine, and I'm not able to recover with the GRUB recovery mode.
> >
> > I have a full backup, which includes the system as well as personal
> > data.
> >
> > When I can't recover, I would install the system anew, from the
> > Kubuntu installation ISO. Then I would unpack my backup, in some
> > directory /backup. Now, how to get a running system again, from that?
>
> If you unpack your backup anyway, you could do so from a live dvd.
>
> You then don't need to install the system, just restore the (root)
> filesystem.

The filesystem which might need to be recovered, is encrypted and a logical volume (LVM based). I don't know how to activate the volume group. This is what I meant with the message "LVM: How to access a foreign volume group", here in this list. I could try to access it with an non-encrypted, non-LVM  maintenance system. I'll try that next.

> Including /boot if it is on a different partition.
>
> At that point you do indeed need to install Grub.
>
> This goes like this. Assuming your backup is in /backup.
>
> # for d in sys dev run proc; do mount --bind /$d /backup/$d; done
> # chroot /backup
>
> (This assumes /boot is already mounted on /backup/boot)
>
> # grub-install /dev/sda
>
> That's really all you need to do. Linux has no "special files" that are
> hardcoded on your partition; which means you can just do a *file
> restore* with the one exception that you need to install grub.

This sound good. Next I'll look after this.


> Which you already thought of.
>
> > Could I just replace the top level directories with ones from the
> > backup?
>
> Better not do this in the *running* system.

Okay.

 

> You can do the exact same thing in a live session without interfering
> with any files.
>
> > Now, how to make it bootable?
>
> You are right on that.
>
> > Can I just do:
> >
> > grub-install /dev/sda
>
> Yes. What you proposed might actually work as long as the "mv" binary
> and its required libraries remained accessible but if you don't do it
> "atomically" corruption could occur. That is why it is much more
> reliable to do it from a live session.
>
> Of course you could do the experiment; after all you have nothing to
> lose.
>
> But I would not trust my system to be in a completely consistent state
> and it saves you time to (not have to do) the install if you do it from
> a live session.
>
> In conclusion, there is no reason or *benefit* to be doing it from an
> installed system.

OK, see above.

Bye,
Volker


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Volker Wysk
In reply to this post by Colin Law
Am Samstag, 9. Dezember 2017, 15:08:46 CET schrieb Colin Law:

> On 9 December 2017 at 14:26, Volker Wysk <[hidden email]> wrote:
> > Hi!
> >
> > I'm making preparations for the case when I can no longer boot my machine, and I'm not able to recover with the GRUB recovery mode.
> >
> > I have a full backup, which includes the system as well as personal data.
> >
> > When I can't recover, I would install the system anew, from the Kubuntu installation ISO. Then I would unpack my backup, in some directory /backup. Now, how to get a running system again, from that? Could I just replace the top level directories with ones from the backup? Such as:
>
> You can use clonezilla running from a bootable image to make a
> compressed full disc image. Then to recover you can use clonezilla
> again to restore to the same disc or another disc of the same size or
> larger.

My disk is 3.6 TB large, and I'm using about 2.1 TB... I don't have a separate partition for /home, everything is in the root filesystem, except for /boot.


> In addition as Chris suggested you should make regular backups of
> important data, and occasionally move one of those offsite.

Who do you tell this! I'm quite eloberate when it comes to backups. Because, some time you *will* need one.


Cheers
Volker


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Xen
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Xen
In reply to this post by Volker Wysk
Volker Wysk schreef op 09-12-2017 20:26:

> The filesystem which might need to be recovered, is encrypted and a
> logical volume (LVM based). I don't know how to activate the volume
> group.

Oh.

Well I thought there might be more, but I did not read the other topic.

It is really not that hard.

So you have 2 options:

1) recreate the entire crypt, and the entire LVM, and new filesystems
(root, boot and swap)

2) open the crypt, allow the LVM to be activated, and zero or reformat
the partitions.

Option 1) is reinstalling the system.



This is option 2)

In the live session:

- cryptsetup open /dev/sda5 sda5_crypt

(assuming your encrypted partition is /dev/sda5, and your boot is
/dev/sda1)

(this will automatically activate the volume group contained in the LUKS
crypt)

(at this point, assuming default, there exist now devices such as
/dev/ubuntu-vg/root)

To zero your root and boot and swap:

- dd if=/dev/zero of=/dev/ubuntu-vg/root bs=1M
- dd if=/dev/zero of=/dev/ubuntu-vg/boot bs=1M
- dd if=/dev/zero of=/dev/ubuntu-vg/swap bs=1M

To create a new filesystem:

- mkfs.ext4 /dev/ubuntu-vg/root
- mkfs.ext2 /dev/ubuntu-vg/boot
- mkswap /dev/ubuntu-vg/swap

To mount the new root and boot so you can restore the backup there:

- mkdir /target
- mount /dev/ubuntu-vg/root /target
- mount /dev/ubuntu-vg/boot /target/boot

Assuming your backup is monolithic including /boot:

- <restorationcommand> -C /target

Installing grub:

- for d in dev proc sys run; do mount --bind /$d /target/$d
- chroot /target
- grub-install /dev/sda

To leave the chroot:
- exit

At this point you are done, assuming your backup is file-based (e.g.
tar).

All of this runs as root (sudo su first) or prefix everything with sudo.

If a volume group really is not activated, run : vgchange -ay

To close the LUKS container again:

- for d in sys run proc dev; do umount /target/$d; done
- umount /target/boot
- umount /target
- vgchange -an
- cryptsetup close luks

Then you are back at the beginning, but with a newly installed (copied)
system.

Closing is of course not necessary, you can reboot instantly.

> This is what I meant with the message "LVM: How to access a
> foreign volume group", here in this list.

I have not filtered all my messages ;-). I thought it belonged to the
LVM-user group ;-).


I have one warning: the sda5_crypt you supply to cryptsetup open MUST
match that of the installed system (the original system).

If you don't, Grub will complain or update-initramfs might nag about not
finding some device.

In Ubuntu the default is sda5_crypt.

This is the value on the beginning of the line in /etc/crypttab.

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Xen
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Xen
Xen schreef op 09-12-2017 21:02:

> To mount the new root and boot so you can restore the backup there:
>
> - mkdir /target
> - mount /dev/ubuntu-vg/root /target
> - mount /dev/ubuntu-vg/boot /target/boot

Forgot one thing:

- mkdir /target
- mount /dev/ubuntu-vg/root /target
- mkdir /target/boot
- mount /dev/ubuntu-vg/boot /target/boot

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Volker Wysk
In reply to this post by Xen
Am Samstag, 9. Dezember 2017, 16:05:39 CET schrieb Xen:
> That's really all you need to do. Linux has no "special files" that are
> hardcoded on your partition; which means you can just do a *file
> restore* with the one exception that you need to install grub.

That's what I wanted do know.

> > Could I just replace the top level directories with ones from the
> > backup?
>
> Better not do this in the *running* system.
>
> You can do the exact same thing in a live session without interfering
> with any files.

I've tried to access my root file system from a live session (an USB stick). The live session was plain, without LVM or encryption. The root file system is on encrypted LVM, created by the "Guided - use entire disk and set up encrypted LVM" choice in the "Disk Setup" step of the Kubuntu 16.04.3 installer. I wasn'a able to activate the volume group. Regardless of what I tried - vgchange -a y, vgchange, lvs, vgs, vgdisplay, pvs, pvdisplay - all the commands finished with no output.

So, again: How to access the root file system of the system which is to be recovered from backup?

Volker


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Volker Wysk
Am Sonntag, 10. Dezember 2017, 09:29:01 CET schrieb Volker Wysk:
> I've tried to access my root file system from a live session (an USB stick). The live session was plain, without LVM or encryption. The root file system is on encrypted LVM, created by the "Guided - use entire disk and set up encrypted LVM" choice in the "Disk Setup" step of the Kubuntu 16.04.3 installer. I wasn'a able to activate the volume group. Regardless of what I tried - vgchange -a y, vgchange, lvs, vgs, vgdisplay, pvs, pvdisplay - all the commands finished with no output.
>
> So, again: How to access the root file system of the system which is to be recovered from backup?

Silly me! I've just forgotten to unlock the crypto partition first. %-(  I _can_ access the root file system from my USB stick, which doesn't use LVM, and thus doesn't yield a conflict of the volume group names.

Volker


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Volker Wysk
In reply to this post by Ralf Mardorf-2
Am Samstag, 9. Dezember 2017, 20:11:43 CET schrieb Ralf Mardorf:
> I'm not willing to read the whole thread.
>
> IMO it's very simple. Backup everything using another install or a live
> media and restore everything using another install or a live media,
> using something simple as e.g.  cp -ai  or  tar  with xattrs.

I'm using dar, which supports differential backups (other than tar).

 
> The bootloader is an exception, as well as the MBR or what ever you
> are using.
>
> Bootloader as well as MBR or an alternative to MBR should be separated
> steps.
>
> IOW if needed format and partition your disk, restore the complete file
> system using copy, tar or whatever and after that install your favourite
> bootloader.

So it (really) is just this two steps. But the second one is a little more involved.

>
> dd usually is inappropriate, just imagine you need to replace the disk
> by a disk with a completely different geometry.
>
> Note, GRUB not necessarily is the best choice for the bootloader that
> might fit to your needs. I'm using syslinux, even while it's a PITA, it
> still does cause less pain regarding my needs, than GRUB does.


Thanks for the input.

Volker


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Volker Wysk
In reply to this post by Xen
Hi

I can do that. I'll try it on my old laptop now. Thank you for your help!

Cheers
Volker


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to recover with a full backup?

Josef Wolf
In reply to this post by Volker Wysk
On Sun, Dec 10, 2017 at 05:39:36PM +0100, Volker Wysk wrote:
> Am Samstag, 9. Dezember 2017, 20:11:43 CET schrieb Ralf Mardorf:
> > I'm not willing to read the whole thread.
> >
> > IMO it's very simple. Backup everything using another install or a live
> > media and restore everything using another install or a live media,
> > using something simple as e.g.  cp -ai  or  tar  with xattrs.
>
> I'm using dar, which supports differential backups (other than tar).

Actually, gnutar CAN do incrementals. But that's with an extended tar format.

--
Josef Wolf
[hidden email]

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users