jump to navigation

Ubuntu: Backup all your Applications 08/30/2010

Posted 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.



1. metamba - 08/30/2010

a good alternative program that does backups and can create a redistributable copy of ur installation is remastersys.

2. artwales - 08/30/2010

Making backups on Linux has been of much concern to me. In windows, i didnt mind shelling out about $50 to purchase ACRONIS, probably one of the best imaging softwares on the windows platform.
I use Linux mint 9 and it comes with an app that has about the same functionality with the one you mentioned in your write up,it even comes with a ISO IMAGE creation functionality.It’s called APTONCD. My gripe with this app is that i cannot make the OS recognise my external DVD writer as a software repository. I use an ASUS UL30A-X5, it does not come with a DVD writer inbuilt.
My major hurdle now is how to use partimage to back up my OS. I am a newbie to Linux, well, maybe a senior newbie, CLI is still a bit scary to me. I tried using partimage, there was not an option to backup the drive as a whole,like we have in acronis, instead i was prompted to backup partitions. Can you walk me through the process of backing up and restore? Better still, can you do a pictoral write up on back up process on Ubuntu and its derivatives?

3. misaac - 08/30/2010

sounds great, will try it out. I have been using APTONCD like artwales but, it doesn’t reinstall chrome for me for some reason. I hope this does.

And yeah, I second our creating a backup tutorial.

4. dared - 08/30/2010

of course there is no denying that there are so many backup tools out there – depending on preference. This article was actually written for one 4llerbuntu on Nairaland that wanted all his applications and settings after a fresh install. APTONCD is good but it really doesn’t work as well once you have cleared your package cache and some do that once in a while to free up space.

The reason i like this was i tried it twice and same time i didn’t even need to download kernel headers as it restored the latest updates, codecs and plugins too.

muyiscoi - 08/30/2010

so r u saying that partimage recreates .deb files of installed apps even though you have cleared out the apt cache?

5. misaac - 08/30/2010

wow. And you said this command:

fakeroot -u dpkg-repack `dpkg –get-selections | grep

might take some time. Please change that to might take the whole day.

I’ve been running the command for like 2 hours now and it hasn’t finished yet!

All it is showing me is:

mbuotidem@NET-SERVER-PC:~/dpkg-repack$ fakeroot -u dpkg-repack `dpkg –get-selections | grep

I just hope my gen fuel doesn’t finish b4 it finishes sha.

6. Metamba - 08/30/2010

Pls check out remastersys http://www.webupd8.org/2010/08/create-full-system-backup-or-custom . I have used it a number of times. It is fast n works like a charm.

dared - 08/30/2010

metamba, link’s not working

7. muyiscoi - 08/30/2010

someone should create a GUI for this. it will make one hell of an app. I think i kinda prefer this to remastersys in some cases cos it only saves me d trouble of redownloading all my apps but doesnt completely mirror d OS on d new install like remastersys does.

8. misaac - 08/30/2010

hi all, please who has actually used this and succeeded. I have just a few packages on my system and my system is real fast yet this is like 3 hours now and all my terminal is saying is:

mbuotidem@NET-SERVER-PC:~/dpkg-repack$ fakeroot -u dpkg-repack `dpkg –get-selections | grep

with the cursor blinking.

I browsed to the location of the folder but’s there isn’t even 1 file in it!

please, if anyone has any idea what could be wrong, i would be interested.

muyiscoi, please, doesn’t remastersys save the trouble of redownloading? I’ve never used it b4 and want to try it out.

dared - 08/30/2010

sorry that command ought to be

fakeroot -u dpkg-repack `dpkg –get-selections | grep install | cut -f1`

sorry for the mix up.


9. dared - 08/30/2010

pls replace that final command with this

fakeroot -u dpkg-repack `dpkg –get-selections | grep install | cut -f1`

sorry about the error. let me know how this goes please.

10. misaac - 08/30/2010

ok. thanks.
Here is what I got:

mbuotidem@NET-SERVER-PC:~$ fakeroot -u dpkg-repack `dpkg –get-selections | grep install | cut -f1`
dpkg: need an action option

Type dpkg –help for help about installing and deinstalling packages [*];
Use `dselect’ or `aptitude’ for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg –force-help for a list of forcing options;
Type dpkg-deb –help for help about manipulating *.deb files;
Type dpkg –license for copyright license and lack of warranty (GNU GPL) [*].

Options marked [*] produce a lot of output – pipe it through `less’ or `more’ !
Usage: dpkg-repack [options] packagename [packagename ..]
–root=dir Take package from filesystem rooted on .
–arch=arch Force the parch to be built for architecture .
–generate Generate build directory but do not build deb.
packagename The name of the package to attempt to repack.

misaac - 08/30/2010

anyone with an idea as to how to get it working?

would have used remastersys but the pc im trying to copy to is a laptop and its drive is dead.

11. misaac - 08/30/2010

dared , thanks for correcting the tutorial. it’s working now!

12. Metamba - 08/31/2010

You can use remastersys to give u an iso of ur software. U can then create a live usb using unetbootin, usbcreator, multiboot etc

13. Metamba - 08/31/2010

After that you can install via usb-flash. do this all the time

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: