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!

  • There used to be something that did this called remastersys, and it only worked on ubuntu and debian. Original developer stopped working on it but this seems to be a working fork github.com/chamuco/respin. I'll post a better answer once I've gotten around to testing it. – Journeyman Geek Oct 23 '15 at 6:34
  • Very well @JourneymanGeek Thanks for your reply. I'll take a look at it as soon as possible :) – user512585 Oct 24 '15 at 4:10
  • Let me know if it worked for you. I'll post a fuller answer when I get around to setting up a full fat (k)ubuntu system to test. – Journeyman Geek Oct 24 '15 at 4:11
  • All right! I'll inform you about how the quest goes :) – user512585 Oct 24 '15 at 4:22
  • Hello @JourneymanGeek I have not tried any solutions... I don't know if I'll really do it for personal aspects reasons... but if I do I'll try to remember to come back and update you!!! Thanks – user512585 Dec 29 '15 at 15:26
up vote 4 down vote accepted

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.

  • So @RyanStott My ideia is to simply get system files and settings (at first at least, don't know if will need it differently in the future) backed up. Thanks for your information, I'll take a better look and I'll post back if I am able to succesfully do what I need, with any tool that I may try :) – user512585 Oct 24 '15 at 4:14

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.

  • Hello @davidgo, thanks for your elaborated information. So, for what I understand of what you said there's a little bit of a problem that won't let it work: my system is encrypted. I guess it won't work at all in this situation right? (Unless at some point a prompt asking for the key pops up) Your answer can be though very useful for someone with other set up. Sorry not to have mentioned the encryption bit... – user512585 Oct 24 '15 at 4:18
  • Everything I said will still work, but there is no point in bothering with steps 1 and 2, and you will have a large image file - effectively, compressed files don't compress as they are more-or-less indistinguishable from randomness. – davidgo Oct 24 '15 at 4:43

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.