creating new server using pkg backup file

Hi, the idea is to create backup file for pkg to export the file to newly created freebsd server and install all packages from the file.

from pkg-backup man page it seems to suggest running
pkg backup -d ~/installed-pkg-list.sql
would create a usable backup file in /root (assuming it was run as root).

When it is run, the file is in

Isn't it the case using the -d tells pkg which directory to store the backup file?

You're misunderstanding pkg-backup(8), it's used to backup the package registration database. Not the packages themselves.
Hi SirDice, ok understood.
Perhaps then you can recommend a solution for this.
Have perfectly good FreeBSD Server which runs apache22. Just created a new FreeBSD 10.3 VM and want to replicate everything needed for web sites to function. Thing is, want to use apache24.

Used the example from man portmaster to create a list and then rsync the list to new FreeBSD Server and run portmaster -d --no-confirm `cat ~/installed-ports-list` Its currently running and installing the ports. But all the packages are missing since there is no way to restore pkg's installed like there is with portmaster.

The other thing is, can apache24 be installed while apache22 is installed? Of course with apache22 not running. I am not sure at this point how our http conf will work with apache24.

I highly recommend using ports-mgmt/poudriere or ports-mgmt/synth to build your own package repository. This has several advantages, you build everything from ports so you have all the freedom to enable/disable options and change the defaults. You have centralized control over updates (you decide when and where to update the ports tree and do a new package build). With poudriere you can even build the same packages for different systems (FreeBSD 10, 11, amd64, i386, even ARM nowadays). Once everything is completed you have a neat package repository you can use over and over again for as many clients as you like. Build once, install many :D

The other thing is, can apache24 be installed while apache22 is installed?
No, unfortunately not.
CONFLICTS_INSTALL=      caudium14-1.* \
 	                apache-*-2.2.* apache22-*-2.2.* \
	                apache-*-2.4.* apache24-*-2.4.*
Configuration files are separate though, /usr/local/etc/apache22/ and /usr/local/etc/apache24/.
I am not sure at this point how our http conf will work with apache24.
I've done quite a few Apache 2.2 -> 2.4 migrations now, it's mostly backwards compatible so there's actually very little chance it won't work. One thing to watch out for are the ACLs. These are different on 2.4 and may need adjusting. But you can use mod_access_compat to make 2.4 compatible with 2.2 ACLs. Another option is to use conditional configuration statements to allow the same config to be used on 2.2 and 2.4.
If you want something simple how about pkg prime-origins > pkg-list on the first server, copy the pkg-list file to the second server and then run pkg install < pkg-list ?

The prime-origins alias is only on later versions of pkg. If it's too old then use pkg query -e '%a = 0' '%o' instead.

However +1 for ports-mgmt/poudriere or ports-mgmt/synth.