Date: Thu, 11 Feb 2010 10:15:12 -0600 From: Adam Vande More <amvandemore@gmail.com> To: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: python script to backup installed packages Message-ID: <6201873e1002110815l312da12fr5388956f32465516@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Sometimes you have need to backup installed packages. I realize most port management tools do this automatically, but if you're on a system with a lot of packages installed and one port management tool fails and you use another to fix it, /usr/ports/packages can become jumbled. Anyways, I've written a simple python script which will create a fresh snapshot of all installed packages. These are convenient for backups or installing on a new system. For anyone interested: from subprocess import Popen, PIPE import os s = Popen('pkg_info -a | grep : | grep Information',shell=True,stdout=PIPE).communicate()[0] pkg_location = '/data/packages' packages = [] for line in s.split('\n'): info = line.replace('Information for ', '').replace(':','') packages.append(info) os.chdir(pkg_location) for package in packages: s = Popen('pkg_create -b ' + package,shell=True,stdout=PIPE).communicate()[0] -- Adam Vande More
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6201873e1002110815l312da12fr5388956f32465516>