Wednesday 18 September 2013

Backup Package List on Debian

Using dpkg

One thing we do on both our servers and workstation is to backup the installed package list in case we need to rebuild the system we can make sure it has exactly the same programs available.

Using dpkg which is the Debian package manager we can dump a list to a standard text file ready for backup, for us we use Google Drive for our backup remote storage so the list will also be backed up there.


dpkg Package Manager

The Backup

We have added package backup to our server backup system and to do the actual backup is as simple as running a single command. This will dump the package list to a text file named package_list.txt
root@chic:~# dpkg --get-selections > package_list.txt

The Restore

To restore the installed packages on a fresh machine is just as simple you just use the set-selections switch when running dpkg. After running dpkg we update our package list and upgrade the system.
root@chic:~# dpkg --set-selections < package_list.txt && apt-get update && apt-get -u dselect-upgrade


Conclusion

This article show how simple a task it is to backup your installed programs so if you need to start fresh you can make sure the programs you had installed are installed again and hassle free to.

In a future article we hope to cover our system restore scripts which can be used for setting up a clean Debian minimal network install into a production ready server.

No comments:

Post a Comment