// to display images directly on GitHub
ifdef::env-github[]
:encoding: UTF-8
:lang: en
:doctype: book
:toc: left
:imagesdir: ../images
endif::[]

////

    This file is part of the PacketFence project.

    See PacketFence_Installation_Guide.asciidoc
    for authors, copyright and license information.

////

//== Appendix

[appendix]
=== Administration Tools

==== pfcmd

`pfcmd` is the command line interface to most PacketFence functionalities.

When executed without any arguments `pfcmd` returns a basic help message with all main options:

----
include::pfcmd.help[]
----

The node view option shows all information contained in the node database table for a specified MAC address

  # /usr/local/pf/bin/pfcmd node view 52:54:00:12:35:02
  mac|pid|detect_date|regdate|unregdate|status|user_agent|computername|notes|last_arp|last_dhcp|switch|port|vlan|dhcp_fingerprint
  52:54:00:12:35:02|1|2008-10-23 17:32:16||||unreg||||2008-10-23 21:12:21|||||

[appendix]
=== Restoring a Percona XtraBackup or Mariabackup dump

If you enabled Percona XtraBackup or Mariabackup for your nightly backup, you can use the following instructions to restore it. In this example we will be restoring `/root/backup/packetfence-db-dump-innobackup-2016-12-20_00h31.xbstream.gz`

First, create a restore directory, move the backup to it and gunzip the backup:

  # mkdir /root/backup/restore
  # cd /root/backup/restore
  # cp ../packetfence-db-dump-innobackup-2016-12-20_00h31.xbstream.gz .
  # gunzip packetfence-db-dump-innobackup-2016-12-20_00h31.xbstream.gz

Then extract the xbstream data (for XtraBackup):

  # xbstream -x < packetfence-db-dump-innobackup-2016-12-20_00h31.xbstream

Then extract the xbstream data (for Mariabackup):

  # mbstream -x < packetfence-db-dump-innobackup-2016-12-20_00h31.xbstream

Once done, you should have a lot of files that were extracted in the restore dir. Now, lets place the xbstream back in the backup directory

  # mv packetfence-db-dump-innobackup-2016-12-20_00h31.xbstream ../

Next, apply the innodb log (for XtraBackup):

  # innobackupex --apply-log ./

Next, apply the innodb log (for Mariabackup):

  # mariabackup --prepare --target-dir=./


We will now stop MariaDB, move the existing data directory and replace it by the data that was extracted:

NOTE: Make sure you adjust the commands above to your environment.

For XtraBackup:

  # service packetfence-mariadb stop
  # mv /var/lib/mysql /var/lib/mysql.bak
  # mkdir /var/lib/mysql
  # mv * /var/lib/mysql
  # chown -R mysql: /var/lib/mysql
  # service packetfence-mariadb start


For Mariabackup:

  # service packetfence-mariadb stop
  # mv /var/lib/mysql /var/lib/mysql.bak
  # mkdir /var/lib/mysql
  # mariabackup --innobackupex --defaults-file=/usr/local/pf/var/conf/mariadb.conf      --move-back --force-non-empty-directories ./
  # chown -R mysql: /var/lib/mysql
  # service packetfence-mariadb start

Should the service fail to start, make sure you look into the MariaDB logs.

[appendix]
=== How to restore a standalone PacketFence server ?

Starting from PacketFence 11.0.0, you can use <<#_exportimport_mechanism,the export/import mechanism>>.

[appendix]
=== How to deploy PacketFence on Linode ?

include::linode/linode.asciidoc[]
