Ubuntu – How to backup the PPAs

backupppa

Related to this question. But my concern is that over the past year, most of my more interesting (or used) applications are from PPAs, and just backing up my sources list won't add the associated launchpad keys the way that add-apt-repository does.

So I'm looking for a way to list all the PPA urls (like ppa:chromium-daily/stable) so that I can easily script a series of add-apt-repository commands to add them into a new installation gracefully.

Short of dumping my bash history of course. Which might be feasible, depending on how far back that file goes back?

Best Answer

Well because I like mucking around with command line scripting, I've written the following. It generates a list of PPA strings that you could backup and then script into add-apt-repository:

grep -RoPish '(?<=ppa.launchpad.net/)[^/]+/[^/ ]+' /etc/apt | sort -u | sed 's/^/ppa:/'

That'll generate something like:

ppa:ubuntu-wine/ppa
ppa:am-monkeyd/nautilus-elementary-ppa
ppa:nilarimogard/webupd8
ppa:ubuntu-x-swat/x-updates
ppa:tualatrix/ppa
ppa:banshee-team/banshee-unstable
ppa:chromium-daily/beta
ppa:libreoffice/ppa
ppa:banshee-team/ppa

If you ever wanted to blanket-restore those, you could pipe them back into the system like so (assuming we saved the PPAs to ~/ppa-backup.txt:

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

I would probably suggest you don't just restore them all. Look through the backup and make sure you know what each PPA contains.

Related Question