Sunday, 16 February 2014

How to setup BackUp PC in centos

BackupPC is an entirely disk-based backup and recovery system.

Backup PC Support any client OS and has a Web interface to allows user control of and access to backups.

How BackupPC Works, Install BackupPC server

The BackupPC model has one user per client. BackupPC emails the owner if it cannot back up the client after a configurable time, and the owner can control restores using the web interface.

# yum install perl-Compress-Zlib perl-Archive-Zip perl-File-RsyncP perl-XML-RSS mod_perl perl httpd

# wget

if error came
error: Failed dependencies:
    perl(Time::ParseDate) is needed by backuppc-3.1.0-1.el5.centos.i386


# yum whatprovides "perl(Time::ParseDate)"

# yum install perl-Time-modules

# rpm -ivh backuppc-3.1.0-1.el5.centos.i386.rpm

1. Add user backuppc to your machine, User backuppc will be created upon installation. Change apache user to backuppc.

 # vim /etc/httpd/conf/httpd.conf

     Change ‘User apache‘ to ‘User backuppc

2. Edit file /etc/httpd/conf.d/backuppc.conf

# vim /etc/httpd/conf.d/backuppc.conf

change ‘Allow from‘ to ‘Allow from all‘

3. Create password for cgi-bin admin user

# htpasswd -c /var/lib/backuppc/passwd/htpasswd admin

passwd: backup

4. Edit backuppc config file

# vi /etc/BackupPC/

 Find and change accordingly

$Conf{ServerHost} = 'localhost';
$Conf{SplitPath} = '/usr/bin/split';
$Conf{CatPath} = '/bin/cat';
$Conf{GzipPath} = '/bin/gzip';
$Conf{Bzip2Path} = '/usr/bin/bzip2';
$Conf{BackupPCUser} = 'backuppc';
$Conf{TopDir} = '/var/lib/backuppc';
$Conf{ConfDir} = '/etc/BackupPC';
$Conf{LogDir} = '/var/log/BackupPC';
$Conf{InstallDir} = '/usr';
$Conf{CgiDir} = '/usr/share/backuppc/cgi-bin';
$Conf{ServerInitdPath} = '/etc/init.d/backuppc';
$Conf{ServerInitdStartCmd} = '$sshPath -q -x -l root $serverHost$serverInitdPath start';
$Conf{SshPath} = '/usr/bin/ssh';
$Conf{NmbLookupPath} = '/usr/bin/nmblookup';
$Conf{PingPath} = '/bin/ping';
$Conf{CgiAdminUsers} = 'admin';

5.Grant passwordless sudo for user backuppc to run /bin/gtar and  /bin/tar

# visudo

Add these entries :

Defaults !lecture  # to disable lecture

backuppc ALL=NOPASSWD:/bin/gtar,/bin/tar   # enable user backuppc to run /bin/tar and /bin/gtar without authentication.

Comment this entry,

# Defaults requiretty

Restart apache and backuppc service

# /etc/init.d/httpd start

# /etc/init.d/backuppc restart

Open your browser and point it to ‘http://backuppc_server_ip/backuppc‘ and you should see the backuppc web interface

After this, you have to do almost all the configuration through the web interface. To test, you can run localhost backup first. You have to create the host, fill up all the setting and you are ready to go. Record the host and ip in /etc/hosts.

# vim /etc/hosts cloudcc  ---------. add every machines host name here.

Once you have hosts with backups, there will be some very useful graphs displaying pool storage size.

Changing the Backuppc Pool Directory

By default, all your backups are stored at /var/lib/backuppc. However, I wish to store my backups on another disk drive that has a lot more storage than my system disk.  To do this we need to create a soft link from the default backup directory to whatever directory you wish to store the backups.  You will notice that we create two directories called "pc" and "cpool".

"pc" is where all the files are stored, and those two directories were originally causing permission issues.

# cd /var/lib/backuppc

# sudo mkdir pc cpool    ----- done this only if there is no 'pc' and 'cpool' directories.

# sudo chown -R backuppc * ----> check the ownership of directories in /vae/lib/backuppc/

If you have problems, it may be a permissions issue:
# sudo chmod -R 777 backuppc

I would recommend not leaving the permissions wide open... just make sure it is a permission error and slowly restrict the permissions until everything works correctly.  Now the backups should redirect directly to your new drive.

Adding Hosts in BackupPC

Now we need to add some hosts for backup.  Select "Edit Config" from the left menu.  Click on the "Hosts" tab.  Here we can add hosts for backup. I personally have DNS reservations for all of my hosts, so I can add by IP, however if your hosts will have different IP's I would highly recommend checking the DHCP option. As long as your hosts are registered in DNS backuppc can track them and back them up no matter where they are.  Add the hosts you will be backing up, hit save, and then click on the "Xfer" tab.

