(Query the AFS database, usable via remctl)


afsdb-query [-hv] [query] query


afsdb-query just runs a SQL query against the AFS database on lsdb and returns the result. It's mostly used to generate volume lists for mass volume moves, but can be used for other purposes. It is intended to be run via remctl.

If query does not begin with select, select volname from volumes where will automatically be added to the beginning of the query. This lets one write queries like:

    type = 'RW' and server = 'afssvr1' and part = '/vicepa'

without having to include the rest of the logic, when the goal is a simple list of volumes.

Any double quotes in the SQL query will be automatically changed to single quotes. The query generally will include whitespace, so this is done so that you can either enclose the whole query in single quotes and use double quotes for strings or vice versa, whichever makes the most sense to you.

For easy use under remctld(8), if the first argument of afsdb-query is the word query and there is a second argument, the second argument will be taken as the query to run.


List all volumes on afssvr6:

    afsdb-query 'server = "afssvr6"'

List all RW volumes on afssvr1 /vicepb:

    afsdb-query "server = 'afssvr1' and part = '/vicepb' and type = 'RW'"

List volume name and size for all volumes on afssvr17 larger than 100MB:

    afsdb-query 'select volname, used from volumes
        where server = "afssvr17" and used > 100000'

When actually running the previous command, you'll need to type the whole command on one line without any newlines.


This script does not protect against any sort of attacks or attempt to limit what operations the user can perform; the automatic addition of the select command is purely for convenience and can easily be worked around. Users who have access to this script will be able to perform any operation that can be performed by the user this script authenticates as.


Russ Allbery <>


Copyright 2004, 2005 Board of Trustees, Leland Stanford Jr. University.

This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.



The current version of this program is available from the AFS reporting database software page at <>.

Last spun 2014-08-10 from POD modified 2008-09-02