19 June 2013

Saurav Modak's picture
Posted by Saurav Modak on August 16, 2012
Ubuntu

If you install software from a lot of PPAs, keeping track of them becomes hard, specially when you need to upgrade from one release to another or reintstall your distro for some reason. With just two commands, you can get a list of all PPAs in your system, save them in a file and restore them when needed.

To backup PPAs:

The following commands gives the list of PPAs explicitly installed in your system:

grep -RoPish "ppa.launchpad.net/[^/]+/[^/ ]+" /etc/apt | sort -u | sed -r 's/\.[^/]+\//:/'

To put them in a file, add > filename.txt in the end:

grep -RoPish "ppa.launchpad.net/[^/]+/[^/ ]+" /etc/apt | sort -u | sed -r 's/\.[^/]+\//:/' > backup.txt

To restore from backup and add all repositories that you have backed up:

<~/ppa-backup.txt xargs -I % sudo add-apt-repository %

Handy after upgrades!

Tags: 

Saurav Modak

Saurav Modak is an engineering student and FOSS enthusiast who believes that best things in the world, such as software should be free (as in freedom). He is a hard core Arch fan and loves to show off his customized Arch Linux installation to friends. You can connect with Saurav on Facebook, Google+ and Twitter.