2 #============================================================= -*-perl-*-
4 # configure.pl: Configuration and installation program for BackupPC
8 # This script should be run as root:
12 # The installation steps are described as the script runs.
15 # Craig Barratt <cbarratt@users.sourceforge.net>
18 # Copyright (C) 2001-2004 Craig Barratt
20 # This program is free software; you can redistribute it and/or modify
21 # it under the terms of the GNU General Public License as published by
22 # the Free Software Foundation; either version 2 of the License, or
23 # (at your option) any later version.
25 # This program is distributed in the hope that it will be useful,
26 # but WITHOUT ANY WARRANTY; without even the implied warranty of
27 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 # GNU General Public License for more details.
30 # You should have received a copy of the GNU General Public License
31 # along with this program; if not, write to the Free Software
32 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #========================================================================
36 # Version 2.1.2, released 5 Sep 2005.
38 # See http://backuppc.sourceforge.net.
40 #========================================================================
44 use vars qw(%Conf %OrigConf);
47 my @Packages = qw(File::Path File::Spec File::Copy DirHandle Digest::MD5
48 Data::Dumper Getopt::Std Getopt::Long Pod::Usage
49 BackupPC::Lib BackupPC::FileZIO);
51 foreach my $pkg ( @Packages ) {
54 if ( $pkg =~ /BackupPC/ ) {
57 BackupPC cannot find the package $pkg, which is included in the
58 BackupPC distribution. This probably means you did not cd to the
59 unpacked BackupPC distribution before running configure.pl, eg:
70 BackupPC needs the package $pkg. Please install $pkg
71 before installing BackupPC.
95 pod2usage(1) if ( $opts{help} );
96 pod2usage(-exitstatus => 0, -verbose => 2) if $opts{man};
98 my $DestDir = $opts{"dest-dir"};
103 This configure script should be run as root, rather than uid $<.
104 Provided uid $< has sufficient permissions to create the data and
105 install directories, then it should be ok to proceed. Otherwise,
106 please quit and restart as root.
109 exit(1) if ( prompt("--> Do you want to continue?",
111 exit(1) if ( $opts{batch} && !$opts{"uid-ignore"} );
116 Is this a new installation or upgrade for BackupPC? If this is
117 an upgrade please tell me the full path of the existing BackupPC
118 configuration file (eg: /xxxx/conf/config.pl). Otherwise, just
124 # Check if this is an upgrade, in which case read the existing
125 # config file to get all the defaults.
129 $ConfigPath = prompt("--> Full path to existing conf/config.pl",
132 last if ( $ConfigPath eq ""
133 || ($ConfigPath =~ /^\// && -r $ConfigPath && -w $ConfigPath) );
134 my $problem = "is not an absolute path";
135 $problem = "is not writable" if ( !-w $ConfigPath );
136 $problem = "is not readable" if ( !-r $ConfigPath );
137 $problem = "doesn't exist" if ( !-f $ConfigPath );
138 print("The file '$ConfigPath' $problem.\n");
139 if ( $opts{batch} ) {
140 print("Need to specify a valid --config-path for upgrade\n");
145 if ( $ConfigPath ne "" && -r $ConfigPath ) {
146 (my $topDir = $ConfigPath) =~ s{/[^/]+/[^/]+$}{};
147 die("BackupPC::Lib->new failed\n")
148 if ( !($bpc = BackupPC::Lib->new($topDir, ".", 1)) );
149 %Conf = $bpc->Conf();
151 $Conf{TopDir} = $topDir;
152 my $err = $bpc->ServerConnect($Conf{ServerHost}, $Conf{ServerPort}, 1);
156 BackupPC is running on $Conf{ServerHost}. You need to stop BackupPC
157 before you can upgrade the code. Depending upon your installation,
158 you could run "/etc/init.d/backuppc stop".
166 # These are the programs whose paths we need to find
170 'gtar/tar' => "TarClientPath",
171 smbclient => "SmbClientPath",
172 nmblookup => "NmbLookupPath",
173 rsync => "RsyncClientPath",
176 'ssh/ssh2' => "SshPath",
177 sendmail => "SendmailPath",
178 hostname => "HostnamePath",
179 split => "SplitPath",
183 bzip2 => "Bzip2Path",
186 foreach my $prog ( sort(keys(%Programs)) ) {
188 foreach my $subProg ( split(/\//, $prog) ) {
189 $path = FindProgram("$ENV{PATH}:/bin:/usr/bin:/sbin:/usr/sbin",
190 $subProg) if ( !length($path) );
192 $Conf{$Programs{$prog}} = $path if ( !length($Conf{$Programs{$prog}}) );
198 I found the following locations for these programs:
201 foreach my $prog ( sort(keys(%Programs)) ) {
202 printf(" %-12s => %s\n", $prog, $Conf{$Programs{$prog}});
205 last if (prompt('--> Are these paths correct?', 'y') =~ /^y/i);
206 foreach my $prog ( sort(keys(%Programs)) ) {
207 $Conf{$Programs{$prog}} = prompt("--> $prog path",
208 $Conf{$Programs{$prog}});
212 my $Perl56 = system($Conf{PerlPath}
213 . q{ -e 'exit($^V && $^V ge v5.6.0 ? 1 : 0);'});
218 BackupPC needs perl version 5.6.0 or later. $Conf{PerlPath} appears
219 to be an older version. Please upgrade to a newer version of perl
220 and re-run this configure script.
228 Please tell me the hostname of the machine that BackupPC will run on.
231 chomp($Conf{ServerHost} = `$Conf{HostnamePath}`)
232 if ( defined($Conf{HostnamePath}) && !defined($Conf{ServerHost}) );
233 $Conf{ServerHost} = prompt("--> BackupPC will run on host",
239 BackupPC should run as a dedicated user with limited privileges. You
240 need to create a user. This user will need read/write permission on
241 the main data directory and read/execute permission on the install
242 directory (these directories will be setup shortly).
244 The primary group for this user should also be chosen carefully.
245 By default the install directories will have group write permission.
246 The data directories and files will have group read permission but
250 my($name, $passwd, $Uid, $Gid);
252 $Conf{BackupPCUser} = prompt("--> BackupPC should run as user",
253 $Conf{BackupPCUser} || "backuppc",
255 ($name, $passwd, $Uid, $Gid) = getpwnam($Conf{BackupPCUser});
256 last if ( $name ne "" );
259 getpwnam() says that user $Conf{BackupPCUser} doesn't exist. Please check the
260 name and verify that this user is in the passwd file.
263 exit(1) if ( $opts{batch} );
268 Please specify an install directory for BackupPC. This is where the
269 BackupPC scripts, library and documentation will be installed.
274 $Conf{InstallDir} = prompt("--> Install directory (full path)",
277 last if ( $Conf{InstallDir} =~ /^\// );
278 if ( $opts{batch} ) {
279 print("Need to specify --install-dir for new installation\n");
286 Please specify a data directory for BackupPC. This is where the
287 configuration files, LOG files and all the PC backups are stored.
288 This file system needs to be big enough to accommodate all the
289 PCs you expect to backup (eg: at least 1-2GB per machine).
294 $Conf{TopDir} = prompt("--> Data directory (full path)",
297 last if ( $Conf{TopDir} =~ /^\// );
298 if ( $opts{batch} ) {
299 print("Need to specify --data-dir for new installation\n");
304 if ( !defined($Conf{CompressLevel}) ) {
305 $Conf{CompressLevel} = BackupPC::FileZIO->compOk ? 3 : 0;
306 if ( $ConfigPath eq "" && $Conf{CompressLevel} ) {
309 BackupPC can compress pool files, providing around a 40% reduction in pool
310 size (your mileage may vary). Specify the compression level (0 turns
311 off compression, and 1 to 9 represent good/fastest to best/slowest).
312 The recommended values are 0 (off) or 3 (reasonable compression and speed).
313 Increasing the compression level to 5 will use around 20% more cpu time
314 and give perhaps 2-3% more compression.
317 } elsif ( $ConfigPath eq "" ) {
320 BackupPC can compress pool files, but it needs the Compress::Zlib
321 package installed (see www.cpan.org). Compression will provide around a
322 40% reduction in pool size, at the expense of cpu time. You can leave
323 compression off and run BackupPC without compression, in which case you
324 should leave the compression level at 0 (which means off). You could
325 install Compress::Zlib and turn compression on later, but read the
326 documentation first about how to do this. Or the better choice is
327 to quit, install Compress::Zlib, and re-run configure.pl.
330 } elsif ( $Conf{CompressLevel} ) {
331 $Conf{CompressLevel} = 0;
334 BackupPC now supports pool file compression. Since you are upgrading
335 BackupPC you probably have existing uncompressed backups. You have
336 several choices if you want to turn on compression. You can run
337 the script BackupPC_compressPool to convert everything to compressed
338 form. Or you can simply turn on compression, so that new backups
339 will be compressed. This will increase the pool storage requirement,
340 since both uncompressed and compressed copies of files will be stored.
341 But eventually the old uncompressed backups will expire, recovering
342 the pool storage. Please see the documentation for more details.
344 If you are not sure what to do, leave the Compression Level at 0,
345 which disables compression. You can always read the documentation
346 and turn it on later.
350 $Conf{CompressLevel} = 0;
353 BackupPC now supports pool file compression, but it needs the
354 Compress::Zlib module (see www.cpan.org). For now, leave
355 the compression level set at 0 to disable compression. If you
356 want you can install Compress::Zlib and turn compression on.
357 Please see the documentation for more details about converting
358 old backups to compressed form.
364 = prompt("--> Compression level", $Conf{CompressLevel});
365 last if ( $Conf{CompressLevel} =~ /^\d+$/ );
371 BackupPC has a powerful CGI perl interface that runs under Apache.
372 A single executable needs to be installed in a cgi-bin directory.
373 This executable needs to run as set-uid $Conf{BackupPCUser}, or
374 it can be run under mod_perl with Apache running as user $Conf{BackupPCUser}.
376 Leave this path empty if you don't want to install the CGI interface.
381 $Conf{CgiDir} = prompt("--> CGI bin directory (full path)",
384 last if ( $Conf{CgiDir} =~ /^\// || $Conf{CgiDir} eq "" );
385 if ( $opts{batch} ) {
386 print("Need to specify --cgi-dir for new installation\n");
391 if ( $Conf{CgiDir} ne "" ) {
395 BackupPC's CGI script needs to display various GIF images that
396 should be stored where Apache can serve them. They should be
397 placed somewher under Apache's DocumentRoot. BackupPC also
398 needs to know the URL to access these images. Example:
400 Apache image directory: /usr/local/apache/htdocs/BackupPC
401 URL for image directory: /BackupPC
403 The URL for the image directory should start with a slash.
407 $Conf{CgiImageDir} = prompt("--> Apache image directory (full path)",
410 last if ( $Conf{CgiImageDir} =~ /^\// );
411 if ( $opts{batch} ) {
412 print("Need to specify --html-dir for new installation\n");
417 $Conf{CgiImageDirURL} = prompt("--> URL for image directory (omit http://host; starts with '/')",
418 $Conf{CgiImageDirURL},
420 last if ( $Conf{CgiImageDirURL} =~ /^\// );
421 if ( $opts{batch} ) {
422 print("Need to specify --html-dir-url for new installation\n");
432 - install the binaries, lib and docs in $Conf{InstallDir},
433 - create the data directory $Conf{TopDir},
434 - create/update the config.pl file $Conf{TopDir}/conf,
435 - optionally install the cgi-bin interface.
439 exit unless prompt("--> Do you want to continue?", "y") =~ /y/i;
442 # Create install directories
444 foreach my $dir ( qw(bin doc
450 next if ( -d "$DestDir$Conf{InstallDir}/$dir" );
451 mkpath("$DestDir$Conf{InstallDir}/$dir", 0, 0775);
452 if ( !-d "$DestDir$Conf{InstallDir}/$dir"
453 || !chown($Uid, $Gid, "$DestDir$Conf{InstallDir}/$dir") ) {
454 die("Failed to create or chown $DestDir$Conf{InstallDir}/$dir\n");
456 print("Created $DestDir$Conf{InstallDir}/$dir\n");
461 # Create CGI image directory
463 foreach my $dir ( ($Conf{CgiImageDir}) ) {
464 next if ( $dir eq "" || -d "$DestDir$dir" );
465 mkpath("$DestDir$dir", 0, 0775);
466 if ( !-d "$DestDir$dir" || !chown($Uid, $Gid, "$DestDir$dir") ) {
467 die("Failed to create or chown $DestDir$dir");
469 print("Created $DestDir$dir\n");
474 # Create $TopDir's top-level directories
476 foreach my $dir ( qw(. conf pool cpool pc trash log) ) {
477 mkpath("$DestDir$Conf{TopDir}/$dir", 0, 0750) if ( !-d "$DestDir$Conf{TopDir}/$dir" );
478 if ( !-d "$DestDir$Conf{TopDir}/$dir"
479 || !chown($Uid, $Gid, "$DestDir$Conf{TopDir}/$dir") ) {
480 die("Failed to create or chown $DestDir$Conf{TopDir}/$dir\n");
482 print("Created $DestDir$Conf{TopDir}/$dir\n");
486 printf("Installing binaries in $DestDir$Conf{InstallDir}/bin\n");
487 foreach my $prog ( qw(BackupPC BackupPC_dump BackupPC_link BackupPC_nightly
488 BackupPC_sendEmail BackupPC_tarCreate BackupPC_trashClean
489 BackupPC_tarExtract BackupPC_compressPool BackupPC_zcat
490 BackupPC_archive BackupPC_archiveHost
491 BackupPC_updatedb BackupPC_xls_report BackupPC_tarIncCreate BackupPC_incPartsUpdate BackupPC_burnArchiveCLI
492 BackupPC_restore BackupPC_serverMesg BackupPC_zipCreate ) ) {
493 InstallFile("bin/$prog", "$DestDir$Conf{InstallDir}/bin/$prog", 0555);
496 printf("Installing library in $DestDir$Conf{InstallDir}/lib\n");
497 foreach my $lib ( qw(
501 BackupPC/PoolWrite.pm
503 BackupPC/Xfer/Archive.pm
506 BackupPC/Xfer/Rsync.pm
507 BackupPC/Xfer/RsyncDigest.pm
508 BackupPC/Xfer/RsyncFileIO.pm
509 BackupPC/Zip/FileMember.pm
516 BackupPC/CGI/AdminOptions.pm
517 BackupPC/CGI/Archive.pm
518 BackupPC/CGI/ArchiveInfo.pm
519 BackupPC/CGI/Browse.pm
520 BackupPC/CGI/DirHistory.pm
521 BackupPC/CGI/EmailSummary.pm
522 BackupPC/CGI/GeneralInfo.pm
523 BackupPC/CGI/HostInfo.pm
525 BackupPC/CGI/LOGlist.pm
526 BackupPC/CGI/Queue.pm
527 BackupPC/CGI/ReloadServer.pm
528 BackupPC/CGI/RestoreFile.pm
529 BackupPC/CGI/RestoreInfo.pm
530 BackupPC/CGI/Restore.pm
531 BackupPC/CGI/StartServer.pm
532 BackupPC/CGI/StartStopBackup.pm
533 BackupPC/CGI/StopServer.pm
534 BackupPC/CGI/Summary.pm
536 BackupPC/CGI/BurnMedia.pm
537 BackupPC/CGI/SearchArchives.pm
538 BackupPC/SearchLib.pm
540 InstallFile("lib/$lib", "$DestDir$Conf{InstallDir}/lib/$lib", 0444);
543 if ( $Conf{CgiImageDir} ne "" ) {
544 printf("Installing images in $DestDir$Conf{CgiImageDir}\n");
545 foreach my $img ( <images/*> ) {
546 (my $destImg = $img) =~ s{^images/}{};
547 InstallFile($img, "$DestDir$Conf{CgiImageDir}/$destImg", 0444, 1);
551 # Install new CSS file, making a backup copy if necessary
553 my $cssBackup = "$DestDir$Conf{CgiImageDir}/BackupPC_stnd.css.pre-2.1.2";
554 if ( -f "$DestDir$Conf{CgiImageDir}/BackupPC_stnd.css" && !-f $cssBackup ) {
555 rename("$DestDir$Conf{CgiImageDir}/BackupPC_stnd.css", $cssBackup);
557 InstallFile("conf/BackupPC_stnd.css",
558 "$DestDir$Conf{CgiImageDir}/BackupPC_stnd.css", 0444, 0);
559 InstallFile("conf/BackupPC_lite.css",
560 "$DestDir$Conf{CgiImageDir}/BackupPC_lite.css", 0444, 0);
561 InstallFile("conf/archive.css",
562 "$DestDir$Conf{CgiImageDir}/archive.css", 0444, 0);
565 printf("Making init.d scripts\n");
566 foreach my $init ( qw(gentoo-backuppc gentoo-backuppc.conf linux-backuppc
567 solaris-backuppc debian-backuppc suse-backuppc) ) {
568 InstallFile("init.d/src/$init", "init.d/$init", 0444);
571 printf("Installing docs in $DestDir$Conf{InstallDir}/doc\n");
572 foreach my $doc ( qw(BackupPC.pod BackupPC.html) ) {
573 InstallFile("doc/$doc", "$DestDir$Conf{InstallDir}/doc/$doc", 0444);
576 printf("Installing config.pl and hosts in $DestDir$Conf{TopDir}/conf\n");
577 InstallFile("conf/hosts", "$DestDir$Conf{TopDir}/conf/hosts", 0644)
578 if ( !-f "$DestDir$Conf{TopDir}/conf/hosts" );
581 # Now do the config file. If there is an existing config file we
582 # merge in the new config file, adding any new configuration
583 # parameters and deleting ones that are no longer needed.
585 my $dest = "$DestDir$Conf{TopDir}/conf/config.pl";
586 my ($newConf, $newVars) = ConfigParse("conf/config.pl");
587 my ($oldConf, $oldVars);
589 ($oldConf, $oldVars) = ConfigParse($dest);
590 $newConf = ConfigMerge($oldConf, $oldVars, $newConf, $newVars);
592 $Conf{EMailFromUserName} ||= $Conf{BackupPCUser};
593 $Conf{EMailAdminUserName} ||= $Conf{BackupPCUser};
596 # Update various config parameters
600 # Guess $Conf{CgiURL}
602 if ( !defined($Conf{CgiURL}) ) {
603 if ( $Conf{CgiDir} =~ m{cgi-bin(/.*)} ) {
604 $Conf{CgiURL} = "'http://$Conf{ServerHost}/cgi-bin$1/BackupPC_Admin'";
606 $Conf{CgiURL} = "'http://$Conf{ServerHost}/cgi-bin/BackupPC_Admin'";
611 # The smbclient commands have moved from hard-coded to the config file.
612 # $Conf{SmbClientArgs} no longer exists, so merge it into the new
613 # commands if it still exists.
615 if ( defined($Conf{SmbClientArgs}) ) {
616 if ( $Conf{SmbClientArgs} ne "" ) {
617 foreach my $param ( qw(SmbClientRestoreCmd SmbClientFullCmd
618 SmbClientIncrCmd) ) {
619 $newConf->[$newVars->{$param}]{text}
620 =~ s/(-E\s+-N)/$1 $Conf{SmbClientArgs}/;
623 delete($Conf{SmbClientArgs});
627 # CSS is now stored in a file rather than a big config variable.
629 delete($Conf{CSSstylesheet});
632 # The blackout timing settings are now stored in a list of hashes, rather
633 # than three scalar parameters.
635 if ( defined($Conf{BlackoutHourBegin}) ) {
636 $Conf{BlackoutPeriods} = [
638 hourBegin => $Conf{BlackoutHourBegin},
639 hourEnd => $Conf{BlackoutHourEnd},
640 weekDays => $Conf{BlackoutWeekDays},
643 delete($Conf{BlackoutHourBegin});
644 delete($Conf{BlackoutHourEnd});
645 delete($Conf{BlackoutWeekDays});
649 # $Conf{RsyncLogLevel} has been replaced by $Conf{XferLogLevel}
651 if ( defined($Conf{RsyncLogLevel}) ) {
652 $Conf{XferLogLevel} = $Conf{RsyncLogLevel};
653 delete($Conf{RsyncLogLevel});
657 # In 2.1.0 the default for $Conf{CgiNavBarAdminAllHosts} is now 1
659 $Conf{CgiNavBarAdminAllHosts} = 1;
662 # IncrFill should now be off
667 # Figure out sensible arguments for the ping command
669 if ( defined($Conf{PingArgs}) ) {
670 $Conf{PingCmd} = '$pingPath ' . $Conf{PingArgs};
671 } elsif ( !defined($Conf{PingCmd}) ) {
672 if ( $^O eq "solaris" || $^O eq "sunos" ) {
673 $Conf{PingCmd} = '$pingPath -s $host 56 1';
674 } elsif ( ($^O eq "linux" || $^O eq "openbsd" || $^O eq "netbsd")
675 && !system("$Conf{PingPath} -c 1 -w 3 localhost") ) {
676 $Conf{PingCmd} = '$pingPath -c 1 -w 3 $host';
678 $Conf{PingCmd} = '$pingPath -c 1 $host';
680 delete($Conf{PingArgs});
684 # Figure out sensible arguments for the df command
686 if ( !defined($Conf{DfCmd}) ) {
687 if ( $^O eq "solaris" || $^O eq "sunos" ) {
688 $Conf{DfCmd} = '$dfPath -k $topDir';
693 # $Conf{SmbClientTimeout} is now $Conf{ClientTimeout}
695 if ( defined($Conf{SmbClientTimeout}) ) {
696 $Conf{ClientTimeout} = $Conf{SmbClientTimeout};
697 delete($Conf{SmbClientTimeout});
700 my $confCopy = "$dest.pre-2.1.2";
701 if ( -f $dest && !-f $confCopy ) {
703 # Make copy of config file, preserving ownership and modes
705 printf("Making backup copy of $dest -> $confCopy\n");
706 my @stat = stat($dest);
710 die("can't copy($dest, $confCopy)\n") unless copy($dest, $confCopy);
711 die("can't chown $uid, $gid $confCopy\n")
712 unless chown($uid, $gid, $confCopy);
713 die("can't chmod $mode $confCopy\n") unless chmod($mode, $confCopy);
715 open(OUT, ">", $dest) || die("can't open $dest for writing\n");
718 foreach my $var ( @$newConf ) {
719 if ( length($blockComment)
720 && substr($var->{text}, 0, length($blockComment)) eq $blockComment ) {
721 $var->{text} = substr($var->{text}, length($blockComment));
722 $blockComment = undef;
724 $blockComment = $1 if ( $var->{text} =~ /^([\s\n]*#{70}.*#{70}[\s\n]+)/s );
725 $var->{text} =~ s/^\s*\$Conf\{(.*?)\}(\s*=\s*['"]?)(.*?)(['"]?\s*;)/
726 defined($Conf{$1}) && ref($Conf{$1}) eq ""
727 && $Conf{$1} ne $OrigConf{$1}
728 ? "\$Conf{$1}$2$Conf{$1}$4"
729 : "\$Conf{$1}$2$3$4"/emg;
730 print OUT $var->{text};
733 if ( !defined($oldConf) ) {
734 die("can't chmod 0640 mode $dest\n") unless chmod(0640, $dest);
735 die("can't chown $Uid, $Gid $dest\n") unless chown($Uid, $Gid, $dest);
738 if ( $Conf{CgiDir} ne "" ) {
739 printf("Installing cgi script BackupPC_Admin in $DestDir$Conf{CgiDir}\n");
740 mkpath("$DestDir$Conf{CgiDir}", 0, 0755);
741 InstallFile("cgi-bin/BackupPC_Admin", "$DestDir$Conf{CgiDir}/BackupPC_Admin",
747 Ok, it looks like we are finished. There are several more things you
750 - Browse through the config file, $Conf{TopDir}/conf/config.pl,
751 and make sure all the settings are correct. In particular, you
752 will need to set the smb share password and user name, backup
753 policies and check the email message headers and bodies.
755 - Edit the list of hosts to backup in $Conf{TopDir}/conf/hosts.
757 - Read the documentation in $Conf{InstallDir}/doc/BackupPC.html.
758 Please pay special attention to the security section.
760 - Verify that the CGI script BackupPC_Admin runs correctly. You might
761 need to change the permissions or group ownership of BackupPC_Admin.
763 - BackupPC should be ready to start. Don't forget to run it
764 as user $Conf{BackupPCUser}! The installation also contains an
765 init.d/backuppc script that can be copied to /etc/init.d
766 so that BackupPC can auto-start on boot. This will also enable
767 administrative users to start the server from the CGI interface.
773 if ( `$Conf{PerlPath} -V` =~ /uselargefiles=undef/ ) {
776 Warning: your perl, $Conf{PerlPath}, does not support large files.
777 This means BackupPC won't be able to backup files larger than 2GB.
778 To solve this problem you should build/install a new version of perl
779 with large file support enabled. Use
781 $Conf{PerlPath} -V | egrep uselargefiles
783 to check if perl has large file support (undef means no support).
787 eval "use File::RsyncP;";
788 if ( !$@ && $File::RsyncP::VERSION < 0.51 ) {
789 print("\nWarning: you need to upgrade File::RsyncP;"
790 . " I found $File::RsyncP::VERSION and BackupPC needs 0.51\n");
795 ###########################################################################
797 ###########################################################################
801 my($prog, $dest, $mode, $binary) = @_;
803 my($uid, $gid) = ($Uid, $Gid);
807 # preserve ownership and modes of files that already exist
809 my @stat = stat($dest);
814 unlink($dest) if ( -f $dest );
816 die("can't copy($prog, $dest)\n") unless copy($prog, $dest);
818 open(PROG, $prog) || die("can't open $prog for reading\n");
819 open(OUT, ">", $dest) || die("can't open $dest for writing\n");
823 s/__INSTALLDIR__/$Conf{InstallDir}/g;
824 s/__TOPDIR__/$Conf{TopDir}/g;
825 s/__BACKUPPCUSER__/$Conf{BackupPCUser}/g;
826 s/__CGIDIR__/$Conf{CgiDir}/g;
827 if ( $first && /^#.*bin\/perl/ ) {
829 # Fill in correct path to perl (no taint for >= 2.0.1).
831 print OUT "#!$Conf{PerlPath}\n";
840 die("can't chown $uid, $gid $dest") unless chown($uid, $gid, $dest);
841 die("can't chmod $mode $dest") unless chmod($mode, $dest);
846 my($path, $prog) = @_;
848 if ( defined($opts{"bin-path"}{$prog}) ) {
849 return $opts{"bin-path"}{$prog};
851 foreach my $dir ( split(/:/, $path) ) {
852 my $file = File::Spec->catfile($dir, $prog);
853 return $file if ( -x $file );
861 open(C, $file) || die("can't open $file");
863 my($out, @conf, $var);
868 if ( /^#/ && !defined($endLine) ) {
873 $allVars->{$var} = @conf if ( defined($var) );
883 } elsif ( /^\s*\$Conf\{([^}]*)/ ) {
885 if ( defined($var) ) {
886 $allVars->{$var} = @conf if ( defined($var) );
896 $endLine = $1 if ( /^\s*\$Conf\{[^}]*} *= *<<(.*);/ );
897 $endLine = $1 if ( /^\s*\$Conf\{[^}]*} *= *<<'(.*)';/ );
899 $endLine = undef if ( defined($endLine) && /^\Q$endLine[\n\r]*$/ );
904 $allVars->{$var} = @conf if ( defined($var) );
911 return (\@conf, $allVars);
916 my($old, $oldVars, $new, $newVars) = @_;
921 # Find which config parameters are not needed any longer
923 foreach my $var ( @$old ) {
924 next if ( !defined($var->{var}) || defined($newVars->{$var->{var}}) );
925 #print(STDERR "Deleting old config parameter $var->{var}\n");
929 # Find which config parameters are new
931 foreach my $var ( @$new ) {
932 next if ( !defined($var->{var}) );
933 if ( defined($oldVars->{$var->{var}}) ) {
934 $posn = $oldVars->{$var->{var}};
936 #print(STDERR "New config parameter $var->{var}: $var->{text}\n");
937 push(@{$old->[$posn]{new}}, $var);
941 # Create merged config file
943 foreach my $var ( @$old ) {
944 next if ( $var->{delete} );
946 foreach my $new ( @{$var->{new}} ) {
955 my($question, $default, $option) = @_;
957 $default = $opts{$option} if ( defined($opts{$option}) );
958 if ( $opts{batch} ) {
959 print("$question [$default]\n");
962 print("$question [$default]? ");
964 $reply =~ s/[\n\r]*//g;
965 return $reply if ( $reply !~ /^$/ );
973 configure.pl [options]
977 configure.pl is a script that is used to install or upgrade a BackupPC
978 installation. It is usually run interactively without arguments. It
979 also supports a batch mode where all the options can be specified
980 via the command-line.
982 For upgrading BackupPC you need to make sure that BackupPC is not
983 running prior to running BackupPC.
985 Typically configure.pl needs to run as the super user (root).
993 Run configure.pl in batch mode. configure.pl will run without
994 prompting the user. The other command-line options are used
995 to specify the settings that the user is usually prompted for.
997 =item B<--bin-path PROG=PATH>
999 Specify the path for various external programs that BackupPC
1000 uses. Several --bin-path options may be specified. configure.pl
1001 usually finds sensible defaults based on searching the PATH.
1004 --bin-path PROG=PATH
1006 where PROG is one of perl, tar, smbclient, nmblookup, rsync, ping,
1007 df, ssh, sendmail, hostname, split, par2, cat, gzip, bzip2 and
1008 PATH is that full path to that program.
1012 --bin-path cat=/bin/cat --bin-path bzip2=/home/user/bzip2
1014 =item B<--config-path CONFIG_PATH>
1016 Path to the existing config.pl configuration file for BackupPC.
1017 This option should be specified for batch upgrades to an
1018 existing installation. The option should be omitted when
1019 doing a batch new install.
1021 =item B<--cgi-dir CGI_DIR>
1023 Path to Apache's cgi-bin directory where the BackupPC_Admin
1024 script will be installed. This option only needs to be
1025 specified for a batch new install.
1027 =item B<--data-dir DATA_DIR>
1029 Path to the BackupPC data directory. This is where all the backup
1030 data is stored, and it should be on a large file system. This option
1031 only needs to be specified for a batch new install.
1035 --data-dir /data/BackupPC
1037 =item B<--dest-dir DEST_DIR>
1039 An optional prefix to apply to all installation directories.
1040 Usually this is not needed, but certain auto-installers like
1041 to stage an install in a temporary directory, and then copy
1042 the files to their real destination. This option can be used
1043 to specify the temporary directory prefix. Note that if you
1044 specify this option, BackupPC won't run correctly if you try
1045 to run it from below the --dest-dir directory, since all the
1046 paths are set assuming BackupPC is installed in the intended
1051 Print a brief help message and exits.
1053 =item B<--hostname HOSTNAME>
1055 Host name (this machine's name) on which BackupPC is being installed.
1056 This option only needs to be specified for a batch new install.
1058 =item B<--html-dir HTML_DIR>
1060 Path to an Apache html directory where various BackupPC image files
1061 and the CSS files will be installed. This is typically a directory
1062 below Apache's DocumentRoot directory. This option only needs to be
1063 specified for a batch new install.
1067 --html-dir /usr/local/apache/htdocs/BackupPC
1069 =item B<--html-dir-url URL>
1071 The URL (without http://hostname) required to access the BackupPC html
1072 directory specified with the --html-dir option. This option only needs
1073 to be specified for a batch new install.
1077 --html-dir-url /BackupPC
1079 =item B<--install-dir INSTALL_DIR>
1081 Installation directory for BackupPC scripts, libraries, and
1082 documentation. This option only needs to be specified for a
1087 --install-dir /usr/local/BackupPC
1091 Prints the manual page and exits.
1093 =item B<--uid-ignore>
1095 configure.pl verifies that the script is being run as the super user
1096 (root). Without the --uid-ignore option, in batch mode the script will
1097 exit with an error if not run as the super user, and in interactive mode
1098 the user will be prompted. Specifying this option will cause the script
1099 to continue even if the user id is not root.
1103 For a standard interactive install, run without arguments:
1107 For a batch new install you need to specify answers to all the
1108 questions that are normally prompted:
1112 --cgi-dir /var/www/cgi-bin/BackupPC \
1113 --data-dir /data/BackupPC \
1115 --html-dir /var/www/html/BackupPC \
1116 --html-dir-url /BackupPC \
1117 --install-dir /usr/local/BackupPC
1119 For a batch upgrade, you only need to specify the path to the
1122 configure.pl --batch --config-path /data/BackupPC/conf/config.pl
1126 Craig Barratt <cbarratt@users.sourceforge.net>
1130 Copyright (C) 2001-2004 Craig Barratt.
1132 This program is free software; you can redistribute it and/or modify
1133 it under the terms of the GNU General Public License as published by
1134 the Free Software Foundation; either version 2 of the License, or
1135 (at your option) any later version.