# View transaction history with pkg?



## GROND (Mar 28, 2015)

I have recently been obligated to use CentOS for work, and while yum is terrible in most respects, I have become quite fond of the `yum history` feature. For those who are not familiar, yum will record each transaction executed, with the ability to view the elements of each transaction and even roll transactions back. Is there a similar feature for pkg, where I can step through the changes made to the system?


----------



## GROND (Mar 28, 2015)

I was referring to RedHat/CentOS yum. I wasn't aware that it was in ports, though I don't see why I'd want to use it. pkg(8) is awesome, but I haven't seen a feature for it that can do transaction history. Is this a thing?


----------



## protocelt (Mar 28, 2015)

I could be wrong but I don't think pkg(8) has that feature. At least not yet. You could however look at your logs for install history.


----------



## scottro (Jun 11, 2015)

No, it doesn't have that feature.  It doesn't even seem, as far as I can tell, to make entries in logfiles, as I found out the other day to my aggravation.  (Hence my updating of this thread in the hope that someone can correct me.)

That is, if you install using ports, there will at least be an entry in /var/log/messages. (I'm not sure about removals.)  However, if you install or remove by using `pkg install whatever` the only entry will be in /var/log/backups in a compressed pkg.sql.xz file. One can then decompress and either look at the raw sql or create a database and import the sql file into it.

As that seems such a drastic lack on a server O/S, I have a strong feeling I'm missing something.


----------



## SirDice (Jun 11, 2015)

scottro said:


> That is, if you install using ports, there will at least be an entry in /var/log/messages. (I'm not sure about removals.)


They are.


```
root@armitage:~ # grep pkg /var/log/messages
Jun  5 11:27:38 armitage pkg: nmap-6.47 installed
root@armitage:~ #
root@armitage:~ # pkg delete nmap
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        nmap-6.47

The operation will free 18 MiB.

Proceed with deinstalling packages? [y/N]: y
[1/1] Deinstalling nmap-6.47...
[1/1] Deleting files for nmap-6.47: 100%
root@armitage:~ # tail -1 /var/log/messages
Jun 11 19:49:14 armitage pkg: nmap-6.47 deinstalled
root@armitage:~ #
```


----------



## scottro (Jun 11, 2015)

Ok, so deletes should be shown then.  Bah, I also realize that I'm dealing with an older server, 9.2 or 9.3 so what I say may no longer be relevant.  I'm not going to say I'm an idiot, (my wife will be happy to say it for me), but I haven't checked if there's anything in messages when installing with pkg on 10.x
I will try that either later tonight or tomorrow and update.


----------



## scottro (Jun 12, 2015)

And to update--yup, at least what happens in pkg is shown in /var/log/messages.  In an older version (9.0? 9.2?) it wasn't.  Thanks everyone.  

There is nothing like yum history, which is too bad, but at least it's easy to see when something was installed.


----------



## kpa (Jun 12, 2015)

Sqlite must have logging capabilities for transactions but the pkg developers just aren't making use of them yet. Make a feature request at https://github.com/freebsd/pkg and it might happen.


----------

