Wednesday, December 17, 2008

HOW TO: Backup all installed .DEB packages

Problem:
Lets say you have set up your ubuntu installation with all the packages you need. Now you want to backup all the installed deb files so that you can restore them quickly and efficiently.

Why would you want this?
When I was using windows I had a directory of every single program that I had downloaded and installed. For one thing it would be easier to install everything as I would not have to go online and hunt for them. It would also be useful when a computer does not have internet connection. In ubuntu "hunting" for programs is a rare occurrence thanks to the fantastic package managing system. However, I personally have about 20-30 programs that I have either compiled from source (using checkinstall), or downloaded debs from obscure locations. Now each of these debs I will save in a directory so that in the future I do not have to go hunting for them. With this command all the installed packages are backed up, including the ones in the package manager. So, why would you want that?

Firstly, this is very useful if lets say you have setup a very basic installation with all updates, and all non-free video/audio codecs. Further, you have installed some basic software. Now lets assume you want to install the same setup on someone's computer who does not have internet. Using this script you can have all your debs in one simple location, so you will not have to re-download everything.

Secondly, lets assume you work for a school, or a company, and you need to install the same ubuntu installation (with the same software) on 30 computers. Wouldn't it be easier to simply put all these debs in a central server and issue the dpkg -i *.deb command. This way you don't have to individually select the packages and the packages don't have to download.

Thirdly, (and this is purely personal) I like to be able to have all my installed packages at hand. This command doesn't take much effort, and for me it only requires 1.4 gb of space, so for a bit of piece of mind I can easily have all my packages on hand. There is no real reason to do this if you are already doing a full system backup (e.g. an image of your Ubuntu partition using partimage). This is just something I discovered and feel could be beneficial to other users.


Solution:

Open a terminal and paste the following into it:
$ sudo apt-get install dpkg-repack fakeroot
$ mkdir ~/dpkg-repack; cd ~/dpkg-repack
$ fakeroot -u dpkg-repack `dpkg --get-selections | grep install | cut -f1`[/code]

(the last command will take some time)

Now if you scroll to your home folder, you should find a folder called "dpkg-repack" which should have all the deb files of all your installed packages.

Re-Install

If you want to re-install the packages, navigate to the folder with the packages and input the following command in the terminal:
$ sudo dpkg -i *.deb

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Many interesting things on this one blog..Very well effort..Looking forward to have some more information from your side in future..
    hard drive recovery dallas

    ReplyDelete