# Box Backup server configuration

## Log files

You may wish to see what's going on with the server. Edit /etc/syslog.conf, and add

    local6.info                         /var/log/box
    local5.info                         /var/log/raidfile

Note separators must be tabs, otherwise it ignores you.

    touch /var/log/box
    touch /var/log/raidfile

And then get them rotated, by adding in /etc/newsyslog.conf

    /var/log/box                644  7    2000 *     Z
    /var/log/raidfile           644  7    2000 *     Z

Then restart syslogd.

## RAID setup

The server does RAID in userland for that extra bit of reliability. You need to set this up separately from the server. To create `/etc/box/raidfile.conf`,

    /usr/local/bin/raidfile-config /etc/box 2048 /raid/0.0 /raid/0.1 /raid/0.2

But adjust it for your system. 2048 is the block size. Under BSD with FFS, set this to your filing system's fragment size (most likely an 8th of the block size), otherwise the block size of the filing system, for maximum efficiency.

The three directories are the locations of the roots of the raid file directories. These are probably the mount points of three big partitions on three separate physical discs. If you don't have this, see below on how to disable userland RAID.

Edit `/etc/box/raidfile.conf` if you have another set of three discs you want to use -- just add another section for each set.

### Disabling userland RAID

If you only have one disc, or a hardware RAID array, you probably won't want to use userland RAID.

In this case, follow the above instructions, but only specify one directory for the `raidfile-config` script. This will generate a raidfile.conf which disables userland RAID, and stores files in the single directory you specify.

NOTE Running the server in non-RAID mode has not been tested as extensively as in RAID file mode.

## Server basic setup

Create a user to run the server under:

    useradd _bbstored

Create `/etc/box/bbstored.conf` with:

    /usr/local/bin/bbstored-config /etc/box hostname _bbstored

(See OpenSSL notes if you get an OpenSSL error)

(set hostname to the address the clients will use to contact this server) Are you using a NAT device or firewall? See the note below.

Read the output for details of what to do next. There is an example at the end of this page, but do follow the instructions output when you run the script yourself.

Make sure the user can write to the raid file directories! For more precise control, create a `backup` directory within each of the raid root directories, and change their permissions accordingly.

If there are other users on this server, you will probably want to stop other users reading the certificates.

    chown -R _bbstored /etc/box/bbstored
    chmod -R go-rwx /etc/box/bbstored

## Configuration for hosts behind a NAT device or firewall

The hostname specified is used for 1) the name in the server's certificate and 2) the address the server will listen on.

If the IP address of the machine isn't the same as the IP address it appears to have to the outside world (because the NAT device or firewall translates it), then this will fail. The server will look up the hostname, and then fail to bind to that address since it is not a local address.

To get around this, you have two options. Either specify the local IP address with the `bbstored-config` command (the name in the certificate won't match the real address, but this is not a problem at the moment), or specify the real address, but edit the `bbstored.conf` file and correct the `ListenAddresses` directive later to reflect the local address.

## Get certified

As per the instructions in the certificates and accounts management page, sign your certificate and install it as directed.

## Start the server

    /usr/local/bin/bbstored

Add this to your system startup scripts.

Please read the Troubleshooting page if you have problems.

If you configured the server so the configuration file is somewhere other than `/etc/box/bbstored.conf`, run the server as, for example,

    /usr/local/bin/bbstored /some/other/config/dir/bbstored.conf

## root not required

The backup server is configured to be run as root, but changes user to the user you specify as soon as it can -- this is simply for convenience when starting the daemon in system start up scripts. However, you can run without root entirely by making a small change to the configuration file.

## Example configuration output

This is an example of output from the bbstored-config script. Important: Follow the instructions output by your script, not the ones here -- they may be different for your system.

    # /usr/local/bin/bbstored-config /etc/box server.example.com _bbstored
    Checking permissions on /raid/0.0/backup
    Checking permissions on /raid/0.1/backup
    Checking permissions on /raid/0.2/backup

    Setup bbstored config utility.

    Configuration:
       Writing configuration file: /etc/box/bbstored.conf
       Writing empty accounts file: /etc/box/bbstored/accounts.txt
       Server hostname: server.example.com
       RaidFile config: /etc/box/raidfile.conf

    Creating /etc/box/bbstored
    Creating blank accounts file
    Generating private key...
     [OpenSSL output omitted]

    Writing configuration file /etc/box/bbstored.conf

    ===================================================================

    bbstored basic configuration complete.

    What you need to do now...

    1) Sign /etc/box/bbstored/server.example.com-csr.pem
       using the bbstored-certs utility.

    2) Install the server certificate and root CA certificate as
          /etc/box/bbstored/server.example.com-cert.pem
          /etc/box/bbstored/clientCA.pem

    3) You may wish to read the configuration file
          /etc/box/bbstored.conf
       and adjust as appropraite.

    4) Create accounts with bbstoreaccounts

    5) Start the backup store daemon with the command
          /usr/local/bin/bbstored
       in /etc/rc.local, or your local equivalent.

    ===================================================================

© Ben Summers, 2003, 2004