Ubuntu: Backup all your Applications 08/30/2010Posted by dared in Guides.
Lets say you have set up your *buntu box. Now you want to backup all the installed deb files so that you can restore them quickly and efficiently.
For one thing it would be easier to install everything as you would not have to go online and hunt for them. Further it would be useful where a computer does not have internet connection. In ubuntu “hunting” for programs is a rare occurrence thanks to the fantastic package managing system. However, you may personally have some programs that you have either compiled from source (using checkinstall, so that that a deb package is created and they are added to APT), or downloaded debs from obscure locations. Now each of these debs you will save in a directory so that in the future you do not have to go hunting for them. However, this command I have outlined backs up ALL packages, 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/etc codecs. Further you have installed some basic useful software. Now lets say you want to install the SAME setup on your grandmothers computer, except she does not have internet connection, or at the time you go to set it up she does not have a net connection. Using this script you can have all your debs in one simple location, so you will not have to redownload everything.
Secondly, lets assume you work for a school, or a company, and you need to install the SAME ubuntu installation 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.
These commands will do that for you.
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`
(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.
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
Thanks to abhiroop from The Ubuntu Forums for this beautiful workaround.