5e1b190cbf0637d6ce4db7eb451db8447ec0560c
[BackupPC.git] / doc-src / BackupPC.pod
1 =head1 BackupPC Introduction
2
3 This documentation describes BackupPC version __VERSION__,
4 released on __RELEASEDATE__.
5
6 =head2 Overview
7
8 BackupPC is a high-performance, enterprise-grade system for backing up
9 Unix, Linux, WinXX, and MacOSX PCs, desktops and laptops to a server's
10 disk.  BackupPC is highly configurable and easy to install and maintain.
11
12 Given the ever decreasing cost of disks and raid systems, it is now
13 practical and cost effective to backup a large number of machines onto
14 a server's local disk or network storage.  For some sites this might be
15 the complete backup solution.  For other sites additional permanent
16 archives could be created by periodically backing up the server to tape.
17
18 Features include:
19
20 =over 4
21
22 =item *
23
24 A clever pooling scheme minimizes disk storage and disk I/O.
25 Identical files across multiple backups of the same or different PC
26 are stored only once (using hard links), resulting in substantial
27 savings in disk storage and disk writes.
28
29 =item *
30
31 Optional compression provides additional reductions in storage
32 (around 40%).  The CPU impact of compression is low since only
33 new files (those not already in the pool) need to be compressed.
34
35 =item *
36
37 A powerful http/cgi user interface allows administrators to view
38 the current status, edit configuration, add/delete hosts, view log
39 files, and allows users to initiate and cancel backups and browse
40 and restore files from backups.
41
42 =item *
43
44 The http/cgi user interface has internationalization (i18n) support,
45 currently providing English, French, German, Spanish, Italian,
46 Dutch and Portuguese-Brazilian.
47
48 =item *
49
50 No client-side software is needed. On WinXX the standard smb protocol is
51 used to extract backup data. On linux, unix or MacOSX clients, rsync or
52 tar (over ssh/rsh/nfs) is used to extract backup data. Alternatively,
53 rsync can also be used on WinXX (using cygwin), and Samba could be
54 installed on the linux or unix client to provide smb shares).
55
56 =item *
57
58 Flexible restore options.  Single files can be downloaded from
59 any backup directly from the CGI interface.  Zip or Tar archives
60 for selected files or directories from any backup can also be
61 downloaded from the CGI interface.  Finally, direct restore to
62 the client machine (using smb or tar) for selected files or
63 directories is also supported from the CGI interface.
64
65 =item *
66
67 BackupPC supports mobile environments where laptops are only
68 intermittently connected to the network and have dynamic IP addresses
69 (DHCP).  Configuration settings allow machines connected via slower WAN
70 connections (eg: dial up, DSL, cable) to not be backed up, even if they
71 use the same fixed or dynamic IP address as when they are connected
72 directly to the LAN.
73
74 =item *
75
76 Flexible configuration parameters allow multiple backups to be performed
77 in parallel, specification of which shares to backup, which directories
78 to backup or not backup, various schedules for full and incremental
79 backups, schedules for email reminders to users and so on.  Configuration
80 parameters can be set system-wide or also on a per-PC basis.
81
82 =item *
83
84 Users are sent periodic email reminders if their PC has not
85 recently been backed up.  Email content, timing and policies
86 are configurable.
87
88 =item *
89
90 BackupPC is Open Source software hosted by SourceForge.
91
92 =back
93
94 =head2 Backup basics
95
96 =over 4
97
98 =item Full Backup
99
100 A full backup is a complete backup of a share. BackupPC can be
101 configured to do a full backup at a regular interval (typically
102 weekly).  BackupPC can be configured to keep a certain number
103 of full backups.  Exponential expiry is also supported, allowing
104 full backups with various vintages to be kept (for example, a
105 settable number of most recent weekly fulls, plus a settable
106 number of older fulls that are 2, 4, 8, or 16 weeks apart).
107
108 =item Incremental Backup
109
110 An incremental backup is a backup of files that have changed
111 since the last successful full or incremental backup.  Starting
112 in BackupPC 3.0 multi-level incrementals are supported.
113 A full backup has level 0.  A new incremental of level N will
114 backup all files that have changed since the most recent backup
115 of a lower level.  $Conf{IncrLevels} is used to specify the
116 level of each successive incremental.  The default value is
117 all level 1, which makes the behavior the same as earlier
118 versions of BackupPC: each incremental will back up all the
119 files that changed since the last full (level 0).
120
121 For SMB and tar, BackupPC uses the modification time (mtime) to
122 determine which files have changed since the last lower-level
123 backup.  That mean SMB and tar incrementals are not able to detect
124 deleted files, renamed files or new files whose modification time
125 is prior to the last lower-level backup.
126
127 Rsync is more clever: any files whose attributes have changed (ie: uid,
128 gid, mtime, modes, size) since the last full are backed up.  Deleted,
129 new files and renamed files are detected by Rsync incrementals.
130
131 BackupPC can also be configured to keep a certain number of incremental
132 backups, and to keep a smaller number of very old incremental backups.
133 If multi-level incrementals are specified then it is likely that
134 more incrementals will need to be kept since lower-level incrementals
135 (and the full backup) are needed to reconstruct a higher-level
136 incremental.
137
138 BackupPC "fills-in" incremental backups when browsing or restoring,
139 based on the levels of each backup, giving every backup a "full"
140 appearance.  This makes browsing and restoring backups much easier:
141 you can restore from any one backup independent of whether it was
142 an incremental or full.
143
144 =item Partial Backup
145
146 When a full backup fails or is canceled, and some files have already
147 been backed up, BackupPC keeps a partial backup containing just the
148 files that were backed up successfully.  The partial backup is removed
149 when the next successful backup completes, or if another full backup
150 fails resulting in a newer partial backup.  A failed full backup
151 that has not backed up any files, or any failed incremental backup,
152 is removed; no partial backup is saved in these cases.
153
154 The partial backup may be browsed or used to restore files just like
155 a successful full or incremental backup.
156
157 With the rsync transfer method the partial backup is used to resume
158 the next full backup, avoiding the need to retransfer the file data
159 already in the partial backup.
160
161 =item Identical Files
162
163 BackupPC pools identical files using hardlinks.  By "identical
164 files" we mean files with identical contents, not necessary the
165 same permissions, ownership or modification time.  Two files might
166 have different permissions, ownership, or modification time but
167 will still be pooled whenever the contents are identical.  This
168 is possible since BackupPC stores the file meta-data (permissions,
169 ownership, and modification time) separately from the file contents.
170
171 =item Backup Policy
172
173 Based on your site's requirements you need to decide what your backup
174 policy is.  BackupPC is not designed to provide exact re-imaging of
175 failed disks.  See L<Limitations|limitations> for more information.
176 However, the addition of tar transport for linux/unix clients, plus
177 full support for special file types and unix attributes in v1.4.0
178 likely means an exact image of a linux/unix file system can be made.
179
180 BackupPC saves backups onto disk. Because of pooling you can relatively
181 economically keep several weeks of old backups.
182
183 At some sites the disk-based backup will be adequate, without a
184 secondary tape backup. This system is robust to any single failure: if a
185 client disk fails or loses files, the BackupPC server can be used to
186 restore files. If the server disk fails, BackupPC can be restarted on a
187 fresh file system, and create new backups from the clients. The chance
188 of the server disk failing can be made very small by spending more money
189 on increasingly better RAID systems.  However, there is still the risk
190 of catastrophic events like fires or earthquakes that can destroy
191 both the BackupPC server and the clients it is backing up if they
192 are physically nearby.
193
194 Some sites might choose to do periodic backups to tape or cd/dvd.
195 This backup can be done perhaps weekly using the archive function of
196 BackupPC.
197
198 Other users have reported success with removable disks to rotate the
199 BackupPC data drives, or using rsync to mirror the BackupPC data pool
200 offsite.
201
202 =back
203
204 =head2 Resources
205
206 =over 4
207
208 =item BackupPC home page
209
210 The BackupPC Open Source project is hosted on SourceForge.  The
211 home page can be found at:
212
213     http://backuppc.sourceforge.net
214
215 This page has links to the current documentation, the SourceForge
216 project page and general information.
217
218 =item SourceForge project
219
220 The SourceForge project page is at:
221
222     http://sourceforge.net/projects/backuppc
223
224 This page has links to the current releases of BackupPC.
225
226 =item BackupPC FAQ
227
228 BackupPC has a FAQ at L<http://backuppc.sourceforge.net/faq>.
229
230 =item Mail lists
231
232 Three BackupPC mailing lists exist for announcements (backuppc-announce),
233 developers (backuppc-devel), and a general user list for support, asking
234 questions or any other topic relevant to BackupPC (backuppc-users).
235
236 The lists are archived on SourceForge and Gmane.  The SourceForge lists
237 are not always up to date and the searching is limited, so Gmane is
238 a good alternative.  See:
239
240     http://news.gmane.org/index.php?prefix=gmane.comp.sysutils.backup.backuppc
241     http://sourceforge.net/mailarchive/forum.php?forum_id=503
242
243 You can subscribe to these lists by visiting:
244
245     http://lists.sourceforge.net/lists/listinfo/backuppc-announce
246     http://lists.sourceforge.net/lists/listinfo/backuppc-users
247     http://lists.sourceforge.net/lists/listinfo/backuppc-devel
248
249 The backuppc-announce list is moderated and is used only for
250 important announcements (eg: new versions).  It is low traffic.
251 You only need to subscribe to one of backuppc-announce and
252 backuppc-users: backuppc-users also receives any messages on
253 backuppc-announce.
254
255 The backuppc-devel list is only for developers who are working on BackupPC.
256 Do not post questions or support requests there.  But detailed technical
257 discussions should happen on this list.
258
259 To post a message to the backuppc-users list, send an email to
260
261     backuppc-users@lists.sourceforge.net
262
263 Do not send subscription requests to this address!
264
265 =item Other Programs of Interest
266
267 If you want to mirror linux or unix files or directories to a remote server
268 you should use rsync, L<http://rsync.samba.org>.  BackupPC uses
269 rsync as a transport mechanism; if you are already an rsync user you
270 can think of BackupPC as adding efficient storage (compression and
271 pooling) and a convenient user interface to rsync.
272
273 Two popular open source packages that do tape backup are
274 Amanda (L<http://www.amanda.org>)
275 and Bacula (L<http://www.bacula.org>).
276 Amanda can also backup WinXX machines to tape using samba.
277 These packages can be used as back ends to BackupPC to backup the
278 BackupPC server data to tape.
279
280 Various programs and scripts use rsync to provide hardlinked backups.
281 See, for example, Mike Rubel's site (L<http://www.mikerubel.org/computers/rsync_snapshots>),
282 JW Schultz's dirvish (L<http://www.dirvish.org/>),
283 Ben Escoto's rdiff-backup (L<http://www.nongnu.org/rdiff-backup>),
284 and John Bowman's rlbackup (L<http://www.math.ualberta.ca/imaging/rlbackup>).
285
286 Unison is a utility that can do two-way, interactive, synchronization.
287 See L<http://freshmeat.net/projects/unison>.  An external wrapper around
288 rsync that maintains transfer data to enable two-way synchronization is
289 drsync; see L<http://freshmeat.net/projects/drsync>.
290
291 BackupPC provides many additional features, such as compressed storage,
292 hardlinking any matching files (rather than just files with the same name),
293 and storing special files without root privileges.  But these other programs
294 provide simple, effective and fast solutions and are definitely worthy of
295 consideration.
296
297 =back
298
299 =head2 Road map
300
301 The new features planned for future releases of BackupPC
302 are at L<http://backuppc.sourceforge.net/faq/roadMap.html>.
303
304 Comments and suggestions are welcome.
305
306 =head2 You can help
307
308 BackupPC is free. I work on BackupPC because I enjoy doing it and I like
309 to contribute to the open source community.
310
311 BackupPC already has more than enough features for my own needs.  The
312 main compensation for continuing to work on BackupPC is knowing that
313 more and more people find it useful.  So feedback is certainly
314 appreciated, both positive and negative.
315
316 Beyond being a satisfied user and telling other people about it, everyone
317 is encouraged to add links to L<http://backuppc.sourceforge.net>
318 (I'll see them via Google) or otherwise publicize BackupPC.  Unlike
319 the commercial products in this space, I have a zero budget (in both
320 time and money) for marketing, PR and advertising, so it's up to
321 all of you!  Feel free to vote for BackupPC at
322 L<http://freshmeat.net/projects/backuppc>.
323
324 Also, everyone is encouraged to contribute patches, bug reports, feature
325 and design suggestions, new code, FAQs, and documentation corrections or
326 improvements.  Answering questions on the mail list is a big help too.
327
328 =head1 Installing BackupPC
329
330 =head2 Requirements
331
332 BackupPC requires:
333
334 =over 4
335
336 =item *
337
338 A linux, solaris, or unix based server with a substantial amount of free
339 disk space (see the next section for what that means). The CPU and disk
340 performance on this server will determine how many simultaneous backups
341 you can run. You should be able to run 4-8 simultaneous backups on a
342 moderately configured server.
343
344 Several users have reported significantly better performance using
345 reiser compared to ext3 for the BackupPC data file system.  It is
346 also recommended you consider either an LVM or raid setup (either
347 in HW or SW; eg: 3Ware RAID5) so that you can expand the
348 file system as necessary.
349
350 When BackupPC starts with an empty pool, all the backup data will be
351 written to the pool on disk. After more backups are done, a higher
352 percentage of incoming files will already be in the pool. BackupPC is
353 able to avoid writing to disk new files that are already in the pool.
354 So over time disk writes will reduce significantly (by perhaps a factor
355 of 20 or more), since eventually 95% or more of incoming backup files
356 are typically in the pool. Disk reads from the pool are still needed to
357 do file compares to verify files are an exact match. So, with a mature
358 pool, if a relatively fast client generates data at say 1MB/sec, and you
359 run 4 simultaneous backups, there will be an average server disk load of
360 about 4MB/sec reads and 0.2MB/sec writes (assuming 95% of the incoming
361 files are in the pool). These rates will be perhaps 40% lower if
362 compression is on.
363
364 =item *
365
366 Perl version 5.6.0 or later. BackupPC has been tested with
367 version 5.6.x, and 5.8.x. If you don't have perl, please
368 see L<http://www.cpan.org>.
369
370 =item *
371
372 Perl modules Compress::Zlib, Archive::Zip and File::RsyncP.  Try "perldoc
373 Compress::Zlib" and "perldoc Archive::Zip" to see if you have these
374 modules.  If not, fetch them from L<http://www.cpan.org> and see the
375 instructions below for how to build and install them.
376
377 The File::RsyncP module is available from L<http://perlrsync.sourceforge.net>
378 or CPAN.  You'll need to install the File::RsyncP module if you want to use
379 Rsync as a transport method.
380
381 =item *
382
383 If you are using smb to backup WinXX machines you need smbclient and
384 nmblookup from the samba package.  You will also need nmblookup if
385 you are backing up linux/unix DHCP machines.  See L<http://www.samba.org>.
386 Samba versions 3.x are stable and now recommended instead of 2.x.
387
388 See L<http://www.samba.org> for source and binaries.  It's pretty easy to
389 fetch and compile samba, and just grab smbclient and nmblookup, without
390 doing the installation. Alternatively, L<http://www.samba.org> has binary
391 distributions for most platforms.
392
393 =item *
394
395 If you are using tar to backup linux/unix machines you should have version
396 1.13.7 at a minimum, with version 1.13.20 or higher recommended.  Use
397 "tar --version" to check your version.  Various GNU mirrors have the newest
398 versions of tar, see for example L<http://www.funet.fi/pub/gnu/alpha/gnu/tar>.
399 As of July 2006 the latest version is 1.15.1.
400
401 =item *
402
403 If you are using rsync to backup linux/unix machines you should have
404 version 2.6.3 or higher on each client machine.  See
405 L<http://rsync.samba.org>. Use "rsync --version" to check your version.
406
407 For BackupPC to use Rsync you will also need to install the perl
408 File::RsyncP module, which is available from
409 L<http://perlrsync.sourceforge.net>.
410 Version 0.70 or later is required.
411
412 =item *
413
414 The Apache web server, see L<http://www.apache.org>, preferably built
415 with mod_perl support.
416
417 =back
418
419 =head2 How much disk space do I need?
420
421 Here's one real example for an environment that is backing up 65 laptops
422 with compression off. Each full backup averages 3.2GB. Each incremental
423 backup averages about 0.2GB. Storing one full backup and two incremental
424 backups per laptop is around 240GB of raw data. But because of the
425 pooling of identical files, only 87GB is used.  This is without
426 compression.
427
428 Another example, with compression on: backing up 95 laptops, where
429 each backup averages 3.6GB and each incremental averages about 0.3GB.
430 Keeping three weekly full backups, and six incrementals is around
431 1200GB of raw data.  Because of pooling and compression, only 150GB
432 is needed.
433
434 Here's a rule of thumb. Add up the disk usage of all the machines you
435 want to backup (210GB in the first example above). This is a rough
436 minimum space estimate that should allow a couple of full backups and at
437 least half a dozen incremental backups per machine. If compression is on
438 you can reduce the storage requirements by maybe 30-40%.  Add some margin
439 in case you add more machines or decide to keep more old backups.
440
441 Your actual mileage will depend upon the types of clients, operating
442 systems and applications you have. The more uniform the clients and
443 applications the bigger the benefit from pooling common files.
444
445 For example, the Eudora email tool stores each mail folder in a separate
446 file, and attachments are extracted as separate files. So in the sadly
447 common case of a large attachment emailed to many recipients, Eudora
448 will extract the attachment into a new file. When these machines are
449 backed up, only one copy of the file will be stored on the server, even
450 though the file appears in many different full or incremental backups. In
451 this sense Eudora is a "friendly" application from the point of view of
452 backup storage requirements.
453
454 An example at the other end of the spectrum is Outlook. Everything
455 (email bodies, attachments, calendar, contact lists) is stored in a
456 single file, which often becomes huge. Any change to this file requires
457 a separate copy of the file to be saved during backup. Outlook is even
458 more troublesome, since it keeps this file locked all the time, so it
459 cannot be read by smbclient whenever Outlook is running.  See the
460 L<Limitations|limitations> section for more discussion of this problem.
461
462 In addition to total disk space, you shold make sure you have
463 plenty of inodes on your BackupPC data partition. Some users have
464 reported running out of inodes on their BackupPC data partition.
465 So even if you have plenty of disk space, BackupPC will report
466 failures when the inodes are exhausted.  This is a particular
467 problem with ext2/ext3 file systems that have a fixed number of
468 inodes when the file system is built.  Use "df -i" to see your
469 inode usage.
470
471 =head2 Step 1: Getting BackupPC
472
473 Some linux distributions now include BackupPC.  The Debian
474 distribution, supprted by Ludovic Drolez, can be found at
475 L<http://packages.debian.org/backuppc>; it should be included
476 in the next stable Debian release.  On Debian, BackupPC can
477 be installed with the command:
478
479     apt-get install backuppc
480
481 In the future there might be packages for Gentoo and other
482 linux flavors.  If the packaged version is older than the
483 released version then you will probably want to install the
484 latest version as described below.
485
486 Otherwise, manually fetching and installing BackupPC is easy.
487 Start by downloading the latest version from
488 L<http://backuppc.sourceforge.net>.  Hit the "Code" button,
489 then select the "backuppc" or "backuppc-beta" package and
490 download the latest version.
491
492 =head2 Step 2: Installing the distribution
493
494 First off, there are three perl modules you should install.
495 These are all optional, but highly recommended:
496
497 =over 4
498
499 =item Compress::Zlib
500
501 To enable compression, you will need to install Compress::Zlib
502 from L<http://www.cpan.org>.
503 You can run "perldoc Compress::Zlib" to see if this module is installed.
504
505 =item Archive::Zip
506
507 To support restore via Zip archives you will need to install
508 Archive::Zip, also from L<http://www.cpan.org>.
509 You can run "perldoc Archive::Zip" to see if this module is installed.
510
511 =item XML::RSS
512
513 To support the RSS feature you will need to install XML::RSS, also from
514 L<http://www.cpan.org>.  There is not need to install this module if you
515 don't plan on using RSS. You can run "perldoc XML::RSS" to see if this
516 module is installed.
517
518 =item File::RsyncP
519
520 To use rsync and rsyncd with BackupPC you will need to install File::RsyncP.
521 You can run "perldoc File::RsyncP" to see if this module is installed.
522 File::RsyncP is available from L<http://perlrsync.sourceforge.net>.
523 Version 0.52 or later is required.
524
525 =back
526
527 To build and install these packages, fetch the tar.gz file and
528 then run these commands:
529
530     tar zxvf Archive-Zip-1.16.tar.gz
531     cd Archive-Zip-1.16
532     perl Makefile.PL
533     make
534     make test
535     make install
536
537 The same sequence of commands can be used for each module.
538
539 Now let's move onto BackupPC itself.  After fetching
540 BackupPC-__VERSION__.tar.gz, run these commands as root:
541
542     tar zxf BackupPC-__VERSION__.tar.gz
543     cd BackupPC-__VERSION__
544     perl configure.pl
545
546 In the future this release might also have patches available on the
547 SourceForge site.  These patch files are text files, with a name of
548 the form
549
550     BackupPC-__VERSION__plN.diff
551
552 where N is the patch level, eg: pl2 is patch-level 2.  These
553 patch files are cumulative: you only need apply the last patch
554 file, not all the earlier patch files.  If a patch file is
555 available, eg: BackupPC-__VERSION__pl2.diff, you should apply
556 the patch after extracting the tar file:
557
558      # fetch BackupPC-__VERSION__.tar.gz
559      # fetch BackupPC-__VERSION__pl2.diff
560      tar zxf BackupPC-__VERSION__.tar.gz
561      cd BackupPC-__VERSION__
562      patch -p0 < ../BackupPC-__VERSION__pl2.diff
563      perl configure.pl
564
565 A patch file includes comments that describe that bug fixes
566 and changes.  Feel free to review it before you apply the patch.
567
568 The configure.pl script also accepts command-line options if you
569 wish to run it in a non-interactive manner.  It has self-contained
570 documentation for all the command-line options, which you can
571 read with perldoc:
572
573     perldoc configure.pl
574
575 Starting with BackupPC 3.0.0, the configure.pl script by default
576 complies with the file system hierarchy conventions.  The major
577 difference compared to earlier versions is that by default
578 configuration files will be stored in /etc/BackupPC
579 rather than below the data directory, __TOPDIR__/conf,
580 and the log files will be stored in /var/log/BackupPC.
581 rather than below the data directory, __TOPDIR__/log.
582
583 If you are upgrading from an earlier version the configure.pl script
584 will keep the configuration files and log files in their original
585 location.
586
587 When you run configure.pl you will be prompted for the full paths
588 of various executables, and you will be prompted for the following
589 information.
590
591 =over 4
592
593 =item BackupPC User
594
595 It is best if BackupPC runs as a special user, eg backuppc, that has
596 limited privileges. It is preferred that backuppc belongs to a system
597 administrator group so that sys admin members can browse backuppc files,
598 edit the configuration files and so on. Although configurable, the
599 default settings leave group read permission on pool files, so make
600 sure the BackupPC user's group is chosen restrictively.
601
602 On this installation, this is __BACKUPPCUSER__.
603
604 For security purposes you might choose to configure the BackupPC
605 user with the shell set to /bin/false.  Since you might need to
606 run some BackupPC programs as the BackupPC user for testing
607 purposes, you can use the -s option to su to explicitly run
608 a shell, eg:
609
610     su -s /bin/bash __BACKUPPCUSER__
611
612 Depending upon your configuration you might also need the -l option.
613
614 =item Data Directory
615
616 You need to decide where to put the data directory, below which
617 all the BackupPC data is stored.  This needs to be a big file system.
618
619 On this installation, this is __TOPDIR__.
620
621 =item Install Directory
622
623 You should decide where the BackupPC scripts, libraries and documentation
624 should be installed, eg: /usr/local/BackupPC.
625
626 On this installation, this is __INSTALLDIR__.
627
628 =item CGI bin Directory
629
630 You should decide where the BackupPC CGI script resides.  This will
631 usually be below Apache's cgi-bin directory.
632
633 On this installation, this is __CGIDIR__.
634
635 =item Apache image directory
636
637 A directory where BackupPC's images are stored so that Apache can
638 serve them.  This should be somewhere under Apache's DocumentRoot
639 directory.
640
641 =item Config and Log directories
642
643 In this installation the configuration and log directories are
644 located in the following locations:
645
646     __CONFDIR__/config.pl    main config file
647     __CONFDIR__/hosts        hosts file
648     __CONFDIR__/pc/HOST.pl   per-pc config file
649     __LOGDIR__/BackupPC      log files, pid, status
650
651 The configure.pl script doesn't prompt for these locations but
652 they can be set for new installations using command-line options.
653
654 =back
655
656 =head2 Step 3: Setting up config.pl
657
658 After running configure.pl, browse through the config file,
659 __CONFDIR__/config.pl, and make sure all the default settings
660 are correct. In particular, you will need to decide whether to use
661 smb, tar or rsync transport (or whether to set it on a per-PC basis)
662 and set the relevant parameters for that transport method.
663 See the section L<Client Setup|step 5: client setup> for more details.
664
665 =head2 Step 4: Setting up the hosts file
666
667 The file __CONFDIR__/hosts contains the list of clients to backup.
668 BackupPC reads this file in three cases:
669
670 =over 4
671
672 =item *
673
674 Upon startup.
675
676 =item *
677
678 When BackupPC is sent a HUP (-1) signal.  Assuming you installed the
679 init.d script, you can also do this with "/etc/init.d/backuppc reload".
680
681 =item *
682
683 When the modification time of the hosts file changes.  BackupPC
684 checks the modification time once during each regular wakeup.
685
686 =back
687
688 Whenever you change the hosts file (to add or remove a host) you can
689 either do a kill -HUP BackupPC_pid or simply wait until the next regular
690 wakeup period.
691
692 Each line in the hosts file contains three fields, separated
693 by white space:
694
695 =over 4
696
697 =item Host name
698
699 This is typically the host name or NetBios name of the client machine
700 and should be in lower case.  The host name can contain spaces (escape
701 with a backslash), but it is not recommended.
702
703 Please read the section L<How BackupPC Finds Hosts|how backuppc finds hosts>.
704
705 In certain cases you might want several distinct clients to refer
706 to the same physical machine.  For example, you might have a database
707 you want to backup, and you want to bracket the backup of the database
708 with shutdown/restart using $Conf{DumpPreUserCmd} and $Conf{DumpPostUserCmd}.
709 But you also want to backup the rest of the machine while the database
710 is still running.  In the case you can specify two different clients in
711 the host file, using any mnemonic name (eg: myhost_mysql and myhost), and
712 use $Conf{ClientNameAlias} in myhost_mysql's config.pl to specify the
713 real host name of the machine.
714
715 =item DHCP flag
716
717 Starting with v2.0.0 the way hosts are discovered has changed and now
718 in most cases you should specify 0 for the DHCP flag, even if the host
719 has a dynamically assigned IP address.
720 Please read the section L<How BackupPC Finds Hosts|how backuppc finds hosts>
721 to understand whether you need to set the DHCP flag.
722
723 You only need to set DHCP to 1 if your client machine doesn't
724 respond to the NetBios multicast request:
725
726     nmblookup myHost
727
728 but does respond to a request directed to its IP address:
729
730     nmblookup -A W.X.Y.Z
731
732 If you do set DHCP to 1 on any client you will need to specify the range of
733 DHCP addresses to search is specified in $Conf{DHCPAddressRanges}.
734
735 Note also that the $Conf{ClientNameAlias} feature does not work for
736 clients with DHCP set to 1.
737
738 =item User name
739
740 This should be the unix login/email name of the user who "owns" or uses
741 this machine. This is the user who will be sent email about this
742 machine, and this user will have permission to stop/start/browse/restore
743 backups for this host.  Leave this blank if no specific person should
744 receive email or be allowed to stop/start/browse/restore backups
745 for this host.  Administrators will still have full permissions.
746
747 =item More users
748
749 Additional user names, separate by commas and with no white space,
750 can be specified.  These users will also have full permission in
751 the CGI interface to stop/start/browse/restore backups for this host.
752 These users will not be sent email about this host.
753
754 =back
755
756 The first non-comment line of the hosts file is special: it contains
757 the names of the columns and should not be edited.
758
759 Here's a simple example of a hosts file:
760
761     host        dhcp    user      moreUsers
762     farside     0       craig     jim,dave
763     larson      1       gary      andy
764
765 =head2 Step 5: Client Setup
766
767 Three methods for getting backup data from a client are supported: smb,
768 tar and rsync.  Smb or rsync are the preferred methods for WinXX clients
769 and rsync or tar are the preferred methods for linux/unix/MacOSX clients.
770
771 The transfer method is set using the $Conf{XferMethod} configuration
772 setting. If you have a mixed environment (ie: you will use smb for some
773 clients and tar for others), you will need to pick the most common
774 choice for $Conf{XferMethod} for the main config.pl file, and then
775 override it in the per-PC config file for those hosts that will use
776 the other method.  (Or you could run two completely separate instances
777 of BackupPC, with different data directories, one for WinXX and the
778 other for linux/unix, but then common files between the different
779 machine types will duplicated.)
780
781 Here are some brief client setup notes:
782
783 =over 4
784
785 =item WinXX
786
787 One setup for WinXX clients is to set $Conf{XferMethod} to "smb".
788 Actually, rsyncd is the better method for WinXX if you are prepared to
789 run rsync/cygwin on your WinXX client.
790
791 If you want to use rsyncd for WinXX clients you can find a pre-packaged
792 zip file on L<http://backuppc.sourceforge.net>. The package is called
793 cygwin-rsync. It contains rsync.exe, template setup files and the
794 minimal set of cygwin libraries for everything to run.  The README file
795 contains instructions for running rsync as a service, so it starts
796 automatically everytime you boot your machine.  If you use rsync
797 to backup WinXX machines, be sure to set $Conf{ClientCharset}
798 correctly (eg: 'cp1252') so that the WinXX file name encoding is
799 correctly converted to utf8.
800
801 Otherwise, to use SMB, you can either create shares for the data you want
802 to backup or your can use the existing C$ share.  To create a new 
803 share, open "My Computer", right click on the drive (eg: C), and
804 select "Sharing..." (or select "Properties" and select the "Sharing"
805 tab). In this dialog box you can enable sharing, select the share name
806 and permissions.
807
808 All Windows NT based OS (NT, 2000, XP Pro), are configured by default 
809 to share the entire C drive as C$.  This is a special share used for 
810 various administration functions, one of which is to grant access to backup 
811 operators. All you need to do is create a new domain user, specifically 
812 for backup. Then add the new backup user to the built in "Backup 
813 Operators" group. You now have backup capability for any directory on 
814 any computer in the domain in one easy step. This avoids using 
815 administrator accounts and only grants permission to do exactly what you 
816 want for the given user, i.e.: backup.
817 Also, for additional security, you may wish to deny the ability for this 
818 user to logon to computers in the default domain policy.
819
820 If this machine uses DHCP you will also need to make sure the
821 NetBios name is set.  Go to Control Panel|System|Network Identification
822 (on Win2K) or Control Panel|System|Computer Name (on WinXP).
823 Also, you should go to Control Panel|Network Connections|Local Area
824 Connection|Properties|Internet Protocol (TCP/IP)|Properties|Advanced|WINS
825 and verify that NetBios is not disabled.
826
827 The relevant configuration settings are $Conf{SmbShareName},
828 $Conf{SmbShareUserName}, $Conf{SmbSharePasswd}, $Conf{SmbClientPath},
829 $Conf{SmbClientFullCmd}, $Conf{SmbClientIncrCmd} and
830 $Conf{SmbClientRestoreCmd}.
831
832 BackupPC needs to know the smb share user name and password for a
833 client machine that uses smb.  The user name is specified in
834 $Conf{SmbShareUserName}. There are four ways to tell BackupPC the
835 smb share password:
836
837 =over 4
838
839 =item *
840
841 As an environment variable BPC_SMB_PASSWD set before BackupPC starts.
842 If you start BackupPC manually the BPC_SMB_PASSWD variable must be set
843 manually first.  For backward compatibility for v1.5.0 and prior, the
844 environment variable PASSWD can be used if BPC_SMB_PASSWD is not set.
845 Warning: on some systems it is possible to see environment variables of
846 running processes.
847
848 =item *
849
850 Alternatively the BPC_SMB_PASSWD setting can be included in
851 /etc/init.d/backuppc, in which case you must make sure this file
852 is not world (other) readable.
853
854 =item *
855
856 As a configuration variable $Conf{SmbSharePasswd} in
857 __CONFDIR__/config.pl.  If you put the password
858 here you must make sure this file is not world (other) readable.
859
860 =item *
861
862 As a configuration variable $Conf{SmbSharePasswd} in the per-PC
863 configuration file (__CONFDIR__/pc/$host.pl or
864 __TOPDIR__/pc/$host/config.pl in non-FHS versions of BackupPC).
865 You will have to use this option if the smb share password is different
866 for each host. If you put the password here you must make sure this file
867 is not world (other) readable.
868
869 =back
870
871 Placement and protection of the smb share password is a possible
872 security risk, so please double-check the file and directory
873 permissions.  In a future version there might be support for
874 encryption of this password, but a private key will still have to
875 be stored in a protected place.  Suggestions are welcome.
876
877 As an alternative to setting $Conf{XferMethod} to "smb" (using
878 smbclient) for WinXX clients, you can use an smb network filesystem (eg:
879 ksmbfs or similar) on your linux/unix server to mount the share,
880 and then set $Conf{XferMethod} to "tar" (use tar on the network
881 mounted file system).
882
883 Also, to make sure that file names with special characters are correctly
884 transferred by smbclient you should make sure that the smb.conf file
885 has (for samba 3.x):
886
887     [global]
888         unix charset = UTF8
889
890 UTF8 is the default setting, so if the parameter is missing then it
891 is ok.  With this setting $Conf{ClientCharset} should be emtpy,
892 since smbclient has already converted the file names to utf8.
893
894 =item Linux/Unix
895
896 The preferred setup for linux/unix clients is to set $Conf{XferMethod}
897 to "rsync", "rsyncd" or "tar".
898
899 You can use either rsync, smb, or tar for linux/unix machines. Smb requires
900 that the Samba server (smbd) be run to provide the shares. Since the smb
901 protocol can't represent special files like symbolic links and fifos,
902 tar and rsync are the better transport methods for linux/unix machines.
903 (In fact, by default samba makes symbolic links look like the file or
904 directory that they point to, so you could get an infinite loop if a
905 symbolic link points to the current or parent directory. If you really
906 need to use Samba shares for linux/unix backups you should turn off the
907 "follow symlinks" samba config setting. See the smb.conf manual page.)
908
909 The requirements for each Xfer Method are:
910
911 =over 4
912
913 =item tar
914
915 You must have GNU tar on the client machine.  Use "tar --version"
916 or "gtar --version" to verify.  The version should be at least
917 1.13.7, and 1.13.20 or greater is recommended.  Tar is run on
918 the client machine via rsh or ssh.
919
920 The relevant configuration settings are $Conf{TarClientPath},
921 $Conf{TarShareName}, $Conf{TarClientCmd}, $Conf{TarFullArgs},
922 $Conf{TarIncrArgs}, and $Conf{TarClientRestoreCmd}.
923
924 =item rsync
925
926 You should have at least rsync 2.6.3, and the latest version is
927 recommended.  Rsync is run on the remote client via rsh or ssh.
928
929 The relevant configuration settings are $Conf{RsyncClientPath},
930 $Conf{RsyncClientCmd}, $Conf{RsyncClientRestoreCmd}, $Conf{RsyncShareName},
931 $Conf{RsyncArgs}, and $Conf{RsyncRestoreArgs}.
932
933 =item rsyncd
934
935 You should have at least rsync 2.6.3, and the latest version is
936 recommended.  In this case the rsync daemon should be running on
937 the client machine and BackupPC connects directly to it.
938
939 The relevant configuration settings are $Conf{RsyncdClientPort},
940 $Conf{RsyncdUserName}, $Conf{RsyncdPasswd}, $Conf{RsyncdAuthRequired},
941 $Conf{RsyncShareName}, $Conf{RsyncArgs}, and $Conf{RsyncRestoreArgs}.
942 $Conf{RsyncShareName} is the name of an rsync module (ie: the thing
943 in square brackets in rsyncd's conf file -- see rsyncd.conf), not a
944 file system path.
945
946 Be aware that rsyncd will remove the leading '/' from path names in
947 symbolic links if you specify "use chroot = no" in the rsynd.conf file.
948 See the rsyncd.conf manual page for more information.
949
950 =back
951
952 You need to set $Conf{ClientCharset} to the client's charset so that
953 file names are correctly converted to utf8.  Use "locale charmap"
954 on the client to see its charset.
955
956 For linux/unix machines you should not backup "/proc".  This directory
957 contains a variety of files that look like regular files but they are
958 special files that don't need to be backed up (eg: /proc/kcore is a
959 regular file that contains physical memory).  See $Conf{BackupFilesExclude}.
960 It is safe to back up /dev since it contains mostly character-special
961 and block-special files, which are correctly handed by BackupPC
962 (eg: backing up /dev/hda5 just saves the block-special file information,
963 not the contents of the disk).
964
965 Alternatively, rather than backup all the file systems as a single
966 share ("/"), it is easier to restore a single file system if you backup
967 each file system separately.  To do this you should list each file system
968 mount point in $Conf{TarShareName} or $Conf{RsyncShareName}, and add the
969 --one-file-system option to $Conf{TarClientCmd} or $Conf{RsyncArgs}.
970 In this case there is no need to exclude /proc explicitly since it looks
971 like a different file system.
972
973 Next you should decide whether to run tar over ssh, rsh or nfs. Ssh is
974 the preferred method. Rsh is not secure and therefore not recommended.
975 Nfs will work, but you need to make sure that the BackupPC user (running
976 on the server) has sufficient permissions to read all the files below
977 the nfs mount.
978
979 Ssh allows BackupPC to run as a privileged user on the client (eg:
980 root), since it needs sufficient permissions to read all the backup
981 files. Ssh is setup so that BackupPC on the server (an otherwise low
982 privileged user) can ssh as root on the client, without being prompted
983 for a password. There are two common versions of ssh: v1 and v2. Here
984 are some instructions for one way to setup ssh.  (Check which version
985 of SSH you have by typing "ssh" or "man ssh".)
986
987 =item MacOSX
988
989 In general this should be similar to Linux/Unix machines.
990 In versions 10.4 and later, the native MacOSX tar works,
991 and also supports resource forks.  xtar is another option,
992 and rsync works too (although the MacOSX-supplied rsync
993 has an extension for extended attributes that is not
994 compatible with standard rsync).
995
996 =item SSH Setup
997
998 SSH is a secure way to run tar or rsync on a backup client to extract
999 the data.  SSH provides strong authentication and encryption of
1000 the network data.
1001
1002 Note that if you run rsyncd (rsync daemon), ssh is not used.
1003 In this case, rsyncd provides its own authentication, but there
1004 is no encryption of network data.  If you want encryption of
1005 network data you can use ssh to create a tunnel, or use a
1006 program like stunnel.  If someone submits instructions I
1007
1008 Setup instructions for ssh are at
1009 L<http://backuppc.sourceforge.net/faq/ssh.html>.
1010
1011 =item Clients that use DHCP
1012
1013 If a client machine uses DHCP BackupPC needs some way to find the
1014 IP address given the host name.  One alternative is to set dhcp
1015 to 1 in the hosts file, and BackupPC will search a pool of IP
1016 addresses looking for hosts.  More efficiently, it is better to
1017 set dhcp = 0 and provide a mechanism for BackupPC to find the
1018 IP address given the host name.
1019
1020 For WinXX machines BackupPC uses the NetBios name server to determine
1021 the IP address given the host name.
1022 For unix machines you can run nmbd (the NetBios name server) from
1023 the Samba distribution so that the machine responds to a NetBios
1024 name request. See the manual page and Samba documentation for more
1025 information.
1026
1027 Alternatively, you can set $Conf{NmbLookupFindHostCmd} to any command
1028 that returns the IP address given the host name.
1029
1030 Please read the section L<How BackupPC Finds Hosts|how backuppc finds hosts>
1031 for more details.
1032
1033 =back
1034
1035 =head2 Step 6: Running BackupPC
1036
1037 The installation contains an init.d backuppc script that can be copied
1038 to /etc/init.d so that BackupPC can auto-start on boot.
1039 See init.d/README for further instructions.
1040
1041 BackupPC should be ready to start.  If you installed the init.d script,
1042 then you should be able to run BackupPC with:
1043
1044     /etc/init.d/backuppc start
1045
1046 (This script can also be invoked with "stop" to stop BackupPC and "reload"
1047 to tell BackupPC to reload config.pl and the hosts file.)
1048
1049 Otherwise, just run
1050
1051      __INSTALLDIR__/bin/BackupPC -d
1052
1053 as user __BACKUPPCUSER__.  The -d option tells BackupPC to run as a daemon
1054 (ie: it does an additional fork).
1055
1056 Any immediate errors will be printed to stderr and BackupPC will quit.
1057 Otherwise, look in __LOGDIR__/LOG and verify that BackupPC reports
1058 it has started and all is ok.
1059
1060 =head2 Step 7: Talking to BackupPC
1061
1062 You should verify that BackupPC is running by using BackupPC_serverMesg.
1063 This sends a message to BackupPC via the unix (or TCP) socket and prints
1064 the response.  Like all BackupPC programs, BackupPC_serverMesg
1065 should be run as the BackupPC user (__BACKUPPCUSER__), so you
1066 should
1067
1068     su __BACKUPPCUSER__
1069
1070 before running BackupPC_serverMesg.  If the BackupPC user is
1071 configured with /bin/false as the shell, you can use the -s
1072 option to su to explicitly run a shell, eg:
1073
1074     su -s /bin/bash __BACKUPPCUSER__
1075
1076 Depending upon your configuration you might also need
1077 the -l option.
1078
1079 You can request status information and start and stop backups using this
1080 interface. This socket interface is mainly provided for the CGI interface
1081 (and some of the BackupPC sub-programs use it too).  But right now we just
1082 want to make sure BackupPC is happy.  Each of these commands should
1083 produce some status output:
1084
1085     __INSTALLDIR__/bin/BackupPC_serverMesg status info
1086     __INSTALLDIR__/bin/BackupPC_serverMesg status jobs
1087     __INSTALLDIR__/bin/BackupPC_serverMesg status hosts
1088
1089 The output should be some hashes printed with Data::Dumper.  If it
1090 looks cryptic and confusing, and doesn't look like an error message,
1091 then all is ok.
1092
1093 The jobs status should initially show just BackupPC_trashClean.
1094 The hosts status should produce a list of every host you have listed
1095 in __CONFDIR__/hosts as part of a big cryptic output line.
1096
1097 You can also request that all hosts be queued:
1098
1099     __INSTALLDIR__/bin/BackupPC_serverMesg backup all
1100
1101 At this point you should make sure the CGI interface works since
1102 it will be much easier to see what is going on.  That's our
1103 next subject.
1104
1105 =head2 Step 8: Checking email delivery
1106
1107 The script BackupPC_sendEmail sends status and error emails to
1108 the administrator and users.  It is usually run each night
1109 by BackupPC_nightly.
1110
1111 To verify that it can run sendmail and deliver email correctly
1112 you should ask it to send a test email to you:
1113
1114     su __BACKUPPCUSER__
1115     __INSTALLDIR__/bin/BackupPC_sendEmail -u MYNAME@MYDOMAIN.COM
1116
1117 BackupPC_sendEmail also takes a -c option that checks if BackupPC
1118 is running, and it sends an email to $Conf{EMailAdminUserName}
1119 if it is not.  That can be used as a keep-alive check by adding
1120
1121     __INSTALLDIR__/bin/BackupPC_sendEmail -c
1122
1123 to __BACKUPPCUSER__'s cron.
1124
1125 The -t option to BackupPC_sendEmail causes it to print the email
1126 message instead of invoking sendmail to deliver the message.
1127
1128 =head2 Step 9: CGI interface
1129
1130 The CGI interface script, BackupPC_Admin, is a powerful and flexible
1131 way to see and control what BackupPC is doing.  It is written for an
1132 Apache server.  If you don't have Apache, see L<http://www.apache.org>.
1133
1134 There are two options for setting up the CGI interface: standard
1135 mode and using mod_perl.  Mod_perl provides much higher performance
1136 (around 15x) and is the best choice if your Apache was built with
1137 mod_perl support.  To see if your apache was built with mod_perl
1138 run this command:
1139
1140     httpd -l | egrep mod_perl
1141
1142 If this prints mod_perl.c then your Apache supports mod_perl.
1143
1144 Using mod_perl with BackupPC_Admin requires a dedicated Apache
1145 to be run as the BackupPC user (__BACKUPPCUSER__).  This is
1146 because BackupPC_Admin needs permission to access various files
1147 in BackupPC's data directories.  In contrast, the standard
1148 installation (without mod_perl) solves this problem by having
1149 BackupPC_Admin installed as setuid to the BackupPC user, so that
1150 BackupPC_Admin runs as the BackuPC user.
1151
1152 Here are some specifics for each setup:
1153
1154 =over 4
1155
1156 =item Standard Setup
1157
1158 The CGI interface should have been installed by the configure.pl script
1159 in __CGIDIR__/BackupPC_Admin.  BackupPC_Admin should have been installed
1160 as setuid to the BackupPC user (__BACKUPPCUSER__), in addition to user
1161 and group execute permission.
1162
1163 You should be very careful about permissions on BackupPC_Admin and
1164 the directory __CGIDIR__: it is important that normal users cannot
1165 directly execute or change BackupPC_Admin, otherwise they can access
1166 backup files for any PC. You might need to change the group ownership
1167 of BackupPC_Admin to a group that Apache belongs to so that Apache
1168 can execute it (don't add "other" execute permission!).
1169 The permissions should look like this:
1170
1171     ls -l __CGIDIR__/BackupPC_Admin
1172     -swxr-x---    1 __BACKUPPCUSER__   web      82406 Jun 17 22:58 __CGIDIR__/BackupPC_Admin
1173
1174 The setuid script won't work unless perl on your machine was installed
1175 with setuid emulation.  This is likely the problem if you get an error
1176 saying such as "Wrong user: my userid is 25, instead of 150", meaning
1177 the script is running as the httpd user, not the BackupPC user.
1178 This is because setuid scripts are disabled by the kernel in most
1179 flavors of unix and linux.
1180
1181 To see if your perl has setuid emulation, see if there is a program
1182 called sperl5.6.0 (or sperl5.8.2 etc, based on your perl version)
1183 in the place where perl is installed. If you can't find this program,
1184 then you have two options: rebuild and reinstall perl with the setuid
1185 emulation turned on (answer "y" to the question "Do you want to do
1186 setuid/setgid emulation?" when you run perl's configure script), or
1187 switch to the mod_perl alternative for the CGI script (which doesn't
1188 need setuid to work).
1189
1190 =item Mod_perl Setup
1191
1192 The advantage of the mod_perl setup is that no setuid script is needed,
1193 and there is a huge performance advantage.  Not only does all the perl
1194 code need to be parsed just once, the config.pl and hosts files, plus
1195 the connection to the BackupPC server are cached between requests.  The
1196 typical speedup is around 15 times.
1197
1198 To use mod_perl you need to run Apache as user __BACKUPPCUSER__.
1199 If you need to run multiple Apache's for different services then
1200 you need to create multiple top-level Apache directories, each
1201 with their own config file.  You can make copies of /etc/init.d/httpd
1202 and use the -d option to httpd to point each http to a different
1203 top-level directory.  Or you can use the -f option to explicitly
1204 point to the config file.  Multiple Apache's will run on different
1205 Ports (eg: 80 is standard, 8080 is a typical alternative port accessed
1206 via http://yourhost.com:8080).
1207
1208 Inside BackupPC's Apache http.conf file you should check the
1209 settings for ServerRoot, DocumentRoot, User, Group, and Port.  See 
1210 L<http://httpd.apache.org/docs/server-wide.html> for more details.
1211
1212 For mod_perl, BackupPC_Admin should not have setuid permission, so
1213 you should turn it off:
1214
1215     chmod u-s __CGIDIR__/BackupPC_Admin
1216
1217 To tell Apache to use mod_perl to execute BackupPC_Admin, add this
1218 to Apache's 1.x httpd.conf file:
1219
1220     <IfModule mod_perl.c>
1221         PerlModule Apache::Registry
1222         PerlTaintCheck On
1223         <Location /cgi-bin/BackupPC/BackupPC_Admin>   # <--- change path as needed
1224            SetHandler perl-script
1225            PerlHandler Apache::Registry
1226            Options ExecCGI
1227            PerlSendHeader On
1228         </Location>
1229     </IfModule>
1230
1231 Apache 2.0.44 with Perl 5.8.0 on RedHat 7.1, Don Silvia reports that
1232 this works (with tweaks from Michael Tuzi):
1233
1234     LoadModule perl_module modules/mod_perl.so
1235     PerlModule Apache2
1236
1237     <Directory /path/to/cgi/>
1238         SetHandler perl-script
1239         PerlResponseHandler ModPerl::Registry
1240         PerlOptions +ParseHeaders
1241         Options +ExecCGI
1242         Order deny,allow
1243         Deny from all
1244         Allow from 192.168.0  
1245         AuthName "Backup Admin"
1246         AuthType Basic
1247         AuthUserFile /path/to/user_file
1248         Require valid-user
1249     </Directory>
1250
1251 There are other optimizations and options with mod_perl.  For
1252 example, you can tell mod_perl to preload various perl modules,
1253 which saves memory compared to loading separate copies in every
1254 Apache process after they are forked.  See Stas's definitive
1255 mod_perl guide at L<http://perl.apache.org/guide>.
1256
1257 =back
1258
1259 BackupPC_Admin requires that users are authenticated by Apache.
1260 Specifically, it expects that Apache sets the REMOTE_USER environment
1261 variable when it runs.  There are several ways to do this.  One way
1262 is to create a .htaccess file in the cgi-bin directory that looks like:
1263
1264     AuthGroupFile /etc/httpd/conf/group    # <--- change path as needed
1265     AuthUserFile /etc/http/conf/passwd     # <--- change path as needed
1266     AuthType basic
1267     AuthName "access"
1268     require valid-user
1269
1270 You will also need "AllowOverride Indexes AuthConfig" in the Apache
1271 httpd.conf file to enable the .htaccess file. Alternatively, everything
1272 can go in the Apache httpd.conf file inside a Location directive. The
1273 list of users and password file above can be extracted from the NIS
1274 passwd file.
1275
1276 One alternative is to use LDAP.  In Apache's http.conf add these lines:
1277
1278     LoadModule auth_ldap_module   modules/auth_ldap.so
1279     AddModule auth_ldap.c
1280
1281     # cgi-bin - auth via LDAP (for BackupPC)
1282     <Location /cgi-binBackupPC/BackupPC_Admin>    # <--- change path as needed
1283       AuthType Basic
1284       AuthName "BackupPC login"
1285       # replace MYDOMAIN, PORT, ORG and CO as needed
1286       AuthLDAPURL ldap://ldap.MYDOMAIN.com:PORT/o=ORG,c=CO?uid?sub?(objectClass=*)
1287       require valid-user
1288     </Location>
1289
1290 If you want to disable the user authentication you can set
1291 $Conf{CgiAdminUsers} to '*', which allows any user to have
1292 full access to all hosts and backups.  In this case the REMOTE_USER
1293 environment variable does not have to be set by Apache.
1294
1295 Alternatively, you can force a particular user name by getting Apache
1296 to set REMOTE_USER, eg, to hardcode the user to www you could add
1297 this to Apache's httpd.conf:
1298
1299     <Location /cgi-bin/BackupPC/BackupPC_Admin>   # <--- change path as needed
1300         Setenv REMOTE_USER www
1301     </Location>
1302
1303 Finally, you should also edit the config.pl file and adjust, as necessary,
1304 the CGI-specific settings.  They're near the end of the config file. In
1305 particular, you should specify which users or groups have administrator
1306 (privileged) access: see the config settings $Conf{CgiAdminUserGroup}
1307 and $Conf{CgiAdminUsers}.  Also, the configure.pl script placed various
1308 images into $Conf{CgiImageDir} that BackupPC_Admin needs to serve
1309 up.  You should make sure that $Conf{CgiImageDirURL} is the correct
1310 URL for the image directory.
1311
1312 See the section L<Fixing installation problems|fixing installation problems> for suggestions on debugging the Apache authentication setup.
1313
1314 =head2 How BackupPC Finds Hosts
1315
1316 Starting with v2.0.0 the way hosts are discovered has changed.  In most
1317 cases you should specify 0 for the DHCP flag in the conf/hosts file,
1318 even if the host has a dynamically assigned IP address.
1319
1320 BackupPC (starting with v2.0.0) looks up hosts with DHCP = 0 in this manner:
1321
1322 =over 4
1323
1324 =item *
1325
1326 First DNS is used to lookup the IP address given the client's name
1327 using perl's gethostbyname() function.  This should succeed for machines
1328 that have fixed IP addresses that are known via DNS.  You can manually
1329 see whether a given host have a DNS entry according to perls'
1330 gethostbyname function with this command:
1331
1332     perl -e 'print(gethostbyname("myhost") ? "ok\n" : "not found\n");'
1333
1334 =item *
1335
1336 If gethostbyname() fails, BackupPC then attempts a NetBios multicast to
1337 find the host.  Provided your client machine is configured properly,
1338 it should respond to this NetBios multicast request.  Specifically,
1339 BackupPC runs a command of this form:
1340
1341     nmblookup myhost
1342
1343 If this fails you will see output like:
1344
1345     querying myhost on 10.10.255.255
1346     name_query failed to find name myhost
1347
1348 If this success you will see output like:
1349
1350     querying myhost on 10.10.255.255
1351     10.10.1.73 myhost<00>
1352
1353 Depending on your netmask you might need to specify the -B option to
1354 nmblookup.  For example:
1355
1356     nmblookup -B 10.10.1.255 myhost
1357
1358 If necessary, experiment on the nmblookup command that will return the
1359 IP address of the client given its name.  Then update
1360 $Conf{NmbLookupFindHostCmd} with any necessary options to nmblookup.
1361
1362 =back
1363
1364 For hosts that have the DHCP flag set to 1, these machines are
1365 discovered as follows:
1366
1367 =over 4
1368
1369 =item *
1370
1371 A DHCP address pool ($Conf{DHCPAddressRanges}) needs to be specified.
1372 BackupPC will check the NetBIOS name of each machine in the range using
1373 a command of the form:
1374
1375     nmblookup -A W.X.Y.Z
1376
1377 where W.X.Y.Z is each candidate address from $Conf{DHCPAddressRanges}.
1378 Any host that has a valid NetBIOS name returned by this command (ie:
1379 matching an entry in the hosts file) will be backed up.  You can
1380 modify the specific nmblookup command if necessary via $Conf{NmbLookupCmd}.
1381
1382 =item *
1383
1384 You only need to use this DHCP feature if your client machine doesn't
1385 respond to the NetBios multicast request:
1386
1387     nmblookup myHost
1388
1389 but does respond to a request directed to its IP address:
1390
1391     nmblookup -A W.X.Y.Z
1392
1393 =back
1394
1395 =head2 Other installation topics
1396
1397 =over 4
1398
1399 =item Removing a client
1400
1401 If there is a machine that no longer needs to be backed up (eg: a retired
1402 machine) you have two choices.  First, you can keep the backups accessible
1403 and browsable, but disable all new backups.  Alternatively, you can
1404 completely remove the client and all its backups.
1405
1406 To disable backups for a client there are two special values for
1407 $Conf{FullPeriod} in that client's per-PC config.pl file:
1408
1409 =over 4
1410
1411 =item -1
1412
1413 Don't do any regular backups on this machine.  Manually
1414 requested backups (via the CGI interface) will still occur.
1415
1416 =item -2
1417
1418 Don't do any backups on this machine.  Manually requested
1419 backups (via the CGI interface) will be ignored.
1420
1421 =back
1422
1423 This will still allow that client's old backups to be browsable
1424 and restorable.
1425
1426 To completely remove a client and all its backups, you should remove its
1427 entry in the conf/hosts file, and then delete the __TOPDIR__/pc/$host
1428 directory.  Whenever you change the hosts file, you should send
1429 BackupPC a HUP (-1) signal so that it re-reads the hosts file.
1430 If you don't do this, BackupPC will automatically re-read the
1431 hosts file at the next regular wakeup.
1432
1433 Note that when you remove a client's backups you won't initially recover
1434 a lot of disk space.  That's because the client's files are still in
1435 the pool.  Overnight, when BackupPC_nightly next runs, all the unused
1436 pool files will be deleted and this will recover the disk space used
1437 by the client's backups.
1438
1439 =item Copying the pool
1440
1441 If the pool disk requirements grow you might need to copy the entire
1442 data directory to a new (bigger) file system.  Hopefully you are lucky
1443 enough to avoid this by having the data directory on a RAID file system
1444 or LVM that allows the capacity to be grown in place by adding disks.
1445
1446 The backup data directories contain large numbers of hardlinks.  If
1447 you try to copy the pool the target directory will occupy a lot more
1448 space if the hardlinks aren't re-established.
1449
1450 The best way to copy a pool file system, if possible, is by copying
1451 the raw device at the block level (eg: using dd).  Application level
1452 programs that understand hardlinks include the GNU cp program with
1453 the -a option and rsync -H.  However, the large number of hardlinks
1454 in the pool will make the memory usage large and the copy very slow.
1455 Don't forget to stop BackupPC while the copy runs.
1456
1457 =back
1458
1459 =head2 Fixing installation problems
1460
1461 Please see the FAQ at L<http://backuppc.sourceforge.net/faq> for
1462 debugging suggestions.
1463
1464 =head1 Restore functions
1465
1466 BackupPC supports several different methods for restoring files. The
1467 most convenient restore options are provided via the CGI interface.
1468 Alternatively, backup files can be restored using manual commands.
1469
1470 =head2 CGI restore options
1471
1472 By selecting a host in the CGI interface, a list of all the backups
1473 for that machine will be displayed.  By selecting the backup number
1474 you can navigate the shares and directory tree for that backup.
1475
1476 BackupPC's CGI interface automatically fills incremental backups
1477 with the corresponding full backup, which means each backup has
1478 a filled appearance.  Therefore, there is no need to do multiple
1479 restores from the incremental and full backups: BackupPC does all
1480 the hard work for you.  You simply select the files and directories
1481 you want from the correct backup vintage in one step.
1482
1483 You can download a single backup file at any time simply by selecting
1484 it.  Your browser should prompt you with the file name and ask you
1485 whether to open the file or save it to disk.
1486
1487 Alternatively, you can select one or more files or directories in
1488 the currently selected directory and select "Restore selected files".
1489 (If you need to restore selected files and directories from several
1490 different parent directories you will need to do that in multiple
1491 steps.)
1492
1493 If you select all the files in a directory, BackupPC will replace
1494 the list of files with the parent directory.  You will be presented
1495 with a screen that has three options:
1496
1497 =over 4
1498
1499 =item Option 1: Direct Restore
1500
1501 With this option the selected files and directories are restored
1502 directly back onto the host, by default in their original location.
1503 Any old files with the same name will be overwritten, so use caution.
1504 You can optionally change the target host name, target share name,
1505 and target path prefix for the restore, allowing you to restore the
1506 files to a different location.
1507
1508 Once you select "Start Restore" you will be prompted one last time
1509 with a summary of the exact source and target files and directories
1510 before you commit.  When you give the final go ahead the restore
1511 operation will be queued like a normal backup job, meaning that it
1512 will be deferred if there is a backup currently running for that host.
1513 When the restore job is run, smbclient, tar, rsync or rsyncd is used
1514 (depending upon $Conf{XferMethod}) to actually restore the files.
1515 Sorry, there is currently no option to cancel a restore that has been
1516 started.
1517
1518 A record of the restore request, including the result and list of
1519 files and directories, is kept.  It can be browsed from the host's
1520 home page.  $Conf{RestoreInfoKeepCnt} specifies how many old restore
1521 status files to keep.
1522
1523 Note that for direct restore to work, the $Conf{XferMethod} must
1524 be able to write to the client.  For example, that means an SMB
1525 share for smbclient needs to be writable, and the rsyncd module
1526 needs "read only" set to "false".  This creates additional security
1527 risks.  If you only create read-only SMB shares (which is a good
1528 idea), then the direct restore will fail.  You can disable the
1529 direct restore option by setting $Conf{SmbClientRestoreCmd},
1530 $Conf{TarClientRestoreCmd} and $Conf{RsyncRestoreArgs} to undef.
1531
1532 =item Option 2: Download Zip archive
1533
1534 With this option a zip file containing the selected files and directories
1535 is downloaded.  The zip file can then be unpacked or individual files
1536 extracted as necessary on the host machine. The compression level can be
1537 specified.  A value of 0 turns off compression.
1538
1539 When you select "Download Zip File" you should be prompted where to
1540 save the restore.zip file.
1541
1542 BackupPC does not consider downloading a zip file as an actual
1543 restore operation, so the details are not saved for later browsing
1544 as in the first case.  However, a mention that a zip file was
1545 downloaded by a particular user, and a list of the files, does
1546 appear in BackupPC's log file.
1547
1548 =item Option 3: Download Tar archive
1549
1550 This is identical to the previous option, except a tar file is downloaded
1551 rather than a zip file (and there is currently no compression option).
1552
1553 =back
1554
1555 =head2 Command-line restore options
1556
1557 Apart from the CGI interface, BackupPC allows you to restore files
1558 and directories from the command line.  The following programs can
1559 be used:
1560
1561 =over 4
1562
1563 =item BackupPC_zcat
1564
1565 For each file name argument it inflates (uncompresses) the file and
1566 writes it to stdout.  To use BackupPC_zcat you could give it the
1567 full file name, eg:
1568
1569     __INSTALLDIR__/bin/BackupPC_zcat __TOPDIR__/pc/host/5/fc/fcraig/fexample.txt > example.txt
1570
1571 It's your responsibility to make sure the file is really compressed:
1572 BackupPC_zcat doesn't check which backup the requested file is from.
1573 BackupPC_zcat returns a non-zero status if it fails to uncompress
1574 a file.
1575
1576 =item BackupPC_tarCreate
1577
1578 BackupPC_tarCreate creates a tar file for any files or directories in
1579 a particular backup.  Merging of incrementals is done automatically,
1580 so you don't need to worry about whether certain files appear in the
1581 incremental or full backup.
1582
1583 The usage is:
1584
1585    BackupPC_tarCreate [-t] [-h host] [-n dumpNum] [-s shareName]
1586                     [-r pathRemove] [-p pathAdd] [-b BLOCKS] [-w writeBufSz]
1587                     files/directories...
1588
1589 The command-line files and directories are relative to the specified
1590 shareName.  The tar file is written to stdout.
1591
1592 The required options are:
1593
1594 =over 4
1595
1596 =item -h host
1597
1598 host from which the tar archive is created
1599
1600 =item -n dumpNum
1601
1602 dump number from which the tar archive is created
1603
1604 =item -s shareName
1605
1606 share name from which the tar archive is created
1607
1608 =back
1609
1610 Other options are:
1611
1612 =over 4
1613
1614 =item -t
1615
1616 print summary totals
1617
1618 =item -r pathRemove
1619
1620 path prefix that will be replaced with pathAdd
1621
1622 =item -p pathAdd
1623
1624 new path prefix
1625
1626 =item -b BLOCKS
1627
1628 the tar block size, default is 20, meaning tar writes data in 20 * 512
1629 bytes chunks.
1630
1631 =item -w writeBufSz
1632
1633 write buffer size, default 1048576 (1MB).  You can increase this if
1634 you are trying to stream to a fast tape device.
1635
1636 =back
1637
1638 The -h, -n and -s options specify which dump is used to generate
1639 the tar archive.  The -r and -p options can be used to relocate
1640 the paths in the tar archive so extracted files can be placed
1641 in a location different from their original location.
1642
1643 =item BackupPC_zipCreate
1644
1645 BackupPC_zipCreate creates a zip file for any files or directories in
1646 a particular backup.  Merging of incrementals is done automatically,
1647 so you don't need to worry about whether certain files appear in the
1648 incremental or full backup.
1649
1650 The usage is:
1651
1652    BackupPC_zipCreate [-t] [-h host] [-n dumpNum] [-s shareName]
1653                     [-r pathRemove] [-p pathAdd] [-c compressionLevel]
1654                    files/directories...
1655
1656 The command-line files and directories are relative to the specified
1657 shareName.  The zip file is written to stdout.
1658
1659 The required options are:
1660
1661 =over 4
1662
1663 =item -h host
1664
1665 host from which the zip archive is created
1666
1667 =item -n dumpNum
1668
1669 dump number from which the zip archive is created
1670
1671 =item -s shareName
1672
1673 share name from which the zip archive is created
1674
1675 =back
1676
1677 Other options are:
1678
1679 =over 4
1680
1681 =item -t
1682
1683 print summary totals
1684
1685 =item -r pathRemove
1686
1687 path prefix that will be replaced with pathAdd
1688
1689 =item -p pathAdd
1690
1691 new path prefix
1692
1693 =item -c level
1694
1695 compression level (default is 0, no compression)
1696
1697 =back
1698
1699 The -h, -n and -s options specify which dump is used to generate
1700 the zip archive.  The -r and -p options can be used to relocate
1701 the paths in the zip archive so extracted files can be placed
1702 in a location different from their original location.
1703
1704 =back
1705
1706 Each of these programs reside in __INSTALLDIR__/bin.
1707
1708 =head1 Archive functions
1709
1710 BackupPC supports archiving to removable media. For users that require
1711 offsite backups, BackupPC can create archives that stream to tape
1712 devices, or create files of specified sizes to fit onto cd or dvd media.
1713
1714 Each archive type is specified by a BackupPC host with its XferMethod
1715 set to 'archive'. This allows for multiple configurations at sites where
1716 there might be a combination of tape and cd/dvd backups being made.
1717
1718 BackupPC provides a menu that allows one or more hosts to be archived.
1719 The most recent backup of each host is archived using BackupPC_tarCreate,
1720 and the output is optionally compressed and split into fixed-sized
1721 files (eg: 650MB).
1722
1723 The archive for each host is done by default using
1724 __INSTALLDIR__/BackupPC_archiveHost.  This script can be copied
1725 and customized as needed.
1726
1727 =head2 Configuring an Archive Host
1728
1729 To create an Archive Host, add it to the hosts file just as any other host
1730 and call it a name that best describes the type of archive, e.g. ArchiveDLT
1731
1732 To tell BackupPC that the Host is for Archives, create a config.pl file in 
1733 the Archive Hosts's pc directory, adding the following line:
1734
1735 $Conf{XferMethod} = 'archive';
1736
1737 To further customise the archive's parameters you can adding the changed
1738 parameters in the host's config.pl file. The parameters are explained in
1739 the config.pl file.  Parameters may be fixed or the user can be allowed 
1740 to change them (eg: output device).
1741
1742 The per-host archive command is $Conf{ArchiveClientCmd}.  By default
1743 this invokes
1744
1745      __INSTALLDIR__/BackupPC_archiveHost
1746
1747 which you can copy and customize as necessary.
1748
1749 =head2 Starting an Archive
1750
1751 In the web interface, click on the Archive Host you wish to use. You will see a
1752 list of previous archives and a summary on each. By clicking the "Start Archive"
1753 button you are presented with the list of hosts and the approximate backup size
1754 (note this is raw size, not projected compressed size) Select the hosts you wish
1755 to archive and press the "Archive Selected Hosts" button.
1756
1757 The next screen allows you to adjust the parameters for this archive run.
1758 Press the "Start the Archive" to start archiving the selected hosts with the
1759 parameters displayed.
1760
1761 =head1 Other CGI Functions
1762
1763 =head2 Configuration and Host Editor
1764
1765 The CGI interface has a complete configuration and host editor.
1766 Only the administrator can edit the main configuration settings
1767 and hosts.  The edit links are in the left navigation bar.
1768
1769 When changes are made to any parameter a "Save" button appears
1770 at the top of the page.  If you are editing a text box you will
1771 need to click outside of the text box to make the Save button
1772 appear.  If you don't select Save then the changes won't be saved.
1773
1774 The host-specific configuration can be edited from the host
1775 summary page using the link in the left navigation bar.
1776 The administrator can edit any of the host-specific
1777 configuration settings.
1778
1779 When editing the host-specific configuration, each parameter has
1780 an "override" setting that denotes the value is host-specific,
1781 meaning that it overrides the setting in the main configuration.
1782 If you unselect "override" then the setting is removed from
1783 the host-specific configuration, and the main configuration
1784 file is displayed.
1785
1786 User's can edit their host-specific configuration if enabled
1787 via $Conf{CgiUserConfigEditEnable}.  The specific subset
1788 of configuration settings that a user can edit is specified
1789 with $Conf{CgiUserConfigEdit}.  It is recommended to make this
1790 list short as possible (you probably don't want your users saving
1791 dozens of backups) and it is essential that they can't edit any
1792 of the Cmd configuration settings, otherwise they can specify
1793 an arbitrary command that will be executed as the BackupPC
1794 user.
1795
1796 =head2 RSS
1797
1798 BackupPC supports a very basic RSS feed.  Provided you have the
1799 XML::RSS perl module installed, a URL simular to this will
1800 provide RSS information:
1801
1802     http://localhost/cgi-bin/BackupPC/BackupPC_Admin?action=rss
1803
1804 This feature is experimental.  The information included will
1805 probably change.
1806
1807 =head1 BackupPC Design
1808
1809 =head2 Some design issues
1810
1811 =over 4
1812
1813 =item Pooling common files
1814
1815 To quickly see if a file is already in the pool, an MD5 digest of the
1816 file length and contents is used as the file name in the pool. This
1817 can't guarantee a file is identical: it just reduces the search to
1818 often a single file or handful of files. A complete file comparison
1819 is always done to verify if two files are really the same.
1820
1821 Identical files on multiples backups are represented by hard links.
1822 Hardlinks are used so that identical files all refer to the same
1823 physical file on the server's disk. Also, hard links maintain
1824 reference counts so that BackupPC knows when to delete unused files
1825 from the pool.
1826
1827 For the computer-science majors among you, you can think of the pooling
1828 system used by BackupPC as just a chained hash table stored on a (big)
1829 file system.
1830
1831 =item The hashing function
1832
1833 There is a tradeoff between how much of file is used for the MD5 digest
1834 and the time taken comparing all the files that have the same hash.
1835
1836 Using the file length and just the first 4096 bytes of the file for the
1837 MD5 digest produces some repetitions.  One example: with 900,000 unique
1838 files in the pool, this hash gives about 7,000 repeated files, and in
1839 the worst case 500 files have the same hash.  That's not bad: we only
1840 have to do a single file compare 99.2% of the time.  But in the worst
1841 case we have to compare as many as 500 files checking for a match.
1842
1843 With a modest increase in CPU time, if we use the file length and the
1844 first 256K of the file we now only have 500 repeated files and in the
1845 worst case around 20 files have the same hash. Furthermore, if we
1846 instead use the first and last 128K of the file (more specifically, the
1847 first and eighth 128K chunks for files larger than 1MB) we get only 300
1848 repeated files and in the worst case around 20 files have the same hash.
1849
1850 Based on this experimentation, this is the hash function used by BackupPC.
1851 It is important that you don't change the hash function after files
1852 are already in the pool.  Otherwise your pool will grow to twice the
1853 size until all the old backups (and all the old files with old hashes)
1854 eventually expire.
1855
1856 =item Compression
1857
1858 BackupPC supports compression. It uses the deflate and inflate methods
1859 in the Compress::Zlib module, which is based on the zlib compression
1860 library (see L<http://www.gzip.org/zlib/>).
1861
1862 The $Conf{CompressLevel} setting specifies the compression level to use.
1863 Zero (0) means no compression. Compression levels can be from 1 (least
1864 cpu time, slightly worse compression) to 9 (most cpu time, slightly
1865 better compression). The recommended value is 3. Changing it to 5, for
1866 example, will take maybe 20% more cpu time and will get another 2-3%
1867 additional compression. Diminishing returns set in above 5.  See the zlib
1868 documentation for more information about compression levels.
1869
1870 BackupPC implements compression with minimal CPU load. Rather than
1871 compressing every incoming backup file and then trying to match it
1872 against the pool, BackupPC computes the MD5 digest based on the
1873 uncompressed file, and matches against the candidate pool files by
1874 comparing each uncompressed pool file against the incoming backup file.
1875 Since inflating a file takes roughly a factor of 10 less CPU time than
1876 deflating there is a big saving in CPU time.
1877
1878 The combination of pooling common files and compression can yield
1879 a factor of 8 or more overall saving in backup storage.
1880
1881 =back
1882
1883 =head2 BackupPC operation
1884
1885 BackupPC reads the configuration information from
1886 __CONFDIR__/config.pl. It then runs and manages all the backup
1887 activity. It maintains queues of pending backup requests, user backup
1888 requests and administrative commands. Based on the configuration various
1889 requests will be executed simultaneously.
1890
1891 As specified by $Conf{WakeupSchedule}, BackupPC wakes up periodically
1892 to queue backups on all the PCs.  This is a four step process:
1893
1894 =over 4
1895
1896 =item 1
1897
1898 For each host and DHCP address backup requests are queued on the
1899 background command queue.
1900
1901 =item 2
1902
1903 For each PC, BackupPC_dump is forked. Several of these may be run in
1904 parallel, based on the configuration. First a ping is done to see if
1905 the machine is alive. If this is a DHCP address, nmblookup is run to
1906 get the netbios name, which is used as the host name. If DNS lookup
1907 fails, $Conf{NmbLookupFindHostCmd} is run to find the IP address from
1908 the host name.  The file __TOPDIR__/pc/$host/backups is read to decide
1909 whether a full or incremental backup needs to be run. If no backup is
1910 scheduled, or the ping to $host fails, then BackupPC_dump exits.
1911
1912 The backup is done using the specified XferMethod.  Either samba's smbclient
1913 or tar over ssh/rsh/nfs piped into BackupPC_tarExtract, or rsync over ssh/rsh
1914 is run, or rsyncd is connected to, with the incoming data
1915 extracted to __TOPDIR__/pc/$host/new.  The XferMethod output is put
1916 into __TOPDIR__/pc/$host/XferLOG.
1917
1918 The letter in the XferLOG file shows the type of object, similar to the
1919 first letter of the modes displayed by ls -l:
1920
1921     d -> directory
1922     l -> symbolic link
1923     b -> block special file
1924     c -> character special file
1925     p -> pipe file (fifo)
1926     nothing -> regular file
1927
1928 The words mean:
1929
1930 =over 4
1931
1932 =item create
1933
1934 new for this backup (ie: directory or file not in pool)
1935
1936 =item pool
1937
1938 found a match in the pool
1939
1940 =item same
1941
1942 file is identical to previous backup (contents were
1943 checksummed and verified during full dump).
1944
1945 =item skip
1946
1947 file skipped in incremental because attributes are the
1948 same (only displayed if $Conf{XferLogLevel} >= 2).
1949
1950 =back
1951
1952 As BackupPC_tarExtract extracts the files from smbclient or tar, or as
1953 rsync runs, it checks each file in the backup to see if it is identical
1954 to an existing file from any previous backup of any PC. It does this
1955 without needed to write the file to disk. If the file matches an
1956 existing file, a hardlink is created to the existing file in the pool.
1957 If the file does not match any existing files, the file is written to
1958 disk and the file name is saved in __TOPDIR__/pc/$host/NewFileList for
1959 later processing by BackupPC_link.  BackupPC_tarExtract and rsync can handle
1960 arbitrarily large files and multiple candidate matching files without
1961 needing to write the file to disk in the case of a match.  This
1962 significantly reduces disk writes (and also reads, since the pool file
1963 comparison is done disk to memory, rather than disk to disk).
1964
1965 Based on the configuration settings, BackupPC_dump checks each
1966 old backup to see if any should be removed.  Any expired backups
1967 are moved to __TOPDIR__/trash for later removal by BackupPC_trashClean.
1968
1969 =item 3
1970
1971 For each complete, good, backup, BackupPC_link is run.
1972 To avoid race conditions as new files are linked into the
1973 pool area, only a single BackupPC_link program runs
1974 at a time and the rest are queued.
1975
1976 BackupPC_link reads the NewFileList written by BackupPC_dump and
1977 inspects each new file in the backup. It re-checks if there is a
1978 matching file in the pool (another BackupPC_link
1979 could have added the file since BackupPC_dump checked). If so, the file
1980 is removed and replaced by a hard link to the existing file. If the file
1981 is new, a hard link to the file is made in the pool area, so that this
1982 file is available for checking against each new file and new backup.
1983
1984 Then, if $Conf{IncrFill} is set (note that the default setting is
1985 off), for each incremental backup, hard links are made in the new
1986 backup to all files that were not extracted during the incremental
1987 backups.  The means the incremental backup looks like a complete
1988 image of the PC (with the exception that files that were removed on
1989 the PC since the last full backup will still appear in the backup
1990 directory tree).
1991
1992 The CGI interface knows how to merge unfilled incremental backups will
1993 the most recent prior filled (full) backup, giving the incremental
1994 backups a filled appearance.  The default for $Conf{IncrFill} is off,
1995 since there is no need to fill incremental backups.  This saves
1996 some level of disk activity, since lots of extra hardlinks are no
1997 longer needed (and don't have to be deleted when the backup expires).
1998
1999 =item 4
2000
2001 BackupPC_trashClean is always run in the background to remove any
2002 expired backups. Every 5 minutes it wakes up and removes all the files
2003 in __TOPDIR__/trash.
2004
2005 Also, once each night, BackupPC_nightly is run to complete some
2006 additional administrative tasks, such as cleaning the pool.  This
2007 involves removing any files in the pool that only have a single
2008 hard link (meaning no backups are using that file).  Again, to
2009 avoid race conditions, BackupPC_nightly is only run when there
2010 are no BackupPC_link processes running.  When BackupPC_nightly is
2011 run no new BackupPC_link jobs are started.  If BackupPC_nightly
2012 takes too long to run, the settings $Conf{MaxBackupPCNightlyJobs}
2013 and $Conf{BackupPCNightlyPeriod} can be used to run several
2014 BackupPC_nightly processes in parallel, and to split its job over
2015 several nights.
2016
2017 =back
2018
2019 BackupPC also listens for TCP connections on $Conf{ServerPort}, which
2020 is used by the CGI script BackupPC_Admin for status reporting and
2021 user-initiated backup or backup cancel requests.
2022
2023 =head2 Storage layout
2024
2025 BackupPC resides in several directories:
2026
2027 =over 4
2028
2029 =item __INSTALLDIR__
2030
2031 Perl scripts comprising BackupPC reside in __INSTALLDIR__/bin,
2032 libraries are in __INSTALLDIR__/lib and documentation
2033 is in __INSTALLDIR__/doc.
2034
2035 =item __CGIDIR__
2036
2037 The CGI script BackupPC_Admin resides in this cgi binary directory.
2038
2039 =item __CONFDIR__
2040
2041 All the configuration information resides below __CONFDIR__.
2042 This directory contains:
2043
2044 The directory __CONFDIR__ contains:
2045
2046 =over 4
2047
2048 =item config.pl
2049
2050 Configuration file. See L<Configuration file|configuration file>
2051 below for more details.
2052
2053 =item hosts
2054
2055 Hosts file, which lists all the PCs to backup.
2056
2057 =item pc
2058
2059 The directory __CONFDIR__/pc contains per-client configuration files
2060 that override settings in the main configuration file.  Each file
2061 is named __CONFDIR__/pc/HOST.pl, where HOST is the host name.
2062
2063 In pre-FHS versions of BackupPC these files were located in
2064 __TOPDIR__/pc/HOST/config.pl.
2065
2066 =back
2067
2068 =item __LOGDIR__
2069
2070 The directory __LOGDIR__ (__TOPDIR__/log on pre-FHS versions
2071 of BackupPC) contains:
2072
2073 =over 4
2074
2075 =item LOG
2076
2077 Current (today's) log file output from BackupPC.
2078
2079 =item LOG.0 or LOG.0.z
2080
2081 Yesterday's log file output.  Log files are aged daily and compressed
2082 (if compression is enabled), and old LOG files are deleted.
2083
2084 =item BackupPC.pid
2085
2086 Contains BackupPC's process id.
2087
2088 =item status.pl
2089
2090 A summary of BackupPC's status written periodically by BackupPC so
2091 that certain state information can be maintained if BackupPC is
2092 restarted.  Should not be edited.
2093
2094 =item UserEmailInfo.pl
2095
2096 A summary of what email was last sent to each user, and when the
2097 last email was sent.  Should not be edited.
2098
2099 =back
2100
2101 =item __TOPDIR__
2102
2103 All of BackupPC's data (PC backup images, logs, configuration information)
2104 is stored below this directory.
2105
2106 =back
2107
2108 Below __TOPDIR__ are several directories:
2109
2110 =over 4
2111
2112 =item __TOPDIR__/trash
2113
2114 Any directories and files below this directory are periodically deleted
2115 whenever BackupPC_trashClean checks. When a backup is aborted or when an
2116 old backup expires, BackupPC_dump simply moves the directory to
2117 __TOPDIR__/trash for later removal by BackupPC_trashClean.
2118
2119 =item __TOPDIR__/pool
2120
2121 All uncompressed files from PC backups are stored below __TOPDIR__/pool.
2122 Each file's name is based on the MD5 hex digest of the file contents.
2123 Specifically, for files less than 256K, the file length and the entire
2124 file is used. For files up to 1MB, the file length and the first and
2125 last 128K are used. Finally, for files longer than 1MB, the file length,
2126 and the first and eighth 128K chunks for the file are used.
2127
2128 Each file is stored in a subdirectory X/Y/Z, where X, Y, Z are the
2129 first 3 hex digits of the MD5 digest.
2130
2131 For example, if a file has an MD5 digest of 123456789abcdef0,
2132 the file is stored in __TOPDIR__/pool/1/2/3/123456789abcdef0.
2133
2134 The MD5 digest might not be unique (especially since not all the file's
2135 contents are used for files bigger than 256K). Different files that have
2136 the same MD5 digest are stored with a trailing suffix "_n" where n is
2137 an incrementing number starting at 0. So, for example, if two additional
2138 files were identical to the first, except the last byte was different,
2139 and assuming the file was larger than 1MB (so the MD5 digests are the
2140 same but the files are actually different), the three files would be
2141 stored as:
2142
2143         __TOPDIR__/pool/1/2/3/123456789abcdef0
2144         __TOPDIR__/pool/1/2/3/123456789abcdef0_0
2145         __TOPDIR__/pool/1/2/3/123456789abcdef0_1
2146
2147 Both BackupPC_dump (actually, BackupPC_tarExtract) and BackupPC_link are
2148 responsible for checking newly backed up files against the pool. For
2149 each file, the MD5 digest is used to generate a file name in the pool
2150 directory. If the file exists in the pool, the contents are compared.
2151 If there is no match, additional files ending in "_n" are checked.
2152 (Actually, BackupPC_tarExtract compares multiple candidate files in
2153 parallel.)  If the file contents exactly match, the file is created by
2154 simply making a hard link to the pool file (this is done by
2155 BackupPC_tarExtract as the backup proceeds). Otherwise,
2156 BackupPC_tarExtract writes the new file to disk and a new hard link is
2157 made in the pool to the file (this is done later by BackupPC_link).
2158
2159 Therefore, every file in the pool will have at least 2 hard links
2160 (one for the pool file and one for the backup file below __TOPDIR__/pc).
2161 Identical files from different backups or PCs will all be linked to
2162 the same file.  When old backups are deleted, some files in the pool
2163 might only have one link.  BackupPC_nightly checks the entire pool
2164 and removes all files that have only a single link, thereby recovering
2165 the storage for that file.
2166
2167 One other issue: zero length files are not pooled, since there are a lot
2168 of these files and on most file systems it doesn't save any disk space
2169 to turn these files into hard links.
2170
2171 =item __TOPDIR__/cpool
2172
2173 All compressed files from PC backups are stored below __TOPDIR__/cpool.
2174 Its layout is the same as __TOPDIR__/pool, and the hashing function
2175 is the same (and, importantly, based on the uncompressed file, not
2176 the compressed file).
2177
2178 =item __TOPDIR__/pc/$host
2179
2180 For each PC $host, all the backups for that PC are stored below
2181 the directory __TOPDIR__/pc/$host.  This directory contains the
2182 following files:
2183
2184 =over 4
2185
2186 =item LOG
2187
2188 Current log file for this PC from BackupPC_dump.
2189
2190 =item LOG.DDMMYYYY or LOG.DDMMYYYY.z
2191
2192 Last month's log file.  Log files are aged monthly and compressed
2193 (if compression is enabled), and old LOG files are deleted.
2194 In earlier versions of BackupPC these files used to have
2195 a suffix of 0, 1, ....
2196
2197 =item XferERR or XferERR.z
2198
2199 Output from the transport program (ie: smbclient, tar or rsync)
2200 for the most recent failed backup.
2201
2202 =item new
2203
2204 Subdirectory in which the current backup is stored.  This
2205 directory is renamed if the backup succeeds.
2206
2207 =item XferLOG or XferLOG.z
2208
2209 Output from the transport program (ie: smbclient, tar or rsync)
2210 for the current backup.
2211
2212 =item nnn (an integer)
2213
2214 Successful backups are in directories numbered sequentially starting at 0.
2215
2216 =item XferLOG.nnn or XferLOG.nnn.z
2217
2218 Output from the transport program (ie: smbclient, tar or rsync)
2219 corresponding to backup number nnn.
2220
2221 =item RestoreInfo.nnn
2222
2223 Information about restore request #nnn including who, what, when, and
2224 why. This file is in Data::Dumper format.  (Note that the restore
2225 numbers are not related to the backup number.)
2226
2227 =item RestoreLOG.nnn.z
2228
2229 Output from smbclient, tar or rsync during restore #nnn.  (Note that the restore
2230 numbers are not related to the backup number.)
2231
2232 =item ArchiveInfo.nnn
2233
2234 Information about archive request #nnn including who, what, when, and
2235 why. This file is in Data::Dumper format.  (Note that the archive
2236 numbers are not related to the restore or backup number.)
2237
2238 =item ArchiveLOG.nnn.z
2239
2240 Output from archive #nnn.  (Note that the archive numbers are not related
2241 to the backup or restore number.)
2242
2243 =item config.pl
2244
2245 Old location of optional configuration settings specific to this host.
2246 Settings in this file override the main configuration file.
2247 In new versions of BackupPC the per-host configuration files are
2248 stored in __CONFDIR__/pc/HOST.pl.
2249
2250 =item backups
2251
2252 A tab-delimited ascii table listing information about each successful
2253 backup, one per row.  The columns are:
2254
2255 =over 4
2256
2257 =item num
2258
2259 The backup number, an integer that starts at 0 and increments
2260 for each successive backup.  The corresponding backup is stored
2261 in the directory num (eg: if this field is 5, then the backup is
2262 stored in __TOPDIR__/pc/$host/5).
2263
2264 =item type
2265
2266 Set to "full" or "incr" for full or incremental backup.
2267
2268 =item startTime
2269
2270 Start time of the backup in unix seconds.
2271
2272 =item endTime
2273
2274 Stop time of the backup in unix seconds.
2275
2276 =item nFiles
2277
2278 Number of files backed up (as reported by smbclient, tar or rsync).
2279
2280 =item size
2281
2282 Total file size backed up (as reported by smbclient, tar or rsync).
2283
2284 =item nFilesExist
2285
2286 Number of files that were already in the pool
2287 (as determined by BackupPC_dump and BackupPC_link).
2288
2289 =item sizeExist
2290
2291 Total size of files that were already in the pool
2292 (as determined by BackupPC_dump and BackupPC_link).
2293
2294 =item nFilesNew
2295
2296 Number of files that were not in the pool
2297 (as determined by BackupPC_link).
2298
2299 =item sizeNew
2300
2301 Total size of files that were not in the pool
2302 (as determined by BackupPC_link).
2303
2304 =item xferErrs
2305
2306 Number of errors or warnings from smbclient, tar or rsync.
2307
2308 =item xferBadFile
2309
2310 Number of errors from smbclient that were bad file errors (zero otherwise).
2311
2312 =item xferBadShare
2313
2314 Number of errors from smbclient that were bad share errors (zero otherwise).
2315
2316 =item tarErrs
2317
2318 Number of errors from BackupPC_tarExtract.
2319
2320 =item compress
2321
2322 The compression level used on this backup.  Zero or empty means no
2323 compression.
2324
2325 =item sizeExistComp
2326
2327 Total compressed size of files that were already in the pool
2328 (as determined by BackupPC_dump and BackupPC_link).
2329
2330 =item sizeNewComp
2331
2332 Total compressed size of files that were not in the pool
2333 (as determined by BackupPC_link).
2334
2335 =item noFill
2336
2337 Set if this backup has not been filled in with the most recent
2338 previous filled or full backup.  See $Conf{IncrFill}.
2339
2340 =item fillFromNum
2341
2342 If this backup was filled (ie: noFill is 0) then this is the
2343 number of the backup that it was filled from
2344
2345 =item mangle
2346
2347 Set if this backup has mangled file names and attributes.  Always
2348 true for backups in v1.4.0 and above.  False for all backups prior
2349 to v1.4.0.
2350
2351 =item xferMethod
2352
2353 Set to the value of $Conf{XferMethod} when this dump was done.
2354
2355 =item level
2356
2357 The level of this dump.  A full dump is level 0.  Currently incrementals
2358 are 1.  But when multi-level incrementals are supported this will reflect
2359 each dump's incremental level.
2360
2361 =back
2362
2363 =item restores
2364
2365 A tab-delimited ascii table listing information about each requested
2366 restore, one per row.  The columns are:
2367
2368 =over 4
2369
2370 =item num
2371
2372 Restore number (matches the suffix of the RestoreInfo.nnn and
2373 RestoreLOG.nnn.z file), unrelated to the backup number.
2374
2375 =item startTime
2376
2377 Start time of the restore in unix seconds.
2378
2379 =item endTime
2380
2381 End time of the restore in unix seconds.
2382
2383 =item result
2384
2385 Result (ok or failed).
2386
2387 =item errorMsg
2388
2389 Error message if restore failed.
2390
2391 =item nFiles
2392
2393 Number of files restored.
2394
2395 =item size
2396
2397 Size in bytes of the restored files.
2398
2399 =item tarCreateErrs
2400
2401 Number of errors from BackupPC_tarCreate during restore.
2402
2403 =item xferErrs
2404
2405 Number of errors from smbclient, tar or rsync during restore.
2406
2407 =back
2408
2409 =item archives
2410
2411 A tab-delimited ascii table listing information about each requested
2412 archive, one per row.  The columns are:
2413
2414 =over 4
2415
2416 =item num
2417
2418 Archive number (matches the suffix of the ArchiveInfo.nnn and
2419 ArchiveLOG.nnn.z file), unrelated to the backup or restore number.
2420
2421 =item startTime
2422
2423 Start time of the restore in unix seconds.
2424
2425 =item endTime
2426
2427 End time of the restore in unix seconds.
2428
2429 =item result
2430
2431 Result (ok or failed).
2432
2433 =item errorMsg
2434
2435 Error message if archive failed.
2436
2437 =back
2438
2439 =back
2440
2441 =back
2442
2443 =head2 Compressed file format
2444
2445 The compressed file format is as generated by Compress::Zlib::deflate
2446 with one minor, but important, tweak. Since Compress::Zlib::inflate
2447 fully inflates its argument in memory, it could take large amounts of
2448 memory if it was inflating a highly compressed file. For example, a
2449 200MB file of 0x0 bytes compresses to around 200K bytes. If
2450 Compress::Zlib::inflate was called with this single 200K buffer, it
2451 would need to allocate 200MB of memory to return the result.
2452
2453 BackupPC watches how efficiently a file is compressing. If a big file
2454 has very high compression (meaning it will use too much memory when it
2455 is inflated), BackupPC calls the flush() method, which gracefully
2456 completes the current compression.  BackupPC then starts another
2457 deflate and simply appends the output file.  So the BackupPC compressed
2458 file format is one or more concatenated deflations/flushes.  The specific
2459 ratios that BackupPC uses is that if a 6MB chunk compresses to less
2460 than 64K then a flush will be done.
2461
2462 Back to the example of the 200MB file of 0x0 bytes.  Adding flushes
2463 every 6MB adds only 200 or so bytes to the 200K output.  So the
2464 storage cost of flushing is negligible.
2465
2466 To easily decompress a BackupPC compressed file, the script
2467 BackupPC_zcat can be found in __INSTALLDIR__/bin.  For each
2468 file name argument it inflates the file and writes it to stdout.
2469
2470 =head2 Rsync checksum caching
2471
2472 An incremental backup with rsync compares attributes on the client
2473 with the last full backup.  Any files with identical attributes
2474 are skipped.  A full backup with rsync sets the --ignore-times
2475 option, which causes every file to be examined independent of
2476 attributes.
2477
2478 Each file is examined by generating block checksums (default 2K
2479 blocks) on the receiving side (that's the BackupPC side), sending
2480 those checksums to the client, where the remote rsync matches those
2481 checksums with the corresponding file.  The matching blocks and new
2482 data is sent back, allowing the client file to be reassembled.
2483 A checksum for the entire file is sent to as an extra check the
2484 the reconstructed file is correct.
2485
2486 This results in significant disk IO and computation for BackupPC:
2487 every file in a full backup, or any file with non-matching attributes
2488 in an incremental backup, needs to be uncompressed, block checksums
2489 computed and sent.  Then the receiving side reassembles the file and
2490 has to verify the whole-file checksum.  Even if the file is identical,
2491 prior to 2.1.0, BackupPC had to read and uncompress the file twice,
2492 once to compute the block checksums and later to verify the whole-file
2493 checksum.
2494
2495 Starting in 2.1.0, BackupPC supports optional checksum caching,
2496 which means the block and file checksums only need to be computed
2497 once for each file.  This results in a significant performance
2498 improvement.  This only works for compressed pool files.
2499 It is enabled by adding
2500
2501         '--checksum-seed=32761',
2502
2503 to $Conf{RsyncArgs} and $Conf{RsyncRestoreArgs}.
2504
2505 Rsync versions prior to and including rsync-2.6.2 need a small patch to
2506 add support for the --checksum-seed option.  This patch is available in
2507 the cygwin-rsyncd package at L<http://backuppc.sourceforge.net>.
2508 This patch is already included in rsync CVS, so it will be standard
2509 in future versions of rsync.
2510
2511 When this option is present, BackupPC will add block and file checksums
2512 to the compressed pool file the next time a pool file is used and it
2513 doesn't already have cached checksums.  The first time a new file is
2514 written to the pool, the checksums are not appended.  The next time
2515 checksums are needed for a file, they are computed and added.  So the
2516 full performance benefit of checksum caching won't be noticed until the
2517 third time a pool file is used (eg: the third full backup).
2518
2519 With checksum caching enabled, there is a risk that should a file's contents
2520 in the pool be corrupted due to a disk problem, but the cached checksums
2521 are still correct, the corruption will not be detected by a full backup,
2522 since the file contents are no longer read and compared.  To reduce the
2523 chance that this remains undetected, BackupPC can recheck cached checksums
2524 for a fraction of the files.  This fraction is set with the
2525 $Conf{RsyncCsumCacheVerifyProb} setting.  The default value of 0.01 means
2526 that 1% of the time a file's checksums are read, the checksums are verified.
2527 This reduces performance slightly, but, over time, ensures that files
2528 contents are in sync with the cached checksums.
2529
2530 The format of the cached checksum data can be discovered by looking at
2531 the code.  Basically, the first byte of the compressed file is changed
2532 to denote that checksums are appended.  The block and file checksum
2533 data, plus some other information and magic word, are appended to the
2534 compressed file.  This allows the cache update to be done in-place.
2535
2536 =head2 File name mangling
2537
2538 Backup file names are stored in "mangled" form. Each node of
2539 a path is preceded by "f" (mnemonic: file), and special characters
2540 (\n, \r, % and /) are URI-encoded as "%xx", where xx is the ascii
2541 character's hex value.  So c:/craig/example.txt is now stored as
2542 fc/fcraig/fexample.txt.
2543
2544 This was done mainly so meta-data could be stored alongside the backup
2545 files without name collisions. In particular, the attributes for the
2546 files in a directory are stored in a file called "attrib", and mangling
2547 avoids file name collisions (I discarded the idea of having a duplicate
2548 directory tree for every backup just to store the attributes). Other
2549 meta-data (eg: rsync checksums) could be stored in file names preceded
2550 by, eg, "c". There are two other benefits to mangling: the share name
2551 might contain "/" (eg: "/home/craig" for tar transport), and I wanted
2552 that represented as a single level in the storage tree. Secondly, as
2553 files are written to NewFileList for later processing by BackupPC_link,
2554 embedded newlines in the file's path will cause problems which are
2555 avoided by mangling.
2556
2557 The CGI script undoes the mangling, so it is invisible to the user.
2558 Old (unmangled) backups are still supported by the CGI
2559 interface.
2560
2561 =head2 Special files
2562
2563 Linux/unix file systems support several special file types: symbolic
2564 links, character and block device files, fifos (pipes) and unix-domain
2565 sockets. All except unix-domain sockets are supported by BackupPC
2566 (there's no point in backing up or restoring unix-domain sockets since
2567 they only have meaning after a process creates them). Symbolic links are
2568 stored as a plain file whose contents are the contents of the link (not
2569 the file it points to). This file is compressed and pooled like any
2570 normal file. Character and block device files are also stored as plain
2571 files, whose contents are two integers separated by a comma; the numbers
2572 are the major and minor device number. These files are compressed and
2573 pooled like any normal file. Fifo files are stored as empty plain files
2574 (which are not pooled since they have zero size). In all cases, the
2575 original file type is stored in the attrib file so it can be correctly
2576 restored.
2577
2578 Hardlinks are also supported.  When GNU tar first encounters a file with
2579 more than one link (ie: hardlinks) it dumps it as a regular file.  When
2580 it sees the second and subsequent hardlinks to the same file, it dumps
2581 just the hardlink information.  BackupPC correctly recognizes these
2582 hardlinks and stores them just like symlinks: a regular text file
2583 whose contents is the path of the file linked to.  The CGI script
2584 will download the original file when you click on a hardlink.
2585
2586 Also, BackupPC_tarCreate has enough magic to re-create the hardlinks
2587 dynamically based on whether or not the original file and hardlinks
2588 are both included in the tar file.  For example, imagine a/b/x is a
2589 hardlink to a/c/y.  If you use BackupPC_tarCreate to restore directory
2590 a, then the tar file will include a/b/x as the original file and a/c/y
2591 will be a hardlink to a/b/x.  If, instead you restore a/c, then the
2592 tar file will include a/c/y as the original file, not a hardlink.
2593
2594 =head2 Attribute file format
2595
2596 The unix attributes for the contents of a directory (all the files and
2597 directories in that directory) are stored in a file called attrib.
2598 There is a single attrib file for each directory in a backup.
2599 For example, if c:/craig contains a single file c:/craig/example.txt,
2600 that file would be stored as fc/fcraig/fexample.txt and there would be an
2601 attribute file in fc/fcraig/attrib (and also fc/attrib and ./attrib).
2602 The file fc/fcraig/attrib would contain a single entry containing the
2603 attributes for fc/fcraig/fexample.txt.
2604
2605 The attrib file starts with a magic number, followed by the
2606 concatenation of the following information for each file:
2607
2608 =over 4
2609
2610 =item *
2611
2612 File name length in perl's pack "w" format (variable length base 128).
2613
2614 =item *
2615
2616 File name.
2617
2618 =item *
2619
2620 The unix file type, mode, uid, gid and file size divided by 4GB and
2621 file size modulo 4GB (type mode uid gid sizeDiv4GB sizeMod4GB),
2622 in perl's pack "w" format (variable length base 128).
2623
2624 =item *
2625
2626 The unix mtime (unix seconds) in perl's pack "N" format (32 bit integer).
2627
2628 =back
2629
2630 The attrib file is also compressed if compression is enabled.
2631 See the lib/BackupPC/Attrib.pm module for full details.
2632
2633 Attribute files are pooled just like normal backup files.  This saves
2634 space if all the files in a directory have the same attributes across
2635 multiple backups, which is common.
2636
2637 =head2 Optimizations
2638
2639 BackupPC doesn't care about the access time of files in the pool
2640 since it saves attribute meta-data separate from the files.  Since
2641 BackupPC mostly does reads from disk, maintaining the access time of
2642 files generates a lot of unnecessary disk writes.  So, provided 
2643 BackupPC has a dedicated data disk, you should consider mounting
2644 BackupPC's data directory with the noatime attribute (see mount(1)).
2645
2646 =head2 Limitations
2647
2648 BackupPC isn't perfect (but it is getting better). Please see
2649 L<http://backuppc.sourceforge.net/faq/limitations.html> for a
2650 discussion of some of BackupPC's limitations.
2651
2652 =head2 Security issues
2653
2654 Please see L<http://backuppc.sourceforge.net/faq/security.html> for a
2655 discussion of some of various security issues.
2656
2657 =head1 Configuration File
2658
2659 The BackupPC configuration file resides in __CONFDIR__/config.pl.
2660 Optional per-PC configuration files reside in __CONFDIR__/pc/$host.pl
2661 (or __TOPDIR__/pc/$host/config.pl in non-FHS versions of BackupPC).
2662 This file can be used to override settings just for a particular PC.
2663
2664 =head2 Modifying the main configuration file
2665
2666 The configuration file is a perl script that is executed by BackupPC, so
2667 you should be careful to preserve the file syntax (punctuation, quotes
2668 etc) when you edit it. It is recommended that you use CVS, RCS or some
2669 other method of source control for changing config.pl.
2670
2671 BackupPC reads or re-reads the main configuration file and
2672 the hosts file in three cases:
2673
2674 =over 4
2675
2676 =item *
2677
2678 Upon startup.
2679
2680 =item *
2681
2682 When BackupPC is sent a HUP (-1) signal.  Assuming you installed the 
2683 init.d script, you can also do this with "/etc/init.d/backuppc reload".
2684
2685 =item *
2686
2687 When the modification time of config.pl file changes.  BackupPC
2688 checks the modification time once during each regular wakeup.
2689
2690 =back
2691
2692 Whenever you change the configuration file you can either do
2693 a kill -HUP BackupPC_pid or simply wait until the next regular
2694 wakeup period.
2695
2696 Each time the configuration file is re-read a message is reported in the
2697 LOG file, so you can tail it (or view it via the CGI interface) to make
2698 sure your kill -HUP worked. Errors in parsing the configuration file are
2699 also reported in the LOG file.
2700
2701 The optional per-PC configuration file (__CONFDIR__/pc/$host.pl or
2702 __TOPDIR__/pc/$host/config.pl in non-FHS versions of BackupPC)
2703 is read whenever it is needed by BackupPC_dump, BackupPC_link and others.
2704
2705 =head1 Configuration Parameters
2706
2707 The configuration parameters are divided into five general groups.
2708 The first group (general server configuration) provides general
2709 configuration for BackupPC.  The next two groups describe what to
2710 backup, when to do it, and how long to keep it.  The fourth group
2711 are settings for email reminders, and the final group contains
2712 settings for the CGI interface.
2713
2714 All configuration settings in the second through fifth groups can
2715 be overridden by the per-PC config.pl file.
2716
2717 __CONFIGPOD__
2718
2719 =head1 Version Numbers
2720
2721 Starting with v1.4.0 BackupPC uses a X.Y.Z version numbering system,
2722 instead of X.0Y. The first digit is for major new releases, the middle
2723 digit is for significant feature releases and improvements (most of
2724 the releases have been in this category), and the last digit is for
2725 bug fixes. You should think of the old 1.00, 1.01, 1.02 and 1.03 as
2726 1.0.0, 1.1.0, 1.2.0 and 1.3.0.
2727
2728 Additionally, patches might be made available.  A patched version
2729 number is of the form X.Y.ZplN (eg: 2.1.0pl2), where N is the
2730 patch level.
2731
2732 =head1 Author
2733
2734 Craig Barratt  <cbarratt@users.sourceforge.net>
2735
2736 See L<http://backuppc.sourceforge.net>.
2737
2738 =head1 Copyright
2739
2740 Copyright (C) 2001-2006 Craig Barratt
2741
2742 =head1 Credits
2743
2744 Ryan Kucera contributed the directory navigation code and images
2745 for v1.5.0.  He contributed the first skeleton of BackupPC_restore.
2746 He also added a significant revision to the CGI interface, including
2747 CSS tags, in v2.1.0, and designed the BackupPC logo.
2748
2749 Xavier Nicollet, with additions from Guillaume Filion, added the
2750 internationalization (i18n) support to the CGI interface for v2.0.0.
2751 Xavier provided the French translation fr.pm, with additions from
2752 Guillaume.
2753
2754 Guillaume Filion wrote BackupPC_zipCreate and added the CGI support
2755 for zip download, in addition to some CGI cleanup, for v1.5.0.
2756 Guillaume continues to support fr.pm updates for each new version.
2757
2758 Josh Marshall implemented the Archive feature in v2.1.0.
2759
2760 Ludovic Drolez supports the BackupPC Debian package.
2761
2762 Javier Gonzalez provided the Spanish translation, es.pm for v2.0.0.
2763
2764 Manfred Herrmann provided the German translation, de.pm for v2.0.0.
2765 Manfred continues to support de.pm updates for each new version,
2766 together with some help frmo Ralph Paßgang.
2767
2768 Lorenzo Cappelletti provided the Italian translation, it.pm for v2.1.0.
2769
2770 Lieven Bridts provided the Dutch translation, nl.pm, for v2.1.0,
2771 with some tweaks from Guus Houtzager.
2772
2773 Reginaldo Ferreira provided the Portuguese Brazillian translation
2774 pt_br.pm for v2.2.0.
2775
2776 Rich Duzenbury provided the RSS feed option to the CGI interface.
2777
2778 Many people have reported bugs, made useful suggestions and helped
2779 with testing; see the ChangeLog and the mail lists.
2780
2781 Your name could appear here in the next version!
2782
2783 =head1 License
2784
2785 This program is free software; you can redistribute it and/or modify it
2786 under the terms of the GNU General Public License as published by the
2787 Free Software Foundation; either version 2 of the License, or (at your
2788 option) any later version.
2789
2790 This program is distributed in the hope that it will be useful,
2791 but WITHOUT ANY WARRANTY; without even the implied warranty of
2792 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2793 General Public License for more details.
2794
2795 You should have received a copy of the GNU General Public License in the
2796 LICENSE file along with this program; if not, write to the Free Software
2797 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.