LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to Create System Recovery Partition in Linux Ubuntu (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-create-system-recovery-partition-in-linux-ubuntu-4175452606/)

melodyintrance 03-04-2013 03:52 AM

How to Create System Recovery Partition in Linux Ubuntu
 
Hi folks, I've recently switched my HTPC from Windows 7 to Ubuntu 12.10 64bit. I want to create a snapshot of the OS partition so I can easily restore if needed.

My HTPC has 1 hard disk which has 3 partitions.
1. 70GB Ubuntu (7GB used)
2. 2GB Swap
3. 75GB New (Unallocated)

I would like to achieve the following:
  1. Choose from a boot loader (Grub2 in this case) and select the "Backup" option.
  2. Either Clonezilla or similar loads and automatically creates a backup of the Ubuntu partition
  3. The backup image is saved locally AND on the NFS filie server
  4. The backup image is compressed so it only backs up the 'used' content instead of the entire 70GB
  5. Choose from the boot loader and select "Restore" option which obviously repeats the process above except it restores from backup image.

I've been reading through my copy of the Linux Bible and other tutorials and I want to put some of this theory into practice.

So far I was thinking of doing the following:
  1. Add Grub2 option to boot from clonezilla live iso
  2. Run saved script or command line in clonezilla to perform the backup into the other 75GB partition and NFS server.
  3. Run saved script or command line in clonezilla to perform the restore from the other 75GB partition or NFS server.

Am I on the right track? Could someone suggest best practice approach for this outcome?

Cheers, Pete

schneidz 03-04-2013 10:02 AM

i would add zeros to the end of the disks like so:
Code:

dd if=/dev/zero of=some/big/file
rm some/big/file

then i would image backup the disks like so:
Code:

dd bs=8192 if=/dev/sdd | bzip2 > xbmc-01.05.2011.iso.bz2 # to create the image
bunzip2 -c ./xbmc-01.05.2011.iso.bz2 | dd bs=8192 of=/dev/sdd # to restore the image

warning: this is a very destructive process; you need to be triply sure that you are restoring to the correct devices.

thorkelljarl 03-04-2013 02:37 PM

Why not backup...

You can of course make a system recovery partition on your present HDD, but I would think that you'd be better off if you instead relied on a good chronological backup program for your system or for its important files.

As a true backup, on another HDD, internal or external, you guard against failure of your HDD. That is the total loss of everything on your system. not just an annoying but repairable episode you can fix with a recovery partition.

Unless you're running a server or some critical always-on application, I wouldn't think you'd have to worry about your linux OS going down, causing chaos, taking everything with it and loosing your files. That is unlikely; your linux installation is more robust than Windows and if needs be, easier to re-install.

I could always add that as a wise and experienced linux user you already have backup and really only need to think of a way to configure it to satisfy your current wishes. Could I be wrong?

I use the program Back in Time which is incremental but doesn't use compression, copying to an external HDD with an SATA connection. The files being without compression makes it easier for me to copy everything back to my installation HDD as I want. When the time comes, I can just format my HDD to do a new installation of openSUSE or mess things up by fooling around with some new distro.

goumba 03-04-2013 03:29 PM

Quote:

Originally Posted by schneidz (Post 4904425)
i would add zeros to the end of the disks like so:
Code:

dd if=/dev/zero of=some/big/file
rm some/big/file


Isn't there a tool zerofree or such that makes it a one step process?

schneidz 03-05-2013 01:57 PM

Quote:

Originally Posted by thorkelljarl (Post 4904568)
Why not backup...

You can of course make a system recovery partition on your present HDD, but I would think that you'd be better off if you instead relied on a good chronological backup program for your system or for its important files...

i agree, however i have a 2 gb xbmc live-usb that i made an image backup with so that if it flakes out i can restore it in about 5 minutes without having to re-install all the add-ons and re-edit the different config files...

the internal hd has 250 gb of movies and music that is also saved on my phone, camera and mp3 players. so that if i accidentally delete something i can manually copy it from wherever.

i think images make sense when they are as small as possible and they contain just the core os and various configs.

incremental backup makes sense for actual data recovery.

melodyintrance 03-13-2013 06:57 AM

Thanks for your replies everyone.

This HTPC is dedicated to run XBMC and act as the upnp server. So far it's only using around 7GB in total. I bet I could make it leaner too because it has ubuntu unity desktop environment installed which is a waste of space. The media is stored in a separate Freenas server.

I have to lean towards Schneidz that making a partition image backup would be ideal due to the considerably small 'used partition space'. Maybe what I'll do is reduce the size of the main partition from 70GB to 8GB. This way the image of the partition will be small and I can write a script to alert me when the partition is running low on space or perhaps automatically grow the partition size by booting into gparted iso...

I came across this post http://ubuntuforums.org/showthread.php?t=1549847 which shows you how to create a grub 2 option to boot to an iso (maybe clonezilla or ghost4linux) so I'll test out this tomorrow and report back.

jpollard 03-13-2013 04:20 PM

Don't forget you need a system with enough capability to restore it...
And you better test it when you do.

melodyintrance 03-24-2013 09:49 PM

Just thought I've give you guys an update.
 
Hey folks, I've had a hell of a learning experience over the past week!

This is what I've managed to do so far:
  1. created ext4 partition for 'system rescue live ISO'
  2. created grub2 entry to boot into the 'system rescue live' session
  3. created a sh script to mount my nfs file server to /mnt/backup
  4. run fsarchiver to save sda1 to nfs backup folder (sda1 is the XBMC partition)

When the system rescue boots (from sda3) it runs the xbmc_backup.sh which sits on the nfs fileserver but only after I manually mount the nfs partition.

Things to do:
  1. Find a way to add my 'mount -t nfs...' command into the stab of 'system rescue' so it's persistent.
  2. Find a way to automatically shut down XBMC and boot into the 'system rescue' session and automatically perform backup and once finished restart the XBMC session.
  3. Find a way to replace 'system rescue' with a smaller live session that is only command line or compile system rescue live without X11 / gui


fsarchiver backed up the xbmc partition (used 4.8G out of 9.8G) and saved a compressed backup file less than 3.0G. The backup ran for around 11 minutes.


All times are GMT -5. The time now is 02:04 AM.