How to backup a FreeBSD installation excluding installed packages

I have a FreeBSD installation (13.1) with around 30 pkgs installed. I'm trying to backup the original install but exclude all the pkgs added in the meantime.

I can't figure out how to do this.

I'd appreciate any suggestions.
 
You would have to know where all your packages put and create things and then exclude them. You probably need to define your need a bit more precisely.

If you are ok with an approximate exclusion I think you could get away with excluding /usr/local, /usr/ports (if used), and /var/cache/pkg.
 
dkh provided a simple and good solution. Probably you need to check some another directories like /var/db/pkg/ /var/db/ports/
Usually everything installed by user stored in /usr/local
So it is a fine solution.

Another way:
You can clone current installation and run it somewhere (even as a jail on the same machine) and remove all packages using "pkg delete" and backup the rest.
 
Why backup the OS at all? It's usually quicker and easier to just reinstall than restoring a backup. Only backup your configuration settings.

Besides that, 13.1-RELEASE is end-of-life. You're going to need to upgrade to 13.3 some time soon.
 
I wanted to install 14.0 over the top of 13.1 and wanted to be able to restore in case of major problems...

I've had numerous problems using freebsd-update in the past, and just wanted a quick update.
 
I wanted to install 14.0 over the top of 13.1 and wanted to be able to restore in case of major problems...

I've had numerous problems using freebsd-update in the past, and just wanted a quick update.
If you use ZFS just make snapshot of ROOT filesystem before upgrade.
I had 0 issues doing upgrades with freebsd-update lately.
Done upgrades from 11.4 to 13.2 and 13.3 without any problems. (skipping 12.x stage)_
 
I wanted to install 14.0 over the top of 13.1 and wanted to be able to restore in case of major problems...
How exactly do you want to install 14.0 over the top of 13.1? You don't mention upgrade from source.

Which file system has the target system, UFS or ZFS?
 
If you use ZFS, you can leverage
bectl(8) to create a boot environment. Then you can rollback if something goes wrong.

More details on the FreeBSD wiki
or in this article
 
Not backing up /usr/local/etc and /var is a potential loss of data. You need to be sure you haven't touched the former and you have no services that use the latter (such as database).
 
Backup all changed *.config files on a system level like /boot/loader.conf, /etc/rc.conf, etc.

Make a list of all added packages:

# pkg prime-list > /home/<your_home>/primelist

Backup your home directory;

Re-install a fresh copy of FreeBSD;

After a new installation set back the *.config files and install all packages with

# pkg install "cat /home/<your_home>/primelist"
 
I use boot environments, and back up config files and data. I set up ZFS datasets for data that I care about - home dirs, databases, etc. I build new boot environments cleanly, copy the config files into it, and reboot. If I need to restore from backup, it's pulling the data ZFS datasets and mounting them.
 
Back
Top