Solved How to reinstall all packages from backup directory

Recently I used the below command to copy all of my stored packages to a folder located on a second internal hard drive.
Code:
rsync -avhpo --progress /var/cache/pkg /diskbkp/backup/var/cache

Next I compared the file names stored in my backup directory to the package list I created by using the below command, and both lists appear to be the same.
Code:
pkg prime-list > /diskbkp/backup/package_list.txt

Well, two days ago I really broke my system, and I had to fix it by doing a fresh reinstall, and then using rsync to restore /boot/loader.conf, /usr/local/etc, /home, and /etc to their original locations. I've been through this process once or twice in the past, and it seems to work relatively well for someone at my skill level to recover from a disaster.

Also, when it comes to reinstalling the packages, I've been relying upon the below command to reinstall all of my packages, and this seems to work provided that the file "package_list.txt" is actually located in the root directory.
Code:
pkg install $(cat /package_list.txt)

However, I was thinking that the package reinstallation process would go fastet, if I could use a command to automatically reinstall all of my backed up packages, rather than getting them through the Internet. I'm able to add one package at a time from my backup copy of /var/cache/pkg, but for the life of me I cannot figure out how to reinstall all of the packages in my backup folder all at once. I tried using commands similar to the below, and then my system seems to chug for a few seconds, but no packages seem to get reinstalled using the below method.
Code:
pkg add /diskbkp/backup/var/cache/pkg/*.*

Also, I'm certain that /dev/ada1p1 is being mounted at /diskbkp, so I don't think that there is in an issue with the path being wrong, but something is stopping it from working?

Any advice greatly appreciated.
 
I haven't tested this, but have you tried something like # pkg add `cat /path/to/package_list.txt`?
It should resolve the dependencies as long as you have them in the same directory.

Make sure the entire package_list.txt list has only valid package names or it will fail.
 
but have you tried something like # pkg add `cat /path/to/package_list.txt
No I'm certain haven't tried that yet, but I will next time I manage to break my installation, which will probably be sometime soon, knowing me. I don't think that it is a good idea to execute that command right now, because at the moment my system seems relatively stable, but I will definitely save it in my backup folder.
 
Back
Top