# Ports backup using ZFS



## kreoso (Dec 15, 2011)

Hello, I'm new to FreeBSD and enjoyed it very much, but I found that uninstallation of a port is not easy, cause of the dependencies. There is also some ports like pkg_cutleaves, but you have to know the dependencies anyway.

So, I think it is better to make the relevant directories into ZFS subvolumes and snapshotting before & after the installation of a port, and if something goes wrong or you don't need it anymore, restore it from the snapshot. 

My question is, which directories are relevant for this. I believe /var and /usr except /usr/home should be there, but I'm not sure for other directories such as /etc, /bin or /sbin, etc.. 

any clues or are there better solution for this job?


----------



## plamaiziere (Dec 15, 2011)

kreoso said:
			
		

> My question is, which directories are relevant for this. I believe /var and /usr except /usr/home should be there, but I'm not sure for other directories such as /etc, /bin or /sbin, etc..
> 
> any clues or are there better solution for this job?



Ports are installed in /usr/local, with the exception of linux binairies going in /compat/linux (which is a symlink to /usr/compat on 8.X).

The ports database is in /var/db/.

So with a snapshot of /usr and /var you should be able to restore. For /home you may use a /home mountpoint, with zfs that is easy.

Regards


----------



## gkontos (Dec 16, 2011)

That would be the /usr/local directory. This is were all binaries and configuration files are stored during software installation. Some software will create directories under /var as well.


----------



## t1066 (Dec 16, 2011)

Some ports like nvidia-driver and virtualbox would also install in /boot/modules.


----------



## fluca1978 (Dec 16, 2011)

kreoso said:
			
		

> So, I think it is better to make the relevant directories into ZFS subvolumes and snapshotting before & after the installation of a port, and if something goes wrong or you don't need it anymore, restore it from the snapshot.



This is how OpenSolaris (and I guess also Solaris) works for a full update. What is done is a kind of full snapshot of the system, the creation of a new boot environment so that you can even change those part of the system that you don't want to remember of, and you can get back in time. So not only you can restore your previous configuration, but you can even boot it and see how it worked without having to touch the final configuration.
By the way, snapshotting /var and /usr/local should suffice. I would add /etc if you don't already backup diligently configuration files, since usually adding a new program via ports mean you are going to enable some services and/or adjust some firewall rules.


----------



## gkontos (Dec 16, 2011)

There was a relevant project for FreeBSD. I haven't really followed it, therefore I can't express any opinion about it.


----------

