How to backup & restore a list of installed FreeBSD packages

How to backup & restore a list of installed FreeBSD packages

To back up a list of installed FreeBSD packages, you can use the pkg info command to generate a list of the installed packages and their versions, and then save the output to a file. For example:

ref‮:ot re‬lautturi.com
pkg info > installed-packages.txt

This will create a file named installed-packages.txt containing a list of the installed packages and their versions, one package per line.

To restore the packages from this list, you can use the pkg install command with the -y flag to install all of the packages in the list. For example:

pkg install -y $(cat installed-packages.txt)

This will read the installed-packages.txt file, and install all of the packages listed in the file. The -y flag tells pkg to assume "yes" to all prompts, so the packages will be installed without requiring any further input.

Note that this method will only restore the packages themselves, and not any configuration files or other data associated with the packages. If you want to back up and restore the entire system, including configuration files and other data, you may want to consider using a tool like freebsd-update or tar to create a full system backup.

Created Time:2017-10-28 21:38:58  Author:lautturi