BackupPC

Posted by Planet Malaysia on May 11, 2006

advertisement

Just to share about BackupPC here.

BackupPC is a high-performance, enterprise-grade system for backing up Linux and WinXX PCs and laptops to a server’s disk. BackupPC is highly configurable and easy to install and maintain.

BackupPC

It’s given the ever decreasing cost of disks and raid systems, it is now practical and cost effective to backup a large number of machines onto a server’s local disk or network storage. This is what BackupPC does. For some sites, this might be the complete backup solution. For other sites, additional permanent archives could be created by periodically backing up the server to tape. A variety of Open Source systems are available for doing backup to tape.

BackupPC is written in Perl and extracts backup data via SMB using Samba, tar over ssh/rsh/nfs, or rsync. It is robust, reliable, well documented and freely available as Open Source on SourceForge.

I hope this “installation guide” will help you to install BackupPC on your system in a Linux Server, using RSYNC ONLY and you are advise to go through BackupPC document first, before to start installing BackupPC.

I’m using “root” privileges to install all these:

OS: Red Hat Enterprise OR Fedora Core 4
Backup method: RSYNC

1.Backup Server
Name: backupserver
IP: 192.168.1.2
RAM: 512MB
Processor: Pentium IV
HDD: hda – 400GB

2.Backup Clients
Name: data
IP: 192.168.1.1
HDD: hda – O/s – RHEL4, 40GB

3.Create new user
#useradd backuppc
#passwd backuppc
{enter your passwd}

4.Install Perl required module before install backupPC.
Install Compress::Zlib
Install Archive::Zip
Install File::RsyncP

5.Download latest version from BackupPC web site.

6.Untar the source
# tar xvzf /home/bimal/BackupPC-x.x.x.tar.gz

7.cd BackupPC-x.x.x

8.Download BackupPC Patch and Apply BackupPC Patch
#cp BackupPC-x.x.xpl1.diff .
# patch p0 < BackupPC-x.x.xpl1.diff

9.Installation start
# perl configure.pl
Is this a new installation or upgrade for BackupPC? If this is
an upgrade please tell me the full path of the existing BackupPC
configuration file (eg: /xxxx/conf/config.pl). Otherwise, just
hit return.

--> Full path to existing conf/config.pl []?

I found the following locations for these programs:

bzip2 => /usr/bin/bzip2
cat => /bin/cat
df => /bin/df
gtar/tar => /bin/gtar
gzip => /bin/gzip
hostname => /bin/hostname
nmblookup => /usr/bin/nmblookup
par2 =>
perl => /usr/bin/perl
ping => /bin/ping
rsync => /usr/bin/rsync
sendmail => /usr/sbin/sendmail
smbclient => /usr/bin/smbclient
split => /usr/bin/split
ssh/ssh2 => /usr/bin/ssh

–> Are these paths correct? [y]?y

Please tell me the hostname of the machine that BackupPC will run on.

–> BackupPC will run on host[backupserver]?192.168.1.2

BackupPC should run as a dedicated user with limited privileges. You
need to create a user. This user will need read/write permission on
the main data directory and read/execute permission on the install
directory (these directories will be setup shortly).

The primary group for this user should also be chosen carefully.
By default the install directories will have group write permission.
The data directories and files will have group read permission but
no other permission.

–> BackupPC should run as user [backuppc]?backuppc

Please specify an install directory for BackupPC. This is where the
BackupPC scripts, library and documentation will be installed.

–> Install directory (full path) []?/data/backuppc

Please specify a data directory for BackupPC. This is where the
configuration files, LOG files and all the PC backups are stored.
This file system needs to be big enough to accommodate all the
PCs you expect to backup (eg: at least 1-2GB per machine).

–> Data directory (full path) []?/data/backuppc_data

BackupPC can compress pool files, providing around a 40% reduction in pool size (your mileage may vary). Specify the compression level (0 turnsoff compression, and 1 to 9 represent good/fastest to best/slowest). The recommended values are 0 (off) or 3 (reasonable compression and speed). Increasing the compression level to 5 will use around 20% more cpu time and give perhaps 2-3% more compression.

