Migrate Packages from Host A to Host B

Page content

How to migrate all Packages

Got several Packages installed on Host A and you would like to migrate them to Host B ? That’s easy :)

Extract on Host A

pkg_info -mz | tee list
ansible--
bash--
...
vnstat--
wget--

scp list HostB:/tmp/

Import on Host B

doas pkg_add -l /tmp/list

Oneline

or you can simple do it in one line, although there are two commands. copy and install

target="host.world"; pkg_info -mz |ssh ${target} "cat > /tmp/list"; ssh ${target} "pkg_add -l /tmp/list"

TwoWaySync

Assume, you have two Hosts with different Packages installed, and you wanna have all Packages installed on both Hosts. So, we need a twoway Sync. remote host

remote="remote.host.world"

twoway sync

pkg_info -mz |ssh ${remote} "cat > /tmp/list"; ssh ${remote} "pkg_add -l /tmp/list"; ssh ${remote} "pkg_info -mz > /tmp/list"; scp ${remote}:/tmp/list /tmp/list; pkg_add -l /tmp/list

Any Comments ?

sha256: 1d25c59d7d6b56eecb06154d26669b7c731c2cd255c9ddf014fd1a202b8f9f10