Contribute  :  Advanced Search  :  Directory  :  Forum  :  FAQ's  :  My Downloads  :  Links  :  Polls  
AFP548 Changing the world one server at a time.
Welcome to AFP548
Thursday, July 29 2010 @ 09:22 am MDT
   

Using serveradmin to backup and restore your configs

Articles

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.

Finally...

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. 

 

 

 

 

 

Story Options

Advertising

Using serveradmin to backup and restore your configs | 6 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Using serveradmin to backup and restore your configs
Authored by: Anonymous on Tuesday, July 03 2007 @ 05:21 pm MDT
On OS X Server 10.4.8, running the following sudo'ed to root:
serveradmin settings all > serverconfig.backup

Gives the following error:
2007-07-03 17:13:58.750 serveradmin[809] Exception in doCommand: *** -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)
serveradmin(809,0xa000cfe0) malloc: *** error for object 0x15db450: double free
serveradmin(809,0xa000cfe0) malloc: *** set a breakpoint in szone_error to debug
serveradmin(809,0xa000cfe0) malloc: *** Deallocation of a pointer not malloced: 0x15d8690; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug

It still does write out what looks to be a complete config file though - but I'm not sure.
Using serveradmin to backup and restore your configs
Authored by: Anonymous on Tuesday, July 03 2007 @ 06:11 pm MDT
Is there a similar command for regular OS X?

It's easy enough to back up /Users, but I'd like to dump my system's setting in a text file of some kind and back that up as well. Then if I ever need to restore things I can bring back the /Users and import the text file as well to get my network and user settings.

Nidump(8) kind-of does some of this, but not quite all of it. It'd be really nice if I could just grab /etc/* like Real Unix(tm).
Using serveradmin to backup and restore your configs
Authored by: Acidprime on Thursday, July 05 2007 @ 06:24 pm MDT
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 :)