Setting Default Xfer Options (for Windows)

we need to set the default transfer settings. This is mostly a setting for large networks of pc's that are set up the same way, which makes it unnecessary for the admin to configure each pc individually. Click on "Edit Config" on the menu on the left, and select "Xfer" from the top menu.  How you set this up depends entirely on your network setup.  I have two Windows 7 PC's, so I will be setting the default settings for a SMB share.

The above screen shot shows the settings I set for the default.  I chose SMB for the transfer method.  The advantage of using SMB is that it is already built into Windows... which is good from an ease of use scenario, but is not as good from a security standpoint.  For the SMB share name, I added the administrative C$ share, which is the entire C$.  In this instance I also should have set default "Include/Exclude" settings.  This part is not extremely intuitive.

To ensure that only the right files are backed up, we need to add first the "SmbShareName" to the "New Key" field, and click "Add".  Once we have added the base share name, we can add the individual paths that we wish to backup.  You will notice above that I told backuppc to backup only the "Users" directory under the C$ share.  So now, instead of backing up the entire OS, backuppc will only backup "C:\Users", which is a much better option. You can obviously add more than one folder.  You can also add folders to exclude, which is a nice option as well. Notice that the "Override" box is checked... that just means that this host differs from the default configuration in this area.

Backing up the Localhost

The easiest way to backup your linux localhost is through "tar".  In the top host drop-drop menu, select "localhost".  Click on "Edit Config" which will enter the host-specific configuration.  Select "tar" and from the "XferMethod" drop-down menu. Next, we need to select the tar share names that we wish to back up.  Since the localhost is not running a whole lot of services, and is not mission critical, I am only backing up the /var and /etc directories.  Go ahead and save the config and you should be ready to backup your localhost!.

Samba Configuration

----> $Conf{XferMethod} = 'smb';
       What transport method to use to backup each host. If you have a mixed set of WinXX and linux/unix hosts you will need to override this in the per-PC

----> $Conf{XferLogLevel} = 1;
       Level of verbosity in Xfer log files. 0 means be quiet, 1 will give will give one line per file, 2 will also show skipped files on incrementals, higher values give more output.

----> $Conf{ClientCharset} = '';
        Filename charset encoding on the client. BackupPC uses utf8 on the server for filename encoding. If this is empty, then utf8 is assumed and client filenames will not be modified. If set to
         a different encoding then filenames will converted to/from utf8 automatically during backup and restore.

----> $Conf{SmbShareName} = 'C$';
        Name of the host share that is backed up when using SMB. This can be a string or an array of strings if there are multiple shares per host. Examples:
$Conf{SmbShareName} = 'c';          # backup 'c' share
$Conf{SmbShareName} = ['c', 'd'];   # backup 'c' and 'd' shares

   This setting only matters if $Conf{XferMethod} = 'smb'.

----> $Conf{SmbShareUserName} = '';

Smbclient share user name. This is passed to 
 smbclient's -U argument.

----> $Conf{SmbSharePasswd} = '';
        Smbclient share password. This is passed to smbclient via its PASSWD environment variable. There are several ways you can tell BackupPC the smb share password.

----> $Conf{SmbClientPath} = '';
 Full path for smbclient. Security caution: normal users should not allowed to write to this file or directory.

smbclient is from the Samba distribution. smbclient is used to actually extract the incremental or full dump of the share filesystem from the PC.

Tar Configuration

Which host directories to backup when using tar transport. This can be a string or an array of strings if there are multiple directories to backup per host. Examples:

$Conf{TarShareName} = '/';                  # backup everything
$Conf{TarShareName} = '/home';              # only backup /home
$Conf{TarShareName} = ['/home', '/src'];    # backup /home and /src

The fact this parameter is called 'TarShareName' is for historical consistency with the Smb transport options. You can use any valid directory on the client: there is no need for it to correspond to any Smb share or device mount point.

you can also use $Conf{BackupFilesOnly} to specify a specific list of directories to backup. It's more efficient to use this option instead of $Conf{TarShareName} since a new tar is run for each entry in $Conf{TarShareName}.

On the other hand, if you add --one-file-system to $Conf{TarClientCmd} you can backup each file system separately, which makes restoring one bad file system easier. In this case you would list all of the mount points here, since you can't get the same result with $Conf{BackupFilesOnly}:

$Conf{TarShareName} = ['/', '/var', '/data', '/boot'];

No comments:

Post a Comment