7

I don't know if the terminology as in "snapshot" is correct for this, if not, please, feel free to correct me.

Is there a way that I can, like "save" the state of my linux install, like an image, so if necessary I can go back? And just to point it out: that's a hard drive install we are talking about :)

Thanks!

2 Answers2

6

The only all-in-one solution I know of is a third-party application TimeShift. It's most comparable to system restore on Windows and time machine on Mac OS X.

TimeShift is a system restore utility which takes incremental snapshots of the system using rsync and hard-links. These snapshots can be restored at a later date to undo all changes that were made to the system after the snapshot was taken. Snapshots can be taken manually or at regular intervals using scheduled jobs.

This utility is designed to protect only system files and settings.

If your looking for a tool instead to make a snapshot of your user files, I would suggest taking a look at some of these alternatives: rsnapshot, Back In Time and TimeVault.

COil
  • 117
0

This depends a bit on your setup, and how exact you need to be about it. One way which will work would be to boot off a USB pen, and then do a backup of the block device (normally, but not always /dev/sda).

There are a few ways to do this. If this is a "one off", The simplest way is:

  1. In your Linux install, dd if=/dev/zero of=/tmp/del.me (This will take a LONG time as its creating a large file with zeros). The system will eventually run out of space and die with an error. THIS IS GOOD !!
  2. rm /tmp/del.me
  3. Reboot with Linux based USB system. Plug in your backup disk.
  4. If your data is on /dev/sdaX, and your backup disk is mounted as /mnt /backup_disk execute the command cat /dev/sda | gzip -c /mnt/backup_disk/initial-ubuntu-install.gz to create an image. Once this is eventually done, unmount the backup disk and you have an image called initial-ubuntu-install.gz.

To recover from this backup later on, boot from a USB disk and execute the command zcat /mnt/backup_disk/initial-ubuntu-install.gz > /dev/sda

Steps 1 and 2 above zero out the unused disk to make it more compressable. They are optional, but will probably result in a way smaller compressed backup image.

Step 4 creates a compressed backup image. It is crude and does not give any indications of progress, but it uses standard tools which come with only a regular install. If your USB has pv (or you apt-get install pv) you can replace the command with pv /dev/sda | gzip -c /mnt/backup_disk/initial-ubuntu-install.gz to give you an indication of progress, similarly for decompressing you can use zcat /mnt/backup_disk/initial-ubuntu-install.gz | pv > /dev/sda

There are other, more complex ways of doing this excercise depending on if it needs to include everything, or just most stuff, but these techniques are more advanced.

I will confirm that Linux does have the idea of snapshots using "Logical Volume Management", and its not uncommon (but not required) for the root partition to be installed on a logical volume. IF you have Logical volumes installed you can take snapshots and back those up - BUT THERE IS A CATCH. Ubuntu can't boot off a Logical Volume, so it needs a small additional partition (typically mounted as /boot) to boot. In order to make this work you would need to -

  1. Take a dump of the disk geometry.
  2. Back up the /boot partition.
  3. Create a snapshot and then back it up.
  4. Destroy the snapshots.

[ Linux snapshots create a temporary copy of the exact state of a partition, they do not create an image for backing up - rather you need to take the snapshot and back it up as you would a partition - the only difference is that you can operate on a live OS, rather then booting to a USB key.

davidgo
  • 73,366