–> Compression level [3]? 3

BackupPC has a powerful CGI perl interface that runs under Apache.
A single executable needs to be installed in a cgi-bin directory.
This executable needs to run as set-uid backuppc, or
it can be run under mod_perl with Apache running as user backuppc.

Leave this path empty if you don’t want to install the CGI interface.

–> CGI bin directory (full path) []? /var/www/cgi-bin/backuppc

BackupPC’s CGI script needs to display various GIF images that
should be stored where Apache can serve them. They should be
placed somewher under Apache’s DocumentRoot. BackupPC also
needs to know the URL to access these images. Example:

Apache image directory: /usr/local/apache/htdocs/BackupPC
URL for image directory: /BackupPC

The URL for the image directory should start with a slash.

–> Apache image directory (full path) []?/var/www/html/BackupPC

–> URL for image directory (omit http://host; starts with ‘/’) []?/BackupPC

Ok, we’re about to:

– install the binaries, lib and docs in /data/backuppc,
– create the data directory /data/backuppc_data,
– create/update the config.pl file /data/backuppc_data/conf,
– optionally install the cgi-bin interface.

–> Do you want to continue? [y]?y

Created /data/backuppc/bin
Created /data/backuppc/doc
Created /data/backuppc/lib/BackupPC/CGI
Created /data/backuppc/lib/BackupPC/Lang
Created /data/backuppc/lib/BackupPC/Xfer
Created /data/backuppc/lib/BackupPC/Zip
Created /var/www/html/BackupPC
Created /data/backuppc_data/.
Created /data/backuppc_data/conf
Created /data/backuppc_data/pool
Created /data/backuppc_data/cpool
Created /data/backuppc_data/pc
Created /data/backuppc_data/trash
Created /data/backuppc_data/log
Installing binaries in /data/backuppc/bin
Installing library in /data/backuppc/lib
Installing images in /var/www/html/BackupPC
Making init.d scripts
Installing docs in /data/backuppc/doc
Installing config.pl and hosts in /data/backuppc_data/conf
PING backupserver (127.0.0.1) 56(84) bytes of data.
64 bytes from backupserver (127.0.0.1): icmp_seq=0ttl=64 time=0.043 ms

— backupserver ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.043/0.043/0.043/0.000 ms, pipe 2
Installing cgi script BackupPC_Admin in /var/www/cgi-bin/backuppc

Ok, it looks like we are finished. There are several more things you
will need to do:

– Browse through the config file, /data/backuppc_data/conf/config.pl,
and make sure all the settings are correct. In particular, you
will need to set the smb share password and user name, backup
policies and check the email message headers and bodies.

– Edit the list of hosts to backup in /data/backuppc_data/conf/hosts.

– Read the documentation in /data/backuppc/doc/BackupPC.html.
Please pay special attention to the security section.

– Verify that the CGI script BackupPC_Admin runs correctly. You might need to change the permissions or group ownership of BackupPC_Admin.

– BackupPC should be ready to start. Don’t forget to run it
as user backuppc! The installation also contains an
init.d/backuppc script that can be copied to /etc/init.d
so that BackupPC can auto-start on boot. This will also enable
administrative users to start the server from the CGI interface.
See init.d/README.

Enjoy!

10.Edit Apache setting
#vi /etchttpd/conf/httpd.conf
User backuppc
group backuppc

ServerName 192.168.1.2 OR ServerName backupserver (if name is resolvable)


SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
Order deny,allow
Deny from all
Allow from 192.168.1
AllowOverride Indexes AuthConfig
AuthName \”Backup Admin\”
AuthType Basic
AuthUserFile /var/www/cgi-bin/.backuppcpsswd
Require valid-user

11.Create a Admin Authorisation password
#htpasswd c /var/www/cgi-bin/.backuppcpsswd admin
New password:
Re-type new password:
Updating password for user admin

12.Change Permissions
#chmod 644 /var/www/cgi-bin/.backuppcpsswd
#chmod u-s /var/www/cgi-bin/backuppc/BackupPC_Admin

13.Startup Script
#cp /BackupPC-x.x.0/init.d/src/linux-backuppc /etc/rc.d/init.d/backuppc

#vi /etc/rc.d/init.d/backuppc
Change BACKUPPCUSER to backuppc
Change INSTALLDIR to /data/backuppc

#chkconfig –add backuppc
#chkconfig –level 345 backuppc on

14.Change BackupPC configuration setting
$Conf{ServerHost} = ‘backupserver’;
$Conf{ServerPort} = -1;
$Conf{ServerMesgSecret} = ”;
$Conf{MyPath} = ‘/bin’;
$Conf{UmaskMode} = 027;
$Conf{WakeupSchedule} = [1..23];
$Conf{MaxBackups} = 4;
$Conf{MaxUserBackups} = 4;
$Conf{MaxPendingCmds} = 10;
$Conf{MaxBackupPCNightlyJobs} = 2;
$Conf{BackupPCNightlyPeriod} = 1;
$Conf{MaxOldLogFiles} = 14;
$Conf{DfPath} = ‘/bin/df’;
$Conf{DfCmd} = ‘$dfPath $topDir’;
$Conf{SplitPath} = ‘/usr/bin/split’;
$Conf{ParPath} = ‘/usr/local/bin/par2′;
$Conf{CatPath} = ‘/bin/cat’;
$Conf{GzipPath} = ‘/bin/gzip’;
$Conf{Bzip2Path} = ‘/usr/bin/bzip2′;
$Conf{DfMaxUsagePct} = 95;
$Conf{TrashCleanSleepSec} = 300;
$Conf{DHCPAddressRanges} = [];
$Conf{BackupPCUser} = ‘backuppc’;
$Conf{CgiDir} = ‘/var/www/cgi-bin/backuppc’;
$Conf{InstallDir} = ‘/data/backuppc’;
$Conf{BackupPCUserVerify} = 1;
$Conf{HardLinkMax} = 31999;
$Conf{TarShareName} = ‘/’;
$Conf{FullPeriod} = 6.97;
$Conf{IncrPeriod} = 0.97;
$Conf{FullKeepCnt} = 4;
$Conf{FullKeepCntMin} = 1;
$Conf{FullAgeMax} = 90;
$Conf{IncrKeepCnt} = 6;
$Conf{IncrKeepCntMin} = 1;
$Conf{IncrAgeMax} = 30;
$Conf{PartialAgeMax} = 3;
$Conf{IncrFill} = 0;
$Conf{RestoreInfoKeepCnt} = 10;
$Conf{ArchiveInfoKeepCnt} = 10;
$Conf{BackupFilesOnly} = [ '/home' ];
$Conf{BackupFilesExclude} = undef;
$Conf{BlackoutBadPingLimit} = 3;
$Conf{BlackoutGoodCnt} = 7;
$Conf{BlackoutPeriods} = [
{
hourBegin => 23.8,
hourEnd => 23.9,
weekDays => [0, 1, 2, 3, 4, 5, 6],
},
];
$Conf{BackupZeroFilesIsFatal} = 0;
$Conf{XferMethod} = ‘rsync’;
$Conf{XferLogLevel} = 3;
$Conf{TarClientCmd} = ‘$sshPath -q -x -n -l root $host’
. ‘ $tarPath -c -v -f – -C $shareName+’
. ‘ –totals’;
$Conf{TarFullArgs} = ‘$fileList+’;
$Conf{TarIncrArgs} = ‘–newer=$incrDate+ $fileList+’;
$Conf{TarClientRestoreCmd} = ‘$sshPath -q -x -l root $host’
. ‘ $tarPath -x -p –numeric-owner –same-owner’
. ‘ -v -f – -C $shareName+’;
$Conf{TarClientPath} = ‘/bin/tar’;
$Conf{RsyncClientPath} = ‘/usr/bin/rsync’;
$Conf{RsyncClientCmd} = ‘$sshPath -q -x -l root $host $rsyncPath $argList+’;
$Conf{RsyncClientRestoreCmd} = ‘$sshPath -q -x -l root $host $rsyncPath $argList+’;
$Conf{RsyncShareName} = ‘/’;
$Conf{RsyncdClientPort} = 873;
$Conf{RsyncdUserName} = ”;
$Conf{RsyncdPasswd} = ”;
$Conf{RsyncdAuthRequired} = 1;
$Conf{RsyncCsumCacheVerifyProb} = 0.01;
$Conf{RsyncArgs} = [
'--numeric-ids',
'--perms',
'--owner',
'--group',
'--devices',
'--links',
'--times',
'--block-size=2048',
'--recursive',
'--exclude', 'boot',
'--exclude', 'dev',
'--exclude', 'lib',
'--exclude', 'misc',
'--exclude', 'opt',
'--exclude', 'proc',
'--exclude', 'sbin',
'--exclude', 'tmp',
'--exclude', 'var',
'--exclude', 'bin',
'--exclude', 'etc',
'--exclude', 'initrd',
'--exclude', 'lost+found',
'--exclude', 'mnt',
'--exclude', 'tftpboot',
'--exclude', 'usr',
];
$Conf{RsyncRestoreArgs} = [
'--numeric-ids',
'--perms',
'--owner',
'--group',
'--devices',
'--links',
'--times',
'--block-size=2048',
'--relative',
'--ignore-times',
'--recursive',
'--one-file-system',
];
$Conf{ArchiveDest} = ‘/tmp’;
$Conf{ArchiveComp} = ‘gzip’;
$Conf{ArchivePar} = 0;
$Conf{ArchiveSplit} = 0;
$Conf{ArchiveClientCmd} = ‘$Installdir/bin/BackupPC_archiveHost’
. ‘ $tarCreatePath $splitpath $parpath $host $backupnumber’
. ‘ $compression $compext $splitsize $archiveloc $parfile *’;
$Conf{SshPath} = ‘/usr/bin/ssh’;
$Conf{NmbLookupPath} = ‘/usr/bin/nmblookup’;
$Conf{NmbLookupCmd} = ‘$nmbLookupPath -A $host’;
$Conf{NmbLookupFindHostCmd} = ‘$nmbLookupPath $host’;
$Conf{FixedIPNetBiosNameCheck} = 0;
$Conf{PingPath} = ‘/bin/ping’;
$Conf{PingCmd} = ‘$pingPath -c 1 -w 3 $host’;
$Conf{ServerInitdPath} = ‘/etc/init.d/backuppc’;
$Conf{ServerInitdStartCmd} = ”;’$sshPath -q -x -l root $serverHost’
. ‘ $serverInitdPath start’
. ‘ < /dev/null >& /dev/null’;
$Conf{CompressLevel} = 3;
$Conf{PingMaxMsec} = 50;
$Conf{ClientTimeout} = 7200;
$Conf{MaxOldPerPCLogFiles} = 12;
$Conf{DumpPreUserCmd} = undef;
$Conf{DumpPostUserCmd} = undef;
$Conf{RestorePreUserCmd} = undef;
$Conf{RestorePostUserCmd} = undef;
$Conf{ArchivePreUserCmd} = undef;
$Conf{ArchivePostUserCmd} = undef;
$Conf{ClientNameAlias} = undef;
$Conf{PerlModuleLoad} = undef;
$Conf{SendmailPath} = ‘/usr/sbin/sendmail’;
$Conf{EMailNotifyMinDays} = 2.5;
$Conf{EMailFromUserName} = ‘backuppc’;
$Conf{EMailAdminUserName} = ‘alert@planetmy’;
$Conf{EMailUserDestDomain} = ‘alert@planetmy.com’;
$Conf{EMailNoBackupEverSubj} = undef;
$Conf{EMailNoBackupEverMesg} = undef;
$Conf{EMailNotifyOldBackupDays} = 7.0;
$Conf{EMailNoBackupRecentSubj} = undef;
$Conf{EMailNoBackupRecentMesg} = undef;
$Conf{EMailNotifyOldOutlookDays} = 5.0;
$Conf{EMailOutlookBackupSubj} = undef;
$Conf{EMailOutlookBackupMesg} = undef;
$Conf{CgiAdminUserGroup} = ‘admin’;
$Conf{CgiAdminUsers} = ‘admin’;
$Conf{CgiURL} = ‘http://bkupsvr/cgi-bin/backuppc/BackupPC_Admin’;
$Conf{Language} = ‘en’;
$Conf{CgiUserHomePageCheck} = ‘’;
$Conf{CgiUserUrlCreate} = ‘mailto:%s’;
$Conf{CgiDateFormatMMDD} = 0;
$Conf{CgiNavBarAdminAllHosts} = 1;
$Conf{CgiSearchBoxEnable} = 1;
$Conf{CgiNavBarLinks} = [
{
link => “?action=view&type=docs”,
lname => “Documentation”, # actually displays $Lang->{Documentation}
},
{
link => “link => "http://backuppc.sourceforge.net/faq",”,
name => “FAQ”, # displays literal “FAQ”
},
{
link => “link => "http://backuppc.sourceforge.net/faq",
name => “SourceForge”, # displays literal “SourceForge”
},
];
$Conf{CgiStatusHilightColor} = {
Reason_backup_failed => ‘#ffcccc’,
Reason_backup_done => ‘#ccffcc’,
Reason_no_ping => ‘#ffff99′,
Reason_backup_canceled_by_user => ‘#ff9900′,
Status_backup_in_progress => ‘#66cc99′,
};
$Conf{CgiHeaders} = ‘‘;
$Conf{CgiImageDir} = ‘/var/www/html/BackupPC’;
$Conf{CgiExt2ContentType} = { };
$Conf{CgiImageDirURL} = ‘/BackupPC’;
$Conf{CgiCSSFile} = ‘BackupPC_stnd.css’;

#vi /data/backuppc_data/conf/hosts
192.168.1.1 0 root admin,backuppc
192.168.1.2 0 root admin,backuppc

15.Every single node config.pl file
#mkdir /data/backuppc_data/pc/192.168.1.2
#vi /data/backuppc_data/pc/192.168.0.1/config.pl
$Conf{XferMethod} = ‘rsync’;
$Conf{XferLogLevel} = 3;
$Conf{RsyncClientPath} = ‘/usr/bin/rsync’;
$Conf{RsyncClientCmd} = ‘$sshPath -q -x -l root $host $rsyncPath $argList+’;
$Conf{RsyncClientRestoreCmd} = ‘$sshPath -q -x -l root $host $rsyncPath $argList+’;
$Conf{BackupFilesOnly} = [ '/data', '/home', '/etc' ];

#Note: Specific for any individual folder backup here.

16.Automating ssh for clients
#su – backuppc
#ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/backuppc/.ssh/id_rsa):
Created directory ‘/home/backuppc/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/backuppc/.ssh/id_rsa.
Your public key has been saved in /home/backuppc/.ssh/id_rsa.pub.
The key fingerprint is:
c8:20:b8:b2:63:4e:29:80:0e:fb:5e:c0:58:1b:2e:df backuppc@backupserver

now you need to put “id_rsa.pub” file(in fact, content) into clients “/root/.ssh/”
directory as(here i am using /root/.ssh/ as i will be taking backup of root privileged directory e.g. /home OR else you may need to adjust as per your requirement)

#scp /home/backuppc/.ssh/id_rsa.pub root@192.168.1.2:/root/.ssh/authorized_keys
#ssh -l root 192.168.1.2 whoami

17.Starting and Accesing BackupPC
# service httpd start
# service backuppc start

18.Logon to BackupPC Admin Page
Open any web browser

http://backupserver/cgi-bin/backuppc/BackupPC_Admin

Enter username: admin
Enter admin password:

19.Gongratulation! You are done!

Possibly Related Posts:


Comments

3 Responses to “BackupPC”

  1. miKo on May 11th, 2006 11:30 pm

    great! I was looking for this installation guide.

  2. Planet Malaysia Blog » Blog Archive » Linux Server Hack on May 28th, 2006 1:06 am

    [...] Backup your server [...]

  3. PlanetMalaysia Team on June 10th, 2006 6:09 pm

Leave a Reply




Planet Malaysia

  • Follow us on Twitter


  • web www.planetmy.com