So, someday you installed Arch Linux, got aroused and played with it, throw some bleeding edge stuffs just for testing, and after hours of vi abuse you just realized that what was once a sleek Arch now tainted with various whatever stuff you threw at it, and at that point you’d hope you can restore it the way it was without reinstalling it and start from scratch.

That’s where this simple article comes. It’s by no means a super cool technique, just a simple routines I perform in case of what I describe above happens. I, for one, have experienced it so many times it’s quite frustrating. The idea is to “snapshot” your installation at specific times. I use Arch Linux, and I guess it’ll work for basically anything except Windows and OS X. Why bother? Who uses them, anyway? Okay back to the topic. For this to work, you only need patience. Everything else is already built in.

How to backup

The simplest thing in backing up your system is by tarball-ing it! My favorite combination, tar + bzip2. Fast, no nonsense, just get the job done. Tarball your root partition, keep the permissions intact, and there you have it! A snapshot.

cd /
su
tar cvpjf arch.190508.tar.bz2 --exclude=/arch.190508.tar.bz2 --exclude=/{proc,sys,home,lost+found} \\
--exclude=/mnt/{temp,docs} --exclude=/var/cache/pacman/pkg --exclude=/vmc /

I have separate partitions for home, pacman’s pkg, and vmc. The temp and docs are separate harddisk. It should be pretty self explanatory, the above command will tarball your system while excluding some directories. The omitted dirs must be recreated again at restoration process. Now put this tarball somewhere safe.

How to restore

  1. Boot using Arch’s install CD.
  2. Create 2 dirs under /mnt, src and dst
  3. Mount your source partition which contains the tarball created above, to src
  4. Mount your target partition to restore the tarball to dst
  5. You can rm -rf the target partition, or use cfdisk before mounting, or whatever means you like, just clean the destination part
  6. Suppose your tarball is located at /mnt/src/arch.190508.tar.bz2, then run this command
  7. tar xvjf /mnt/src/arch.190508.tar.bz2 -C /mnt/dst
  8. Reboot using Arch’s install CD, chroot to the restored partition, reinstall grub
  9. Okay now you have restored your Arch system as it was when you made the tarball. Don’t forget to recreate the omitted directories you specified when creating the backup.

Some tips

You can actually use this method to clone your Arch install to different partitions, even computers. Mass cloning is also possible. In that case, you might edit, to reflect the new setup, fstab and menu.lst, if you use grub. Lilo? I don’t know about lilo, what is it?

Scenario

  1. Err, these are what I actually did some 3 days ago.
  2. Fresh install of Arch, only base system. Nothing else. Eats 516MB of harddisk space, tarballed to 98MB of bz2 file, arch.base.tar.bz2
  3. Install X, Xfce, and various apps needed. Total install size grows to 1.9GB, tarballed to 323MB of bz2 file, arch.xfce.fresh.tar.bz2
  4. Do some customizing, tweaking, optimization, whatever, tarballed to arch.xfce.custo.tar.bz2
  5. Decided to try KDE instead, Xfce looks kinda lame (’coz of constant exposure), KDE4 looks particularly eye catching. Believe the pacman power can uninstall whatever packages installed, but resort to fresh install instead. Poor guy. Restore the arch.base.tar.bz2 and install KDE4 instead.
  6. After some time, come into senses that everything but Xfce sucks, and decided to go back to Xfce, so the system is restored using arch.xfce.custo.tar.bz2
  7. Compute happily

Disclaimer

These are just rants, ramblings, and mumblings of an average Linux user. Do not take them too seriously :)

Update

Here is the final script, as of now, looks like:

cd / && tar cvpjf /mnt/docs/Image/Arch/arch.basic.261008.tar.bz2 --exclude=/{home/bluekurv,home/prasetya,root,loop,lost+found,mnt/docs,proc,sys,tmp,var/cache/pacman/pkg,}/* /

The logic: go to /, tar+bz2 and preserve permissions of entire thing under / with the exceptions of the *contents* of these folders (the –exclude list), and put it in /mnt/docs/Image/Arch as file arch.basic.261008.tar.bz2. Phew.

You no longer need to recreate the omitted directories, as the backup process now only omit the *contents* of the directories specified in the exclude list.

 

 

2 Comments + Hide/Show

  1. i wonder whether fedora can do like that as well ?

     
     
  2. Hm, logically, it can be applied to any Linux distro, but don’t take my word on it, I’ve tested it only on Arch.

    My current Arch installation is 1.9 GB in size, full fledged, and has been cloned to various PCs and laptops. They all work fine, after a bit of tweaks here and there..

     
     

 

Go to Top