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