
Debian is the most popular architecture for Linux. It provides a mix of ease of use with integration with different API’s and GUI’s. This is a simple tutorial to create a package backup from any Debian based system.
Although, ubuntu comes with an application “APTonCD” which creates a backup of all your packages, the application requires the packages to be present in the apt cache. Other applications are also available though, they are not user friendly. Here is an easy solution with a command line application dpkg-repack.
- Download and install a small package “dpkg-repack” from the repositories. Download here.
- Download and run a shell script i have created for you. Download here. (Make sure you have enough space in the disk you are running it from, double click and open in terminal.)
- You are all set with a complete debian package backup.
[ad# inposttext-ad]
Now analysing the shell script :
- dpkg-repack: is used to repack installed files into debian packages.
- dpkg –get-selections: is used to get a list of packages on the system into stdout(standatd output)
- grep install: grep matches the output for the text “install”
- cut -f1 cut -f1: cuts the second column, which is the one with the text install.
The complete command is
dpkg-repack `dpkg --get-selections | grep install | cut -f1`
You can execute this line at your terminal.
Once you have this backup, you would also want to reinstall it later. To reinstall packages simply navigate to the folder and do a:
dpkg -i *.deb
Your packages along with your settings will be back.
Chinmoy Kanjilal is the geek behind Techarraz. This is where he rants about his adventures with technology. Get to know him better, and connect with him on social networks.
Thanks for the how-to. As a linux n00b, I just wondered what folder everything was being backed up to. Can I use this procedure to back the packages up to something external, say a DVD, a USB stick or a second hard drive?
Sure. You can specify the path to the drive where you want to backup.
Well, yes. You can create this backup anywhere you want. Just run the file or the command from the location you want the backup to be made to..
For a DVD drive, you need to backup to a drive first and then you can write it to a DVD.
Very good to know, thank you! Also nice how you explain the subcomponents of the command: it’s nice to know exactly what is happening in case something goes wrong.
Probably easier to do
# sudo apt-get install dpkg-repack
than download and install package manually though…
For greater n00bs than myself, you might also include instructions on setting up a cronjob for this.
Anyway, thanks again.
Redge
Oh surely. Thanks for the advice. Please keep visiting and commenting.
Thanks for answering my query. Should be able to manage that now.
thanks for the wonderful post .. wrks out great …well you already did all the coding all we needed to do is to run the script .. thanks once again
so…can we reinstall old ubuntu version to newer version of ubuntu and then restore our old installed package with this?
Well,the package backup you create with this will also contain the linux kernel modules. So if you install the backup, your previous kernel will appear too.
Thanks for sharing, simply amazing