source: box/trunk/docs/docbook/adminguide.xml @ 2474

Revision 2474, 82.9 KB checked in by chris, 3 years ago (diff)

Reorganise docs in trunk to match distribution layout, which is cleaner,
and makes Makefile work on distributions and trunk equally.

Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
4<!ENTITY __ExceptionCodes__elfjz3fu SYSTEM "ExceptionCodes.xml">
5]>
6<book>
7  <title>Box Backup administrator's guide</title>
8
9  <preface>
10    <title>License</title>
11
12    <para>Copyright © 2003 - 2007, Ben Summers and contributors. All rights
13    reserved.</para>
14
15    <para>Redistribution and use in source and binary forms, with or without
16    modification, are permitted provided that the following conditions are
17    met:</para>
18
19    <itemizedlist>
20      <listitem>
21        <para>Redistributions of source code must retain the above copyright
22        notice, this list of conditions and the following disclaimer.</para>
23      </listitem>
24
25      <listitem>
26        <para>Redistributions in binary form must reproduce the above
27        copyright notice, this list of conditions and the following disclaimer
28        in the documentation and/or other materials provided with the
29        distribution.</para>
30      </listitem>
31
32      <listitem>
33        <para>All use of this software and associated advertising materials
34        must display the following acknowledgement: This product includes
35        software developed by Ben Summers and contributors.</para>
36      </listitem>
37
38      <listitem>
39        <para>The names of the Authors may not be used to endorse or promote
40        products derived from this software without specific prior written
41        permission.</para>
42      </listitem>
43    </itemizedlist>
44
45    <para>[Where legally impermissible the Authors do not disclaim liability
46    for direct physical injury or death caused solely by defects in the
47    software unless it is modified by a third party.]</para>
48
49    <para>THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR
50    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
51    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
52    NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
53    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
54    TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
55    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
56    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
57    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
58    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</para>
59  </preface>
60
61  <chapter>
62    <title>Configuration</title>
63
64    <section>
65      <title>System configuration</title>
66
67      <section>
68        <title>Server</title>
69
70        <para>After you've downloaded and compiled the programs you need to
71        install the programs on your server. As root do the following:</para>
72
73        <programlisting>make install-backup-server</programlisting>
74
75        <para>This assumes that you are installing on the same server that you
76        compiled the software on. If not, copy the
77        boxbackup-x.xx-backup-server-OSNAME.tgz file to the server you want to
78        run on, and install there. For example (on Mac OS X):</para>
79
80        <programlisting>tar zxvf boxbackup-0.10-server-darwin8.5.0.tgz
81cd boxbackup-0.10-server-darwin8.5.0
82./install-backup-server</programlisting>
83
84        <para>Then create the user for the backup daemon on the server:</para>
85
86        <programlisting>useradd _bbstored</programlisting>
87
88        <para>Box Backup has a built-in software RAID facility (redundant
89        array of inexpensive disks) for the backup store. This allows you to
90        spread the store data over three disks, and recover from the loss of
91        any one disk without losing data. However, this is now deprecated, and
92        you are recommended to use the software or hardware RAID facilities of
93        your operating system instead. Use the following command if you want
94        to create a simple server without Box Backup RAID:</para>
95
96        <programlisting>mkdir /tmp/boxbackupRepository                        # Create the directory
97chown _bbstored /tmp/boxbackupRepository/             # Change the owner to the new boxbackup daemon user
98
99/usr/local/sbin/raidfile-config /etc/box/  1024 /tmp/boxbackupRepository
100
101#substitute 1024 with the desired blocksize
102#substitute /tmp/boxbackupRepository with a directory that exists where you want the backup store located
103#/usr/local/sbin/raidfile-config --help shows you the options</programlisting>
104
105        <para>Then create the configuration file /etc/box/bbstored.conf The
106        hostname is tricky as it is used for two things: The name of the
107        server in the certificate and the address the server is listening on.
108        Since you might be using NAT, might move the server around or the
109        domain name might change, choose a name that describes the server.
110        When the network address of the server changes, you need to update the
111        <literal>ListenAddresses</literal> directive in the
112        <filename>/etc/box/bbstored.conf</filename> file.</para>
113
114        <programlisting>/usr/local/sbin/bbstored-config /etc/box hostname _bbstored</programlisting>
115
116        <para>This last step outputs 5 instructions that you must execute to
117        the letter. A lot of questions are raised on the mailing list because
118        these steps have not been followed properly.</para>
119
120        <para>TODO: Expand on this. Explain the 5 steps in detail.</para>
121
122        <para>If you want to run the server as a non-root user, look <link
123        linkend="WORoot">here</link>.</para>
124      </section>
125
126      <section>
127        <title>Certificate Management</title>
128
129        <para>There are two steps involved to create an account. You need to
130        create the account on the server, and sign a certificate to give the
131        client permission to connect to the server.</para>
132
133        <para>Running a Certification Authority for TLS (SSL) connections is
134        not trivial. However, a script to does most of the work in a way which
135        should be good enough for most deployments.</para>
136
137        <important>
138          <para>The certificate authority directory is intended to be stored
139          on another server. It should not be kept on the backup server, in
140          order to limit the impact of a server compromise. The instructions
141          and the script assume that it will be kept elsewhere, so will ask
142          you to copy files to and from the CA.</para>
143        </important>
144
145        <warning>
146          <para>SSL certificates contain validity dates, including a "valid
147          from" time. If the clock on the machine which signs the certificates
148          is not syncronised to the clocks of the machines using these
149          certificates, you will probably get strange errors until the start
150          time is reached on all machines. If you get strange errors when
151          attempting to use new certificates, check the clocks on all machines
152          (client, store and CA). You will probably just need to wait a while
153          until the certificates become valid, rather than having to
154          regenerate them.</para>
155        </warning>
156
157        <section>
158          <title>Set up a Certificate Authority</title>
159
160          <para>It is recommended that you keep your Certificate Authority on
161          a separate machine than either the client or the server, preferably
162          without direct network access. The contents of this directory
163          control who can access your backup store server.</para>
164
165          <para>To setup the basic key structure, do the following:</para>
166
167          <programlisting>/usr/local/sbin/bbstored-certs ca init</programlisting>
168
169          <para>(See <ulink url="instguide.xml">OpenSSL notes</ulink> if you
170          get an OpenSSL error)</para>
171
172          <para>This creates the directory called <filename>ca</filename> in
173          the current directory, and initialises it with basic keys.</para>
174        </section>
175
176        <section>
177          <title>Sign a server certificate</title>
178
179          <para>When you use the <command>bbstored-config</command> script to
180          set up a config file for a server, it will generate a certificate
181          request (CSR) for you. Transfer it to the machine with your CA, then
182          do:</para>
183
184          <programlisting>/usr/local/sbin/bbstored-certs ca sign-server hostname-csr.pem</programlisting>
185
186          <para>This signs the certificate for the server. Follow the
187          instructions in the output on which files to install on the server.
188          The CSR file is now no longer needed. Make sure you run this command
189          from the directory above the directory 'ca'.</para>
190
191          <para>TODO: Explain instructions in output.</para>
192        </section>
193
194        <section>
195          <title>Set up an account</title>
196
197          <para>Choose an account number for the user. This must be unique on
198          the server, and is presented as a 31 bit number in hex greater than
199          0, for example, 1 or 75AB23C. Then on the backup store server,
200          create the account with:</para>
201
202          <programlisting>/usr/local/sbin/bbstoreaccounts create 75AB23C 0 4096M 4505M</programlisting>
203
204          <para>This looks complicated. The numbers are, in order:</para>
205
206          <itemizedlist>
207            <listitem>
208              <para>The account number allocated (hex)</para>
209            </listitem>
210
211            <listitem>
212              <para>The RAID disc set (0 if you use raidfile-config and don't
213              add a new set)</para>
214            </listitem>
215
216            <listitem>
217              <para>Soft limit (size)</para>
218            </listitem>
219
220            <listitem>
221              <para>Hard limit (size)</para>
222            </listitem>
223          </itemizedlist>
224
225          <para>The sizes are are specified in Mb, Gb, or blocks, depending on
226          the suffix. 1M specifies 1 Mb, 1G specifies 1 Gb, and 1B specifies 1
227          block, the size of which depends on how you have configured the
228          raidfile system with raidfile-config.</para>
229
230          <para>In this example, I have allocated 4Gb (assuming you use 2048
231          byte blocks as per my example) as the soft limit, and 4Gb + 10% as
232          the hard limit.</para>
233
234          <para>NOTE The sizes specified here are pre-RAID. So if you are
235          using userland RAID, you are actually allocating two-thirds of this
236          amount. This means that, when you take compression into account,
237          that if you allocate 2Gb on the server, it'll probably hold about
238          2Gb of backed up files (depending on the compressability of those
239          files).</para>
240
241          <para>The backup client will (voluntarily) try not to upload more
242          data than is allowed by the soft limit. The store server will refuse
243          to accept a file if it would take it over the hard limit, and when
244          doing housekeeping for this account, try and delete old versions and
245          deleted files to reduce the space taken to below the soft
246          limit.</para>
247
248          <para>This command will create some files on disc in the raid file
249          directories (if you run as root, the utility will change to the user
250          specified in the bbstored.conf file to write them) and update the
251          accounts file. A server restart is not required.</para>
252
253          <para>NOTE If you get a message saying 'Exception: RaidFile (2/8)',
254          the directories you specified in the raidfile.conf are not writable
255          by the _bbstored user -- fix it, and try again.</para>
256
257          <para>Finally, tell the user their account number, and the hostname
258          of your server. They will use this to set up the backup client, and
259          send you a CSR. This has the account number embedded in it, and you
260          should be sure that it has the right account number in it.</para>
261
262          <para>Sign this CSR with this command:</para>
263
264          <programlisting>/usr/local/sbin/bbstored-certs ca sign 75AB23C-csr.pem</programlisting>
265
266          <para>Don't forget to check that the embedded account number is
267          correct! Then send the two files back to the user, as instructed by
268          the script.</para>
269
270          <para>Please read the Troubleshooting page if you have
271          problems.</para>
272
273          <para>TODO: Link to troubleshooting...</para>
274        </section>
275      </section>
276
277      <section>
278        <title>Log Files</title>
279
280        <para>You may wish to see what's going on with the server. Edit
281        /etc/syslog.conf, and add:</para>
282
283        <programlisting>local6.info                         /var/log/box
284local5.info                         /var/log/raidfile</programlisting>
285
286        <para><emphasis role="bold">Note:</emphasis> Separators must be tabs,
287        otherwise these entries will be ignored.</para>
288
289        <programlisting>touch /var/log/box
290touch /var/log/raidfile</programlisting>
291
292        <para>Set up log rotation for these new log files. For example, if you
293        have <filename>/etc/newsyslog.conf</filename>, add the following lines
294        to it:</para>
295
296        <programlisting>/var/log/box                644  7    2000 *     Z
297/var/log/raidfile           644  7    2000 *     Z</programlisting>
298
299        <para>If you have <filename>/etc/logrotate.d</filename>, create a new
300        file in there (for example
301        <filename>/etc/logrotate.d/boxbackup</filename>) containing the
302        following:</para>
303
304        <programlisting>/var/log/box /var/log/raidfile {
305        weekly
306        create
307        compress
308        rotate 52
309}</programlisting>
310
311        <para>Then restart syslogd, for example:</para>
312
313        <programlisting>/etc/init.d/syslogd restart</programlisting>
314      </section>
315
316      <section>
317        <title>Configuring a client</title>
318
319        <para>Before you can do any configuration, you need to know the
320        hostname of the server you will be using, and your account number on
321        that server.</para>
322
323        <para>Later in the process, you will need to send a certificate
324        request to the administrator of that server for it to be
325        signed.</para>
326
327        <para>Installation is covered in the compiling and installing section.
328        You only need the backup-client parcel.</para>
329
330        <para>It is important that you read all the output of the config
331        scripts. See the end of this page for an example.</para>
332
333        <para>The backup client has to be run as root, because it needs to
334        read all your files to back them up, although it is possible to back
335        up a single user's files by running it as that user. (Tip: specify a
336        directory other than <filename>/etc/box</filename>, and then give the
337        alternate config file as the first argument to
338        <command>bbackupd</command>). However, it will fall over if you don't
339        give yourself read access to one of your files.</para>
340
341        <section>
342          <title id="BasicConfig">Basic configuration</title>
343
344          <para>Run the <command>bbackupd-config</command> script to generate
345          the configuration files and generate a private key and certificate
346          request.</para>
347
348          <programlisting>/usr/local/sbin/bbackupd-config /etc/box lazy <emphasis
349              role="bold">999 hostname</emphasis> /var/bbackupd <emphasis
350              role="bold">/home</emphasis></programlisting>
351
352          <para>(See <ulink url="instguide.xml">OpenSSL notes</ulink> if you
353          get an OpenSSL error)</para>
354
355          <para>The items in bold need to be changed. In order, they are the
356          account number, the hostname of the server you're using, and
357          finally, the directories you want backed up. You can include as many
358          you want here.</para>
359
360          <para>However, the directories you specify must not contain other
361          mounted file systems within them at any depth. Specify them
362          separately, one per mount point. No checks are currently made to
363          catch bad configuration of this nature!</para>
364
365          <para>You may also want to consider changing the mode from lazy to
366          snapshot, depending on what your system is used for:</para>
367
368          <glosslist>
369            <glossentry>
370              <glossterm>Lazy Mode</glossterm>
371
372              <glossdef>
373                <para>This mode regularly scans the files, with only a rough
374                schedule. It uploads files as and when they are changed, if
375                the latest version is more than a set age. This is good for
376                backing up user's documents stored on a server, and spreads
377                the load out over the day.</para>
378              </glossdef>
379            </glossentry>
380
381            <glossentry>
382              <glossterm>Snapshot Mode</glossterm>
383
384              <glossdef>
385                <para>This mode emulates the traditional backup behaviour of
386                taking a snapshot of the filesystem. The backup daemon does
387                absolutely nothing until it is instructed to make a backup
388                using the bbackupctl utility (probably as a cron job), at
389                which point it uploads all files which have been changed since
390                the last time it uploaded.</para>
391              </glossdef>
392            </glossentry>
393          </glosslist>
394
395          <para>When you run the config script, it will tell you what you need
396          to do next. Don't forget to read all the output. An example is shown
397          at the end of this page, but the instructions for your installation
398          may be different.</para>
399        </section>
400
401        <section>
402          <title>Certificates</title>
403
404          <para>After you have sent your certificate request off to the server
405          administrator and received your certificate and CA root back,
406          install them where instructed by the bbackupd-config script during
407          basic bbackupd configuration.</para>
408
409          <para>You can then run the daemon (as root) by running
410          <command>/usr/local/sbin/bbackupd</command>, and of course, adding it
411          to your system's startup scripts. The first time it's run it will
412          upload everything. Interrupting it and restarting it will only
413          upload files which were not uploaded before - it's very
414          tolerant.</para>
415
416          <para>If you run in snapshot mode, you will need to add a cron job
417          to schedule backups. The config script will tell you the exact
418          command to use for your system.</para>
419
420          <para>Please read the Troubleshooting page if you have
421          problems.</para>
422
423          <para>Remember to make a traditional backup of the keys file, as
424          instructed. You cannot restore files without it.</para>
425
426          <para>It is recommended that you backup up all of /etc/box as it
427          will make things easier if you need to restore files. But only the
428          keys are absolutely essential.</para>
429
430          <para>If you want to see what it's doing in more detail (probably a
431          good idea), follow the instructions in the server setup to create
432          new log files with syslog. </para>
433        </section>
434
435        <section>
436          <title>Adding and removing backed up locations</title>
437
438          <para>By editing the /etc/box/bbackupd.conf file, you can add and
439          remove directories to back up - see comments in this file for help.
440          Send bbackupd a HUP signal after you modify it.</para>
441
442          <para>When you remove a location, it will not be marked as deleted
443          immediately. Instead, bbackupd waits about two days before doing so,
444          just in case you change your mind. After this, it will be eventually
445          removed from the store by the housekeeping process. Run as
446          root.</para>
447
448          <para>The backup client is designed to be run as root. It is
449          possible to run without root, but this is not recommended. Clock
450          synchronisation for file servers.</para>
451
452          <para>If you are using the backup client to backup a filesystem
453          served from a fileserver, you should ideally ensure that the
454          fileserver clocks are synchronised with the fileserver.</para>
455
456          <para>bbackupd will cope perfectly well if the clocks are not
457          synchronised. Errors up to about half an hour cause no problems.
458          Larger discrepancies cause a loss of efficiency and the potential to
459          back up a file during a write process.</para>
460
461          <para>There is a configuration parameter MaxFileTimeInFuture, which
462          specifies how far in the future a file must be for it to be uploaded
463          as soon as it is seen. You should not need to adjust this (default
464          is 2 days). Instead, get those clocks synchronised. Excluding files
465          and directories from the backup.</para>
466
467          <para>Within the bbackupd.conf file, there is a section named
468          BackupLocations which specifies which locations on disc should be
469          backed up. It has subsections, each of which is in the
470          format:</para>
471
472          <programlisting> name
473 {
474    Path = /path/of/directory
475    (optional exclude directives)
476 }</programlisting>
477
478          <para><emphasis role="bold">name</emphasis> is derived from the Path
479          by the config script, but should merely be unique.</para>
480
481          <para>The exclude directives are of the form:</para>
482
483          <programlisting>[Exclude|AlwaysInclude][File|Dir][|sRegex] = regex or full pathname</programlisting>
484
485          <para>(The regex suffix is shown as 'sRegex' to make File or Dir
486          plural)</para>
487
488          <para>For example:</para>
489
490          <programlisting> ExcludeDir = /home/guest-user
491 ExcludeFilesRegex = *.(mp3|MP3)\$
492 AlwaysIncludeFile = /home/username/veryimportant.mp3</programlisting>
493
494          <para>This excludes the directory /home/guest-user from the backup
495          along with all mp3 files, except one MP3 file in particular.</para>
496
497          <para>In general, Exclude excludes a file or directory, unless the
498          directory is explicitly mentioned in a AlwaysInclude
499          directive.</para>
500
501          <para>If a directive ends in Regex, then it is a regular expression
502          rather than a explicit full pathname. See</para>
503
504          <programlisting> man 7 re_format</programlisting>
505
506          <para>for the regex syntax on your platform.</para>
507        </section>
508
509        <section>
510          <title>Example configuration output</title>
511
512          <para>This is an example of output from the bbstored-config
513          script.</para>
514
515          <important>
516            <para>Follow the instructions output by your script, not the ones
517            here -- they may be different for your system.</para>
518          </important>
519
520          <programlisting>/usr/local/sbin/bbackupd-config /etc/box lazy 51 server.example.com /var/bbackupd /home /etc/samba
521
522Setup bbackupd config utility.
523
524Configuration:
525   Writing configuration file: /etc/box/bbackupd.conf
526   Account: 51
527   Server hostname: server.example.com
528   Directories to back up:
529      /home
530      /etc/samba
531
532Note: If other file systems are mounted inside these directories, then problems may occur
533with files on the store server being renamed incorrectly. This will cause efficiency
534problems, but not affect the integrity of the backups.
535
536WARNING: Directories not checked against mountpoints. Check mounted filesystems manually.
537
538Creating /etc/box...
539Creating /etc/box/bbackupd
540Generating private key...
541 [OpenSSL output omitted]
542
543Generating keys for file backup
544Writing notify script /etc/box/bbackupd/NotifyStoreFull.sh
545Writing configuration file /etc/box/bbackupd.conf
546
547===================================================================
548
549bbackupd basic configuration complete.
550
551What you need to do now...
552
5531) Make a backup of /etc/box/bbackupd/51-FileEncKeys.raw
554   This should be a secure offsite backup.
555   Without it, you cannot restore backups. Everything else can
556   be replaced. But this cannot.
557   KEEP IT IN A SAFE PLACE, OTHERWISE YOUR BACKUPS ARE USELESS.
558
5592) Send /etc/box/bbackupd/51-csr.pem
560   to the administrator of the backup server, and ask for it to
561   be signed.
562
5633) The administrator will send you two files. Install them as
564      /etc/box/bbackupd/51-cert.pem
565      /etc/box/bbackupd/serverCA.pem
566   after checking their authenticity.
567
5684) You may wish to read the configuration file
569      /etc/box/bbackupd.conf
570   and adjust as appropraite.
571   
572   There are some notes in it on excluding files you do not
573   wish to be backed up.
574
5755) Review the script
576      /etc/box/bbackupd/NotifyStoreFull.sh
577   and check that it will email the right person when the store
578   becomes full. This is important -- when the store is full, no
579   more files will be backed up. You want to know about this.
580
5816) Start the backup daemon with the command
582      /usr/local/sbin/bbackupd
583   in /etc/rc.local, or your local equivalent.
584   Note that bbackupd must run as root.
585
586===================================================================</programlisting>
587
588          <para>Remember to make a secure, offsite backup of your backup keys,
589          as described in <link linkend="BasicConfig">Basic
590          configuration</link> above. If you do not, and that key is lost, you
591          have no backups.</para>
592        </section>
593      </section>
594
595      <section>
596        <title>Configuration Options</title>
597
598        <para>Box Backup has many options in its configuration file. We will
599        try to list them all here.</para>
600
601        <para>First of all, here is an example configuration file, for
602        reference:</para>
603
604        <example>
605          <title>Example Configuration File</title>
606
607          <programlisting>StoreHostname = localhost
608AccountNumber = 0x2
609
610KeysFile = /etc/box/2-FileEncKeys.raw
611CertificateFile = /etc/box/2-cert.pem
612PrivateKeyFile = /etc/box/2-key.pem
613TrustedCAsFile = /etc/box/serverCA.pem
614DataDirectory = /var/run/boxbackup
615NotifyScript = /etc/box/NotifySysadmin.sh
616CommandSocket = /var/run/box/bbackupd.sock
617
618UpdateStoreInterval = 86400
619MinimumFileAge = 3600
620MaxUploadWait = 7200
621FileTrackingSizeThreshold = 65536
622DiffingUploadSizeThreshold = 65536
623MaximumDiffingTime = 20
624ExtendedLogging = no
625LogAllFileAccess = yes
626
627Server
628{
629        PidFile = /var/run/bbackupd.pid
630}
631BackupLocations
632{
633        etc
634        {
635                Path = /etc
636        }
637        home
638        {
639                Path = /home
640                ExcludeDir = /home/shared
641                ExcludeDir = /home/chris/.ccache
642                ExcludeDir = /home/chris/.mozilla/firefox/vvvkq3vp.default/Cache
643        }
644}</programlisting>
645        </example>
646
647        <para>As you can see from the example above, the configuration file
648        has a number of subsections, enclosed in curly braces {}. Some options
649        appear outside of any subsection, and we will refer to these as <link
650        linkend="RootOptions">root options</link>. The available options in
651        each section are described below.</para>
652
653        <para>Every option has the form <quote>name = value</quote>. Names are
654        not case-sensitive, but values are. Depending on the option, the value
655        may be:</para>
656
657        <itemizedlist>
658          <listitem>
659            <para>a path (to a file or directory);</para>
660          </listitem>
661
662          <listitem>
663            <para>a number (usually in seconds or bytes);</para>
664          </listitem>
665
666          <listitem>
667            <para>a boolean (the word Yes or No);</para>
668          </listitem>
669
670          <listitem>
671            <para>a hostname (or IP address).</para>
672          </listitem>
673        </itemizedlist>
674
675        <para>Paths are specified in native format, i.e. a full Windows path
676        with drive letter on Windows clients, or a full Unix path on Unix
677        clients.</para>
678
679        <para><example>
680            <title>Example:</title>
681
682            <para>StoreObjectInfoFile =
683            /var/state/boxbackup/bbackupd.dat</para>
684
685            <para>StoreObjectInfoFile = C:\Program Files\Box
686            Backup\data\bbackupd.dat</para>
687          </example>The use of relative paths (which do not start with a
688        forward slash on Unix, or a drive specification on Windows) is
689        possible but not recommended, since they are interpreted relative to
690        the current working directory when bbackupd was started, which is
691        liable to change unexpectedly over time.</para>
692
693        <para>Numbers which start with "0x" are interpreted as hexadecimal.
694        Numbers which do not start with "0x" are interpreted as
695        decimal.</para>
696
697        <section>
698          <title id="RootOptions">Root Options</title>
699
700          <para>These options appear outside of any subsection. By convention
701          they are at the beginning of the configuration file.</para>
702
703          <para>Some options are required, and some are optional.</para>
704
705          <glosslist>
706            <glossentry>
707              <glossterm>StoreHostname (required)</glossterm>
708
709              <glossdef>
710                <para>The Internet host name (DNS name) or IP address of the
711                server. This is only used to connect to the server.</para>
712              </glossdef>
713            </glossentry>
714
715            <glossentry>
716              <glossterm>AccountNumber (required)</glossterm>
717
718              <glossdef>
719                <para>The number of the client's account on the server. This
720                must be provided by the server operator, and must match the
721                account number in the client's certificate, otherwise the
722                client will not be able to log into the server.</para>
723
724                <para>The account number may be specified in hexadecimal
725                (starting with 0x, as in the example above) or in decimal, but
726                since the server operator works in hexadecimal, that format is
727                highly recommended and is the default.</para>
728              </glossdef>
729            </glossentry>
730
731            <glossentry>
732              <glossterm>KeysFile (required)</glossterm>
733
734              <glossdef>
735                <para>The path to the file containing the encryption key used
736                for data encryption of client file data and filenames. This is
737                the most important file to keep safe, since without it your
738                backups cannot be decrypted and are useless. Likewise, if an
739                attacker gets access to this key and to your encrypted
740                backups, he can decrypt them and read all your data. </para>
741
742                <para>Do not change the encryption key without deleting all
743                files from the account on the server first. None of your old
744                files on the store will be readable if you do so, and if you
745                change it back, none of the files uploaded with the new key
746                will be readable.</para>
747              </glossdef>
748            </glossentry>
749
750            <glossentry>
751              <glossterm>CertificateFile (required)</glossterm>
752
753              <glossdef>
754                <para>The path to the OpenSSL client certificate in PEM
755                format. This is supplied by the server operator in response to
756                the certificate request which you send to them. Together with
757                the PrivateKeyFile, this provides access to the store server
758                and the encrypted data stored there.</para>
759
760                <para>It is not critical to protect this file or to back it up
761                safely, since it can be regenerated by creating a new
762                certificate request, and asking the server operator to sign
763                it. You may wish to back it up, together with the
764                PrivateKeyFile, to avoid this inconvenience if you lose all
765                your data and need quick access to your backups.</para>
766
767                <para>If you do back them up, you should keep them in a
768                separate location to the KeysFile, since any person holding
769                the KeysFile and the PrivateKeyFile can gain access to your
770                encrypted data and decrypt it.</para>
771              </glossdef>
772            </glossentry>
773
774            <glossentry>
775              <glossterm>PrivateKeyFile (required)</glossterm>
776
777              <glossdef>
778                <para>The path to the OpenSSL private key in PEM format. This
779                is generated at the same time as the certificate request, but
780                there is no need to send it to the server operator, and you
781                should not do so, in case the communication is intercepted by
782                an attacker. Together with the CertificateFile, this provides
783                access to the store server and the encrypted data stored
784                there.</para>
785
786                <para>See the notes under CertificateFile for information
787                about backing up this file.</para>
788              </glossdef>
789            </glossentry>
790
791            <glossentry>
792              <glossterm>TrustedCAsFile (required)</glossterm>
793
794              <glossdef>
795                <para>The path to the OpenSSL certificate of the Client
796                Certificate Authority (CCA), in PEM format. This is supplied
797                by the server operator along with your account details, or
798                along with your signed client certificate. This is used to
799                verify that the server which you are connecting to is
800                authorised by the person who signed your certificate. It
801                protects you against DNS and ARP poisoning and IP spoofing
802                attacks.</para>
803              </glossdef>
804            </glossentry>
805
806            <glossentry>
807              <glossterm>DataDirectory (required)</glossterm>
808
809              <glossdef>
810                <para>The path to a directory where bbackupd will keep local
811                state information. This consists of timestamp files which
812                identify the last backup start and end times, used by
813                <command>bbackupquery</command> to determine whether files
814                have changed, and optionally a database of inode numbers,
815                which are used to check for files being renamed. The database
816                is only saved if Box Backup is built with Berkeley Database
817                (BDB) support.</para>
818              </glossdef>
819            </glossentry>
820
821            <glossentry>
822              <glossterm>NotifyScript (optional)</glossterm>
823
824              <glossdef>
825                <para>The path to the script or command to run when the Box
826                Backup client detects an error during the backup process. This
827                is normally used to notify the client system administrator by
828                e-mail when a backup fails for any reason.</para>
829
830                <para>The script or command is called with one of the
831                following additional arguments to identify the cause of the
832                problem:</para>
833
834                <glosslist>
835                  <glossentry>
836                    <glossterm>store-full</glossterm>
837
838                    <glossdef>
839                      <para>The backup store is full. No new files are being
840                      uploaded. If some files are marked as deleted, they
841                      should be removed in due course by the server's
842                      housekeeping process. Otherwise, you need to remove some
843                      files from your backup set, or ask the store operator
844                      for more space.</para>
845                    </glossdef>
846                  </glossentry>
847
848                  <glossentry>
849                    <glossterm>read-error</glossterm>
850
851                    <glossdef>
852                      <para>One or more files which were supposed to be backed
853                      up could not be read. This could be due to:<itemizedlist>
854                          <listitem>
855                            <para>running the server as a non-root user;</para>
856                          </listitem>
857
858                          <listitem>
859                            <para>backing up a mounted filesystem such as
860                            NFS;</para>
861                          </listitem>
862
863                          <listitem>
864                            <para>access control lists being applied to some
865                            files;</para>
866                          </listitem>
867
868                          <listitem>
869                            <para>SELinux being enabled;</para>
870                          </listitem>
871
872                          <listitem>
873                            <para>trying to back up open files under
874                            Windows;</para>
875                          </listitem>
876
877                          <listitem>
878                            <para>strange directory permissions such as 0000 or
879                            0400.</para>
880                          </listitem>
881                        </itemizedlist>Check the client logs, e.g.
882                      /var/log/bbackupd on Unix, or the Windows Event Viewer
883                      in Control Panel &gt; Administrative Tools, for more
884                      information about which files are not being backed up
885                      and why.</para>
886                    </glossdef>
887                  </glossentry>
888
889                  <glossentry>
890                    <glossterm>backup-error</glossterm>
891
892                    <glossdef>
893                      <para>There was a communications error with the server,
894                      or an unexpected exception was encountered during a
895                      backup run. Check the client logs, e.g.
896                      <filename>/var/log/box</filename> on Unix, or the
897                      Windows Event Viewer in Control Panel &gt;
898                      Administrative Tools, for more information about the
899                      problem.</para>
900
901                      <para>You may wish to check your Internet access to the
902                      server, check that the server is running, and ask your
903                      server operator to check your account on the
904                      server.</para>
905                    </glossdef>
906                  </glossentry>
907                </glosslist>
908              </glossdef>
909            </glossentry>
910
911            <glossentry>
912              <glossterm>CommandSocket (optional)</glossterm>
913
914              <glossdef>
915                <para>The path to the Unix socket which
916                <command>bbackupd</command> creates when running, and which
917                <command>bbackupctl</command> uses to communicate with it, for
918                example to force a sync or a configuration reload. If this
919                option is omitted, no socket will be created, and
920                <command>bbackupctl</command> will not function.</para>
921
922                <para>Unix sockets appear within the filesystem on Unix, as a
923                special type of file, and must be created in a directory which
924                exists and to which bbackupd has write access, and bbackupctl
925                has read access. </para>
926
927                <para>On Windows, the path is ignored, and a <glossterm>named
928                pipe</glossterm> is created instead. This does not currently
929                have any security attached, so it can be accessed by any user.
930                Unlike a Unix socket it can also be accessed remotely. Please
931                use this option with extreme caution on Windows, and only on
932                fully trusted networks.</para>
933              </glossdef>
934            </glossentry>
935
936            <glossentry>
937              <glossterm>AutomaticBackup (optional)</glossterm>
938
939              <glossdef>
940                <para>Enable or disable the client from connecting
941                automatically to the store every
942                <glossterm>UpdateStoreInterval</glossterm> seconds. When
943                enabled (set to <quote>Yes</quote>), the client is in
944                <glossterm>Lazy Mode</glossterm>. When disabled (set to
945                <quote>No</quote>), it is in <glossterm>Snapshot
946                Mode</glossterm>. This setting is optional, and the default
947                value is <quote>Yes</quote>.</para>
948              </glossdef>
949            </glossentry>
950
951            <glossentry>
952              <glossterm>UpdateStoreInterval (required)</glossterm>
953
954              <glossdef>
955                <para>The approximate time between successive connections to
956                the server, in seconds, when the client is in <glossterm>Lazy
957                Mode</glossterm>. The actual time is randomised slightly to
958                prevent "rush hour" traffic jams on the server, where many
959                clients try to connect at the same time.</para>
960
961                <para>This value is ignored if the client is in
962                <glossterm>Snapshot Mode</glossterm>. However, it is still
963                required. It can be set to zero in this case.</para>
964
965                <para>You will probably need to experiment with the value of
966                this option. A good value to start with is probably 86400
967                seconds, which is one day.</para>
968              </glossdef>
969            </glossentry>
970
971            <glossentry>
972              <glossterm>MinimumFileAge (required)</glossterm>
973
974              <glossdef>
975                <para>The number of seconds since a file was last modified
976                before it will be backed up. The reason for this is to avoid
977                repeatedly backing up files which are repeatedly changing. A
978                good value is about 3600 seconds (one hour). If set to zero,
979                files which have changed will always be backed up on the next
980                backup run. </para>
981
982                <para>The <glossterm>MaxUploadWait</glossterm> option
983                overrides this option in some circumstances.</para>
984              </glossdef>
985            </glossentry>
986
987            <glossentry>
988              <glossterm>MaxUploadWait (required)</glossterm>
989
990              <glossdef>
991                <para>The number of seconds since a file was last uploaded
992                before it will be uploaded again, even if it keeps changing.
993                The reason for this is to ensure that files which are
994                continuously modified are eventually uploaded anyway. This
995                should be no less than the value of
996                <glossterm>MinimumFileAge</glossterm>. A good value is about
997                14400 seconds (4 hours).</para>
998              </glossdef>
999            </glossentry>
1000
1001            <glossentry>
1002              <glossterm>MaxFileTimeInFuture (optional)</glossterm>
1003
1004              <glossdef>
1005                <para>The maximum time that a file's timestamp can be in the
1006                future, before it will be backed up anyway. Due to clock
1007                synchronisation problems, it is inevitable that you will
1008                occasionally see files timestamped in the future. Normally,
1009                for files which are dated only slightly in the future, you
1010                will want to wait until after the file's date before backing
1011                it up. However, for files whose dates are very wrong (more
1012                than a few hours) you will normally prefer to back them up
1013                immediately.</para>
1014
1015                <para>A good value is about 7200 seconds (2 hours) to cope
1016                with potential problems when moving in and out of daylight
1017                saving time, if applicable in your timezone. The default
1018                value, if this setting is not provided, is 172800 seconds (2
1019                days).</para>
1020              </glossdef>
1021            </glossentry>
1022
1023            <glossentry>
1024              <glossterm>FileTrackingSizeThreshold (required)</glossterm>
1025
1026              <glossdef>
1027                <para>The minimum size of files which will be tracked by inode
1028                number to detect renames. It is not worth detecting renames of
1029                small files, since they are quick to upload again in full, and
1030                keeping their inode numbers in memory increases the client's
1031                memory usage and slows down searches. Larger files should be
1032                tracked to avoid wasting space on the store and long
1033                uploads.</para>
1034
1035                <para>A good value is about 65536 bytes (64 kilobytes).</para>
1036              </glossdef>
1037            </glossentry>
1038
1039            <glossentry>
1040              <glossterm>DiffingUploadSizeThreshold (required)</glossterm>
1041
1042              <glossdef>
1043                <para>The minimum size of files which will be compared to the
1044                old file on the server, and for which only changes will be
1045                uploaded. It is not worth comparing small files, since they
1046                are quick to upload again in full, and sending the entire file
1047                reduces the risk of data loss if the store is accidentally
1048                corrupted. Larger files should have only their differences
1049                uploaded to avoid wasting space on the store and long
1050                uploads.</para>
1051
1052                <para>A good value is about 65536 bytes (64 kilobytes).</para>
1053              </glossdef>
1054            </glossentry>
1055
1056            <glossentry>
1057              <glossterm>MaximumDiffingTime (optional)</glossterm>
1058
1059              <glossdef>
1060                <para>The maximum time for which the client will attempt to
1061                find differences between the current version and the old
1062                version in the store, before giving up and uploading the
1063                entire file again. Very large files (several gigabytes) may
1064                take a very long time to scan for changes, but would also take
1065                a very long time to upload again and use a lot of space on the
1066                store, so it is normally worth omitting this value. </para>
1067
1068                <para>Use this option only if, for some bizarre reason, you
1069                prefer to upload really large files in full rather than spend
1070                a long time scanning them for changes.</para>
1071              </glossdef>
1072            </glossentry>
1073
1074            <glossentry>
1075              <glossterm>KeepAliveTime (optional)</glossterm>
1076
1077              <glossdef>
1078                <para>The interval (in seconds) between sending Keep-Alive
1079                messages to the server while performing long operations such
1080                as finding differences in large files, or scanning large
1081                directories. </para>
1082
1083                <para>These messages ensure that the SSL connection is not
1084                closed by the server, or an intervening firewall, due to lack
1085                of activity.</para>
1086
1087                <para>The server will normally wait up to 15 minutes (900
1088                seconds) before disconnecting the client, so the value should
1089                be given and should be less than 900. Some firewalls may time
1090                out inactive connections after 10 or 5 minutes. </para>
1091
1092                <para>A good value is 300 seconds (5 minutes). You may need to
1093                reduce this if you frequently see TLSReadFailed or
1094                TLSWriteFailed errors on the client.</para>
1095              </glossdef>
1096            </glossentry>
1097
1098            <glossentry>
1099              <glossterm>StoreObjectInfoFile (optional)</glossterm>
1100
1101              <glossdef>
1102                <para>Enables the use of a state file, which stores the
1103                client's internal state when the client is not running. This
1104                is useful on clients machines which are frequently shut down,
1105                for example desktop and laptop computers, because it removes
1106                the need for the client to recontact the store and rescan all
1107                directories on the first backup run, which may take some time.
1108                This feature is somewhat experimental and not well tested.
1109                </para>
1110
1111                <para>This is option is disabled by default, in which case the
1112                state is stored in memory only. The value is the path to the
1113                state file.</para>
1114              </glossdef>
1115            </glossentry>
1116
1117            <glossentry>
1118              <glossterm>ExtendedLogging (optional)</glossterm>
1119
1120              <glossdef>
1121                <para>Enables the connection debugging mode of the client,
1122                which writes all commands sent to or received from the server
1123                to the system logs. This generates a <emphasis>lot</emphasis>
1124                of output, so it should only be used when instructed, or when
1125                you suspect a connection problem or client-server protocol
1126                error (and you know how to interpret the output).</para>
1127
1128                <para>This is a boolean value, which may be set to
1129                <quote>Yes</quote> or <quote>No</quote>. The default is of
1130                course <quote>No</quote>.</para>
1131              </glossdef>
1132            </glossentry>
1133
1134            <glossentry>
1135              <glossterm>ExtendedLogFile (optional, new in 0.11)</glossterm>
1136
1137              <glossdef>
1138                <para>Enables the same debugging output as
1139                <glossterm>ExtendedLogging</glossterm>, but written to a file
1140                instead of the system logs. This is useful if you need
1141                extended logging, but do not have access to the system logs,
1142                for example if you are not the administrator of the
1143                computer.</para>
1144
1145                <para>The value is the path to the file where these logs will
1146                be written. If omitted, extended logs will not be written to a
1147                file. This is entirely independent of the
1148                <glossterm>ExtendedLogging</glossterm> option. It does not
1149                make much sense to use both at the same time.</para>
1150              </glossdef>
1151            </glossentry>
1152
1153            <glossentry>
1154              <glossterm>LogAllFileAccess (optional, new in 0.11)</glossterm>
1155
1156              <glossdef>
1157                <para>Enables logging of all local file and directory access,
1158                file uploads (full and differential), and excluded files. This
1159                may be useful if the client is failing to upload a particular
1160                file, or crashing while trying to upload it. The logs will be
1161                sent to the system log or Windows Event Viewer.</para>
1162
1163                <para>This generates a <emphasis>lot</emphasis>
1164                of output, so it should only be used when instructed, or when
1165                you suspect that bbackupd is skipping some files and want to
1166                know why. Because it is verbose, the messages are hidden by
1167                default even if the option is enabled. To see them, you must
1168                run bbackupd with at least one -v option.</para>
1169
1170                <para>This is a boolean value, which may be set to
1171                <quote>Yes</quote> or <quote>No</quote>. The default is of
1172                course <quote>No</quote>.</para>
1173              </glossdef>
1174            </glossentry>
1175
1176            <glossentry>
1177              <glossterm>SyncAllowScript (optional)</glossterm>
1178
1179              <glossdef>
1180                <para>The path to the script or command to run when the client
1181                is about to start an automatic backup run, and wishes to know
1182                whether it is safe to do so. This is useful for clients which
1183                do not always have access to the server, for example laptops
1184                and computers on dial-up Internet connections.</para>
1185
1186                <para>The script should either output the word
1187                <quote>now</quote> if the backup should proceed, or else a
1188                number, in seconds, which indicates how long the client should
1189                wait before trying to connect again. Any other output will
1190                result in an error on the client, and the backup will not
1191                run.</para>
1192
1193                <para>This value is optional, and by default no such script is
1194                used.</para>
1195              </glossdef>
1196            </glossentry>
1197          </glosslist>
1198        </section>
1199
1200        <section>
1201          <title>Server Section</title>
1202
1203          <para>These options appear within the Server subsection, which is at
1204          the root level.</para>
1205
1206          <glosslist>
1207            <glossentry>
1208              <glossterm>PidFile</glossterm>
1209
1210              <glossdef>
1211                <para>This option enables the client to write its processs
1212                identifier (PID) to the specified file after starting. The
1213                file will be deleted when the client daemon exits for any
1214                reason. This is disabled by default, but is recommended
1215                whenever you run the client daemon as a daemon (in the
1216                background), which is usually the case. This file can be used
1217                by scripts to determine whether the daemon is still running,
1218                and to send it messages to reload its configuration or to
1219                terminate.</para>
1220
1221                <example>
1222                  <title>Example Server Section</title>
1223
1224                  <programlisting>Server
1225{
1226    PidFile = /var/state/boxbackup/bbackupd.pid
1227}</programlisting>
1228                </example>
1229              </glossdef>
1230            </glossentry>
1231          </glosslist>
1232        </section>
1233
1234        <section>
1235          <title>Backup Locations Section</title>
1236
1237          <para>This section serves only as a container for all defined backup
1238          locations.</para>
1239
1240          <example>
1241            <title>Example Backup Locations Section</title>
1242
1243            <programlisting>BackupLocations
1244{
1245        etc
1246        {
1247                Path = /etc
1248        }
1249        home
1250        {
1251                Path = /home
1252                ExcludeDir = /home/shared
1253                ExcludeDir = /home/chris/.ccache
1254                ExcludeDir = /home/chris/.mozilla/firefox/vvvkq3vp.default/Cache
1255        }
1256}</programlisting>
1257          </example>
1258
1259          <para>Each subsection is a backup location. The name of the
1260          subsection is the name that will be used on the server. The root
1261          directory of the account on the server contains one subdirectory per
1262          location. The name should be simple, not containing any spaces or
1263          special characters.</para>
1264
1265          <para>If you do not define any locations, the client will not back
1266          up any files!</para>
1267
1268          <para>It is currently not recommended to back up the root directory
1269          of the filesystem on Unix. Box Backup is designed to back up
1270          important data and configuration files, not full systems.
1271          Nevertheless, nothing prevents you from doing so if you
1272          desire.</para>
1273
1274          <para>On Windows, it is currently not possible to back up files
1275          which are open (currently in use), such as open documents in
1276          Microsoft Office, and system files such as the registry and the
1277          paging file. You will get an error for each open file which the
1278          client attempts to back up. Once the file has been closed, it will
1279          be backed up normally. System files will always be open, and should
1280          be excluded from your backups.</para>
1281        </section>
1282      </section>
1283    </section>
1284  </chapter>
1285
1286  <chapter>
1287    <title>Administration</title>
1288
1289    <para>This chapter deals with the dauily running and management of the Box
1290    Backup system. It explains most day-to-day tasks.</para>
1291
1292    <section>
1293      <title>Regular Maintenance</title>
1294
1295      <para>The steps involved in maintaining and keeping the backup sets
1296      healthy are outlined in this section.</para>
1297
1298      <section>
1299        <title>Controlling a backup client</title>
1300
1301        <para>The bbackupctl program sends control commands to the bbackupd
1302        daemon. It must be run as the same user as the daemon, and there is no
1303        exception for root.</para>
1304
1305        <para>The command line syntax is:</para>
1306
1307        <programlisting>/usr/local/sbin/bbackupctl [-q] [-c config-file] command</programlisting>
1308
1309        <para>The -q option reduces the amount of output the program emits,
1310        and -c allows an alternative configuration file to be
1311        specified.</para>
1312
1313        <para>Valid commands are:</para>
1314
1315        <itemizedlist>
1316          <listitem>
1317            <para><emphasis role="bold">terminate</emphasis></para>
1318
1319            <para>Stop the bbackupd daemon now (equivalent to kill)</para>
1320          </listitem>
1321
1322          <listitem>
1323            <para><emphasis role="bold">reload</emphasis></para>
1324
1325            <para>Reload the configuration file (equivalent to kill
1326            -HUP)</para>
1327          </listitem>
1328
1329          <listitem>
1330            <para><emphasis role="bold">sync</emphasis></para>
1331
1332            <para>Connect to the server and synchronise files now</para>
1333          </listitem>
1334        </itemizedlist>
1335
1336        <para><emphasis role="bold">bbackupctl</emphasis> communicates with
1337        the server via a UNIX domain socket, specified in bbackupd.conf with
1338        the CommandSocket directive. This does not need to be specified, and
1339        <emphasis role="bold">bbackupd</emphasis> will run without the command
1340        socket, but in this case bbackupctl will not be able to communicate
1341        with the daemon.</para>
1342
1343        <para>Some platforms cannot check the user id of the connecting
1344        process, so this command socket becomes a denial of service security
1345        risk. <emphasis role="bold">bbackupd</emphasis> will warn you when it
1346        starts up if this is the case on your platform, and you should
1347        consider removing the CommandSocket directive on these
1348        platforms.</para>
1349      </section>
1350
1351      <section>
1352        <title>Using bbackupctl to perform snapshots</title>
1353
1354        <para><emphasis role="bold">bbackupctl</emphasis>'s main purpose is to
1355        implement snapshot based backups, emulating the behaviour of
1356        traditional backup software.</para>
1357
1358        <para>Use bbackupd-config to write a configuration file in snapshot
1359        mode, and then run the following command as a cron job.</para>
1360
1361        <programlisting>/usr/local/sbin/bbackupctl -q sync</programlisting>
1362
1363        <para>This will cause the backup daemon to upload all changed files
1364        immediately. <emphasis role="bold">bbackupctl</emphasis> will exit
1365        almost immediately, and will not output anything unless there is an
1366        error.</para>
1367      </section>
1368
1369      <section>
1370        <title>Checking storage space used on the server</title>
1371
1372        <section>
1373          <title>From the client machine</title>
1374
1375          <para>bbackupquery can tell you how much space is used on the server
1376          for this account. Either use the usage command in interactive mode,
1377          or type:</para>
1378
1379          <programlisting>/usr/local/sbin/bbackupquery -q usage quit</programlisting>
1380
1381          <para>to show the space used as a single command.</para>
1382        </section>
1383
1384        <section>
1385          <title>On the server</title>
1386
1387          <para>bbstoreaccounts allows you to query the space used, and change
1388          the limits. To display the space used on the server for an account,
1389          use:</para>
1390
1391          <programlisting>/usr/local/sbin/bbstoreaccounts info 75AB23C</programlisting>
1392
1393          <para>To adjust the soft and hard limits on an account, use:</para>
1394
1395          <programlisting>/usr/local/sbin/bbstoreaccounts setlimit 75AB23C new-soft-limit new-hard-limit</programlisting>
1396
1397          <para>You do not need to restart the server.</para>
1398        </section>
1399      </section>
1400
1401      <section>
1402        <title>Verify and restore files</title>
1403
1404        <para>Backups are no use unless you can restore them. The bbackupquery
1405        utility does this and more.</para>
1406
1407        <para>You don't provide any login information to it, as it just picks
1408        up the data it needs from /etc/box/bbackupd.conf. You should run it as
1409        root so it can find everything it needs.</para>
1410
1411        <para>Full documentation can be found in the <ulink
1412        url="bbackupquery.xml">bbackupquery manual page</ulink>. It follows
1413        the model of a command line sftp client quite closely.</para>
1414
1415        <para>TODO: Link to bbackupquery man-page here.</para>
1416
1417        <para>On systems where GNU readline is available (by default) it uses
1418        that for command line history and editing. Otherwise it falls back to
1419        very basic UNIX text entry.</para>
1420
1421        <para>TODO: Did the readline dependency change to editline?</para>
1422
1423        <section>
1424          <title>Using bbackupquery</title>
1425
1426          <para>bbackupquery is the tool you use to verify, restore and
1427          investigate your backup files with. When invoked, it simply logs
1428          into the server using the certificates you have listed in
1429          bbackupd.conf.</para>
1430
1431          <para>After you run bbackupquery, you will see a prompt, allowing
1432          you to execute commands. The list (or ls) command lets you view
1433          files in the store. It works much like unix ls, but with different
1434          options. An example:</para>
1435
1436          <programlisting>[pthomsen@host bbackupquery]$ bbackupquery
1437Box Backup Query Tool  v0.10, (c) Ben Summers and contributors 2003-2006
1438Using configuration file /etc/box/bbackupd.conf
1439Connecting to store...
1440Handshake with store...
1441Login to store...
1442Login complete.
1443
1444Type "help" for a list of commands.
1445
1446query &gt; ls
144700000002 -d---- mp3
144800000003 -d---- video
144900000004 -d---- home-pthomsen
145000000005 -d---- root
1451query &gt;   </programlisting>
1452
1453          <para>The ls commands shows the directories that are backed up. Now
1454          we'll take a closer look at the home-pthomsen directory:</para>
1455
1456          <programlisting>query &gt; cd home-pthomsen
1457query &gt; ls
145800002809 f----- sample.tiff
14590000280a f----- s3.tiff
14600000280b f----- s4.tiff
14610000280d f----- s2.tiff
14620000280e f----- foo.pdf
14630000286c f----- core.28720
14640000339a -d---- .emacs.d
14650000339d -d---- bbackup-contrib
146600003437 f----- calnut.compare.txt
14670000345d f----- DSCN1783.jpg
14680000345e f----- DSCN1782.jpg
1469query &gt;</programlisting>
1470
1471          <para>The ls command takes the following options;</para>
1472
1473          <itemizedlist>
1474            <listitem>
1475              <para><emphasis role="bold">-r </emphasis>-- recursively list
1476              all files</para>
1477            </listitem>
1478
1479            <listitem>
1480              <para><emphasis role="bold">-d</emphasis> -- list deleted
1481              files/directories</para>
1482            </listitem>
1483
1484            <listitem>
1485              <para><emphasis role="bold">-o</emphasis> -- list old versions
1486              of files/directories</para>
1487            </listitem>
1488
1489            <listitem>
1490              <para><emphasis role="bold">-I</emphasis> -- don't display
1491              object ID</para>
1492            </listitem>
1493
1494            <listitem>
1495              <para><emphasis role="bold">-F </emphasis>-- don't display
1496              flags</para>
1497            </listitem>
1498
1499            <listitem>
1500              <para><emphasis role="bold">-t </emphasis>-- show file
1501              modification time (and attr mod time if has the object has
1502              attributes, ~ separated)</para>
1503            </listitem>
1504
1505            <listitem>
1506              <para><emphasis role="bold">-s</emphasis> -- show file size in
1507              blocks used on server (only very approximate indication of size
1508              locally)</para>
1509            </listitem>
1510          </itemizedlist>
1511
1512          <para>The flags displayed from the ls command are as follows:</para>
1513
1514          <simplelist>
1515            <member>f = file</member>
1516
1517            <member>d = directory</member>
1518
1519            <member>X = deleted</member>
1520
1521            <member>o = old version</member>
1522
1523            <member>R = remove from server as soon as marked deleted or
1524            old</member>
1525
1526            <member>a = has attributes stored in directory record which
1527            override attributes in backup file</member>
1528          </simplelist>
1529        </section>
1530
1531        <section>
1532          <title>Verify backups</title>
1533
1534          <para>As with any backup system, you should frequently check that
1535          your backups are working properly by comparing them. Box Backup
1536          makes this very easy and completely automatic. All you have to do is
1537          schedule the <command>bbackupquery compare</command> command to run
1538          regularly, and check its output. You can run the command manually as
1539          follows:</para>
1540
1541          <programlisting>/usr/local/sbin/bbackupquery "compare -a" quit</programlisting>
1542
1543          <para>This command will report all the differences found between the
1544          store and the files on disc. It will download everything, so may
1545          take a while. You should expect to see some differences on a typical
1546          compare, because files which have recently changed are unlikely to
1547          have been uploaded yet. It will also tell you how many files have
1548          been modified since the last backup run, since these will normally
1549          have changed, and such failures are expected.</para>
1550
1551          <para>You are strongly recommended to add this command as a
1552          <command>cron</command> job, at least once a month, and to check the
1553          output for anything suspicious, particularly a large number of
1554          compare failures, failures on files that have not been modified, or
1555          any error (anything except a compare mismatch) that occurs during
1556          the compare operation.</para>
1557
1558          <para>Consider keeping a record of these messages and comparing them
1559          with a future verification.</para>
1560
1561          <para>If you would like to do a "quick" check which just downloads
1562          file checksums and compares against that, then run:</para>
1563
1564          <programlisting>/usr/local/sbin/bbackupquery "compare -aq" quit</programlisting>
1565
1566          <para>However, this does not check that the file attributes are
1567          correct, and since the checksums are generated on the client they
1568          may not reflect the data on the server if there is a problem -- the
1569          server cannot check the encrypted contents. View this as a quick
1570          indication, rather than a definite check that your backup verifies
1571          correctly.</para>
1572        </section>
1573
1574        <section>
1575          <title>Restore backups</title>
1576
1577          <para>You will need the keys file created when you configured the
1578          server. Without it, you cannot restore the files; this is the
1579          downside of encrypted backups. However, by keeping the small keys
1580          file safe, you indirectly keep your entire backup safe.</para>
1581
1582          <para>The first step is to recreate the configuration of the backup
1583          client. It's probably best to have stored the /etc/box directory
1584          with your keys. But if you're recreating it, all you really need is
1585          to have got the login infomation correct (ie the certs and
1586          keys).</para>
1587
1588          <para>Don't run bbackupd yet! It will mark all your files as deleted
1589          if you do, which is not hugely bad in terms of losing data, just a
1590          major inconvenience. (This assumes that you are working from a blank
1591          slate. If you want to restore some files to a different location,
1592          it's fine to restore while bbackupd is running, just do it outside a
1593          backed up directory to make sure it doesn't start uploading the
1594          restored files.)</para>
1595
1596          <para>Type:</para>
1597
1598          <programlisting>/usr/local/sbin/bbackupquery</programlisting>
1599
1600          <para>to run it in interactive mode.</para>
1601
1602          <para>Type:</para>
1603
1604          <programlisting>list</programlisting>
1605
1606          <para>to see a list of the locations stored on the server.</para>
1607
1608          <para>For each location you want to restore, type:</para>
1609
1610          <programlisting>restore name-on-server local-dir-name</programlisting>
1611
1612          <para>The directory specified by local-dir-name must not exist yet.
1613          If the restore is interrupted for any reason, repeat the above
1614          steps, but add the <emphasis role="bold">-r</emphasis> flag to the
1615          restore command to tell it to resume.</para>
1616        </section>
1617
1618        <section>
1619          <title>Retrieving deleted and old files</title>
1620
1621          <para>Box Backup makes old versions of files and files you have
1622          deleted available, subject to there being enough disc space on the
1623          server to hold them.</para>
1624
1625          <para>This is how to retrieve them using bbackupquery. Future
1626          versions will make this far more user-friendly.</para>
1627
1628          <para>Firstly, run bbackupquery in interactive mode. It behaves in a
1629          similar manner to a command line sftp client.</para>
1630
1631          <programlisting>/usr/local/sbin/bbackupquery</programlisting>
1632
1633          <para>Then navigate to the directory containing the file you want,
1634          using list, cd and pwd.</para>
1635
1636          <programlisting>query &gt; cd home/profiles/USERNAME</programlisting>
1637
1638          <para>List the directory, using the "o" option to list the files
1639          available without filtering out everything apart from the current
1640          version. (if you want to see deleted files as well, use list
1641          -odt)</para>
1642
1643          <programlisting>query &gt; list -ot
164400000078 f--o- 2004-01-21T20:17:48 NTUSER.DAT
164500000079 f--o- 2004-01-21T20:17:48 ntuser.dat.LOG
16460000007a f--o- 2004-01-21T17:55:12 ntuser.ini
16470000007b f---- 2004-01-12T15:32:00 ntuser.pol
16480000007c -d--- 1970-01-01T00:00:00 Templates
164900000089 -d--- 1970-01-01T00:00:00 Start Menu
1650000000a0 -d--- 1970-01-01T00:00:00 SendTo
1651000000a6 -d--- 1970-01-01T00:00:00 Recent
165200000151 -d--- 1970-01-01T00:00:00 PrintHood
165300000152 -d--- 1970-01-01T00:00:00 NetHood
165400000156 -d--- 1970-01-01T00:00:00 My Documents
16550000018d -d--- 1970-01-01T00:00:00 Favorites
165600000215 -d--- 1970-01-01T00:00:00 Desktop
165700000219 -d--- 1970-01-01T00:00:00 Cookies
16580000048b -d--- 1970-01-01T00:00:00 Application Data
1659000005da -d--- 1970-01-01T00:00:00 UserData
16600000437e f--o- 2004-01-24T02:45:43 NTUSER.DAT
16610000437f f--o- 2004-01-24T02:45:43 ntuser.dat.LOG
166200004380 f--o- 2004-01-23T17:01:29 ntuser.ini
166300004446 f--o- 2004-01-24T02:45:43 NTUSER.DAT
166400004447 f--o- 2004-01-24T02:45:43 ntuser.dat.LOG
1665000045f4 f---- 2004-01-26T15:54:16 NTUSER.DAT
1666000045f5 f---- 2004-01-26T15:54:16 ntuser.dat.LOG
1667000045f6 f---- 2004-01-26T16:54:31 ntuser.ini</programlisting>
1668
1669          <para>(this is a listing from a server which is used as a Samba
1670          server for a network of Windows clients.) You now need to fetch the
1671          file using it's ID, rather than it's name. The ID is the hex number
1672          in the first column. Fetch it like this:</para>
1673
1674          <programlisting>query &gt; get -i 0000437e NTUSER.DAT
1675Object ID 0000437e fetched successfully.</programlisting>
1676
1677          <para>The object is now available on your local machine. You can use
1678          lcd to move around, and sh ls to list directories on your local
1679          machine.</para>
1680        </section>
1681      </section>
1682    </section>
1683
1684    <section>
1685      <title id="FixCorruptions">Fixing corruptions of store data</title>
1686
1687      <para>This section gives help on what to do if your server has suffered
1688      corruption, for example, after an unclean shutdown or other operating
1689      system or hardware problem.</para>
1690
1691      <para>In general, as updates to the store are made in an atomic manner,
1692      the most likely result is wasted disc space. However, if really bad
1693      things happen, or you believe that there is a lot of wasted space, then
1694      these instructions will help to restore your data.</para>
1695
1696      <para>You know you will need to do something if you get strange errors,
1697      and bbackupd attempts to contact the server every 100 seconds or so. Or
1698      if one of the discs in your RAID disc set has failed.</para>
1699
1700      <para>After following these instructions, the end result will be that
1701      bbackupquery will be able to see all the files which were stored on your
1702      server, and retrieve them. Some of them may be in lost+found directories
1703      in the root of the store (or in their original position if they have
1704      been moved) but they will all be able to be retrieved.</para>
1705
1706      <para>After you have retrieved the files you want, bbackupd will upload
1707      new versions where necessary, and after about two days, mark any
1708      lost+found directories as deleted. Finally, those directories will be
1709      removed by the housekeeping process on the server.</para>
1710
1711      <para>These instructions assume you're working on account 1234. Replace
1712      this with the account number that you actually want to check (the one
1713      that is experiencing errors). These steps will need to be repeated for
1714      all affected accounts.</para>
1715
1716      <section>
1717        <title>Stop bbackupd</title>
1718
1719        <para>First, make sure that bbackupd is not running on the client
1720        machine for the account you are going to recover. Use
1721        <command>bbackupctl terminate</command> to stop it. This step is not
1722        strictly necessary, but is recommended. During any checks on the
1723        account, bbackupd will be unable to log in, and after they are
1724        complete, the account is marked as changed on the server so bbackupd
1725        will perform a complete scan.</para>
1726      </section>
1727
1728      <section>
1729        <title>Are you using RAID on the server?</title>
1730
1731        <para>The raidfile recovery tools have not been written, and probably
1732        will not be, since Box Backup RAID is deprecated. However, when two
1733        out of three files are available, the server will successfully allow
1734        access to your data, even if it complains a lot in the logs. The best
1735        thing to do is to fix the accounts, if necessary, and retrieve any
1736        files you need. Then move the old store directories aside (in case you
1737        need them) and start afresh with new accounts, and let the clients
1738        upload all their data again.</para>
1739      </section>
1740
1741      <section>
1742        <title>Check and fix the account</title>
1743
1744        <para>First, run the check utility, and see what errors it
1745        reports.</para>
1746
1747        <programlisting>/usr/local/sbin/bbstoreaccounts check 1234</programlisting>
1748
1749        <para>This will take some time, and use a fair bit of memory (about 16
1750        bytes per file and directory). If the output looks plausible and
1751        reports errors which need fixing, run it again but with the fix
1752        flag:</para>
1753
1754        <programlisting>/usr/local/sbin/bbstoreaccounts check 1234 fix</programlisting>
1755
1756        <para>This will fix any errors, and remove unrecoverable files.
1757        Directories will be recreated if necessary.</para>
1758
1759        <para><emphasis role="bold">NOTE</emphasis>: The utility may adjust
1760        the soft and hard limits on the account to make sure that housekeeping
1761        will not remove anything -- check these afterwards.</para>
1762      </section>
1763
1764      <section>
1765        <title>Grab any files you need with bbackupquery</title>
1766
1767        <para>At this point, you will have a working store. Every file which
1768        was on the server, and wasn't corrupt, will be available.</para>
1769
1770        <para>On the client, use bbackupquery to log in and examine the store.
1771        (type help at the prompt for instructions). Retrieve any files you
1772        need, paying attention to any lost+found directories in the root
1773        directory of the store.</para>
1774
1775        <para>You can skip this step if you are sure that the client machine
1776        is fine -- in this case, bbackupd will bring the store up to
1777        date.</para>
1778      </section>
1779
1780      <section>
1781        <title>Restart bbackupd</title>
1782
1783        <para>Restart bbackupd on the client machine. The store account will
1784        be brought up to date, and files in the wrong place will be marked for
1785        eventual deletion.</para>
1786      </section>
1787    </section>
1788
1789    <section>
1790      <title id="Troubleshooting">Troubleshooting</title>
1791
1792      <para>If you are trying to fix a store after your disc has been
1793      corrupted, see <link linkend="FixCorruptions">Fixing corruptions of
1794      store data</link>.</para>
1795
1796      <para>Unfortunately, the error messages are not particularly helpful at
1797      the moment. This page lists some of the common errors, and the most
1798      likely causes of them.</para>
1799
1800      <para>When an error occurs, you will see a message like 'Exception:
1801      RaidFile/OSFileError (2/8)' either on the screen or in your log files.
1802      (it is recommended you set up another log file as recommended in the
1803      server setup instructions.)</para>
1804
1805      <para>This error may not be particularly helpful, although some do have
1806      extra information about probable causes. To get further information,
1807      check the ExceptionCodes.txt file in the root of the distribution. This
1808      file is generated by the ./configure script, so you will need to have
1809      run that first.</para>
1810
1811      <para>Some common causes of exceptions are listed below.</para>
1812
1813      <para>Please email me with any other codes you get, and I will let you
1814      know what they mean, and add notes here.</para>
1815
1816      <section>
1817        <title>RaidFile (2/8)</title>
1818
1819        <para>This is found either when running bbstoreaccounts or in the
1820        bbstored logs.</para>
1821
1822        <para><emphasis role="bold">Problem</emphasis>: The directories you
1823        specified in the raidfile.conf are not writable by the _bbstored
1824        user.</para>
1825
1826        <para><emphasis role="bold">Resolution</emphasis>: Change permissions
1827        appropriately.</para>
1828      </section>
1829
1830      <section>
1831        <title>Common (1/2)</title>
1832
1833        <para>This usually occurs when the configuration files can't be
1834        opened.</para>
1835
1836        <para><emphasis role="bold">Problem</emphasis>: You created your
1837        configurations in non-standard locations, and the programs cannot find
1838        them.</para>
1839
1840        <para><emphasis role="bold">Resolution</emphasis>: Explicitly specify
1841        configuration file locations to daemons and programs. For
1842        example</para>
1843
1844        <programlisting>/usr/local/sbin/bbstored /some/other/dir/bbstored.config /usr/local/sbin/bbackupquery -c /some/other/dir/bbackupd.config</programlisting>
1845
1846        <para>(daemons specify the name as the first argument, utility
1847        programs with the -c option).</para>
1848
1849        <para><emphasis role="bold">Problem</emphasis>: bbstored can't find
1850        the raidfile.conf file specified in bbstored.conf.</para>
1851
1852        <para><emphasis role="bold">Resolution</emphasis>: Edit bbstored.conf
1853        to point to the correct location of this additional configuration
1854        file.</para>
1855      </section>
1856
1857      <section>
1858        <title>Server (3/16)</title>
1859
1860        <para>The server can't listen for connections on the IP address
1861        specified when you configured it.</para>
1862
1863        <para><emphasis role="bold">Problem</emphasis>: This probably means
1864        you've specified the wrong hostname to bbstored-config -- maybe your
1865        server is behind a NAT firewall?</para>
1866
1867        <para><emphasis role="bold">Resolution</emphasis>: Edit bbstored.conf
1868        and correct the ListenAddresses line. You should replace the server
1869        address with the IP address of your machine.</para>
1870      </section>
1871
1872      <section>
1873        <title>Connection (7/x)</title>
1874
1875        <para>These errors all relate to connections failing -- you may see
1876        them during operation if there are network failures or other problems
1877        between the client and server. The backup system will recover from
1878        them automatically.</para>
1879
1880        <section>
1881          <title>Connection (7/30) - SSL problems</title>
1882
1883          <para>Log snippet from client side:</para>
1884
1885          <programlisting>bbackupd[1904]: Opening connection to server xxxx.xxx...
1886bbackupd[1904]: SSL err during Connect: error:xxxxxxxx:rsa routines:RSA_padding_check_PKCS1_type_1:block type is not 01
1887bbackupd[1904]: SSL err during Connect: error:xxxxxxxx:rsa routines:RSA_EAY_PUBLIC_DECRYPT:padding check failed
1888bbackupd[1904]: SSL err during Connect: error:xxxxxxxx:asn1 encoding routines:ASN1_verify:EVP lib
1889bbackupd[1904]: SSL err during Connect: error:xxxxxxxx:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
1890bbackupd[1904]: TRACE: Exception thrown: ConnectionException(Conn_TLSHandshakeFailed) at SocketStreamTLS.cpp(237)
1891bbackupd[1904]: Exception caught (7/30), reset state and waiting to retry...</programlisting>
1892
1893          <para>And from the server:</para>
1894
1895          <programlisting>bbstored[19291]: Incoming connection from xx.xxx.xx.xxx port xxxxx (handling in child xxxxx)
1896bbstored[21588]: SSL err during Accept: error:xxxxxxxx:SSL routines:SSL3_READ_BYTES:tlsv1 alert decrypt error
1897bbstored[21588]: in server child, exception Connection TLSHandshakeFailed (7/30) -- terminating child</programlisting>
1898
1899          <para><emphasis role="bold">Solution</emphasis>: Create a new CA on
1900          the server side and re-generate the client certificate. Re-creating
1901          the client certificate request is not necessary.</para>
1902        </section>
1903      </section>
1904
1905      <section>
1906        <title>Advanced troubleshooting</title>
1907
1908        <para>If this really doesn't help, then using the DEBUG builds of the
1909        system will give you much more information -- a more descriptive
1910        exception message and the file and line number where the error
1911        occurred.</para>
1912
1913        <para>For example, if you are having problems with bbstoreaccounts,
1914        build the debug version with:</para>
1915
1916        <programlisting>cd boxbackup-0.0
1917cd bin/bbstoreaccounts
1918make</programlisting>
1919
1920        <para>Within the module directories, make defaults to building the
1921        debug version. At the top level, it defaults to release.</para>
1922
1923        <para>This will build an executable in debug/bin/bbstoreaccounts which
1924        you can then use instead of the release version. It will give far more
1925        useful error messages.</para>
1926
1927        <para>When you get an error message, use the file and line number to
1928        locate where the error occurs in the code. There will be comments
1929        around that line to explain why the exception happened.</para>
1930
1931        <para>If you are using a debug version of a daemon, these extended
1932        messages are found in the log files.</para>
1933      </section>
1934    </section>
1935  </chapter>
1936
1937  &__ExceptionCodes__elfjz3fu;
1938
1939  <appendix>
1940    <title id="WORoot">Running without root</title>
1941
1942    <para>It is possible to run both the server and client without root
1943    privileges.</para>
1944
1945    <section>
1946      <title>Server</title>
1947
1948      <para>The server, by default, runs as a non-root user. However, it
1949      expects to be run as root and changes user to a specified user as soon
1950      as it can, simply for administrative convenience. The server uses a port
1951      greater than 1024, so it doesn't need root to start.</para>
1952
1953      <para>To run it entirely as a non-root user, edit the bbstored.conf
1954      file, and remove the User directive from the Server section. Then simply
1955      run the server as your desired user.</para>
1956    </section>
1957
1958    <section>
1959      <title>Client</title>
1960
1961      <para>The client requires root for normal operation, since it must be
1962      able to access all files to back them up. However, it is possible to run
1963      the client as a non-root user, with certain limitations.</para>
1964
1965      <para>Follow the installation instructions, but install the executable
1966      files manually to somewhere in your home directory. Then use
1967      bbackupd-config to configure the daemon, but use a directory other than
1968      /etc/box, probably somewhere in your home directory.</para>
1969
1970      <para>All directories you specify to be backed up must be readable, and
1971      all files must be owned by the user and readable to that user.</para>
1972
1973      <para>Important: If any file or directory is not readable by this user,
1974      the backup process will skip that file or directory. Keep an eye on the
1975      logs for reports of this failure.</para>
1976
1977      <para>Non-root operation of the backup client is recommended only for
1978      testing, and should not be relied on in a production environment.</para>
1979    </section>
1980  </appendix>
1981</book>
Note: See TracBrowser for help on using the repository browser.