Articles July 3, 2007 at 11:40 am

Using serveradmin to backup and restore your configs

We all know about those little tear-off things in the bottom right hand corner of Server Admin, right? They're a very handy way of backing up your config before making a change. Just drag it off to your desktop, make your changes and if it all goes pear-shaped, just drag it back and sanity is restored. That's all well and good, but not exactly scriptable.

Enter serveradmin… 

serveradmin is the command line version of the GUI application, and offers much greater flexibility for automation. At it's simplest, the following command will backup your server config to a file called serverconfig.backup:

 serveradmin settings all > serverconfig.backup 

Note: serveradmin must be run as root


And restoring is as simple as reversing the 'greater than' arrow and removing the 'all' option:

 serveradmin settings < serverconfig.backup 

Note: Having all your services configurations in one huge file is problematic – what if you need to restore the settings for only one service, or a couple? That would mean having to go into the file and edit or comment out the sections that didn't want to get configured. Fortunately serveradmin allows you to specify the service(s) you want to work with.

To see all the services available:

 serveradmin list 

So, now you can easily create backups for each service individually, for example AFP:

 serveradmin settings afp > afpconfig.backup 

And restoring these would simply be:

 serveradmin settings < afpconfig.backup 

Right, that's one level of granularity, let's go a bit further. Let's say you want to change only one or two specific settings for a particular service…

Individual configuration options can be set using exactly the same syntax. To see how to reference each option just type:

 serveradmin settings afp 

This will return all of the settings for the AFP service.


serveradmin has a 'command' element in addition to the settings option. This allows you some interaction with the services and lets you pull out information. The following is shamelessly stolen from the man page:

 serveradmin command afp:command = getConnectedUsers

This will return you a list of all the currently connected users for the AFP service. Note that you'll need to specify the service followed by a colon. You can also create a command file containing multiple commands instead of typing everything out multiple times. Sadly it doesn't allow you to affect multiple services so you'll need a command file for each service. Lots more info can be found in the serveradmin man page.

So, while there are one or two shortcomings of the command, it does make the job of backing up, reading and restoring your server's config much easier to do programmatically and routinely. 






No Comments

  • Just a note on how to backup the server sharepoints

    To backup.

    nidump -r /config/SharePoints . >shares.nidump

    To restore from the backup.

    niload -r /config/SharePoints . <shares.nidump

    ( and yes I know about ^h^h^h^h^h^h 🙂

Leave a reply

You must be logged in to post a comment.