BackupPC – gestión de backups. Guía de instalación para bobos.
¿Qué es BackupPC?
El otro día tuve la ocasión de ver en funcionamiento una herramienta estupenda para gestionar copias de seguridad mediante un interfaz web (o por via de comandos). Se llama BackupPC y es libre.
Las opciones de personalización son infinitas, no sólo a nivel de compresión de los backups, sino también la posibilidad de gestionar de forma cómoda los privilegios de acceso, quién puede hacer cada backup, cómo se hace cada backup (rsync sobre ssh, samba…).
Vaya, que me encantó. Paso, por tanto, a comentaros cómo instalar y configurar esta herramienta. He de decir que esta guía la he hecho “para mi” -por si tengo que replicar esta instalación en otras máquinas- por lo que es incompleta, imperfecta y seguro que tiene errores o cosas que se pueden mejorar.
** Nota tras terminar la instalación: habría sido más conveniente instalar la herramienta como usuario apache directamente… pero si seguís las instrucciones que doy, también funcionará asi.
Configurando BackupPC en Red Hat EL 5 – descargando source, instalando pre-requisitos y creando directorios
Asumo que tendréis instalado perl, apache, etc.
En mi caso, lo hago sobre perl 5.8.8 para 64bits.
[root@olmo BackupPC]# perl --version This is perl, v5.8.8 built for x86_64-linux-thread-multi Copyright 1987-2006, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
Primero descargamos el tar.gz con el instalador. Lo podemos hacer desde:
http://sourceforge.net/projects/backuppc/files/backuppc/3.1.0/BackupPC-3.1.0.tar.gz/download.
[root@olmo BackupPC-3.1.0]# yum install perl-suidperl [root@olmo BackupPC-3.1.0]# /usr/sbin/adduser backuppc [root@olmo www]# mkdir /var/www/cgi-bin/BackupPC [root@olmo cgi-bin]# mkdir /var/www/icons/BackupPC [root@olmo backuppc-install]# cd /home/miguel/backuppc-install [root@olmo backuppc-install]# tar zvxf BackupPC-3.1.0.tar.gz
El proceso de instalación (todo el output)
[root@olmo BackupPC-3.1.0]# 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: /etc/BackupPC/config.pl). Otherwise, just hit return. --> Full path to existing main 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]? Please tell me the hostname of the machine that BackupPC will run on. --> BackupPC will run on host [olmo.unizar.es]? 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. The data directories and files will have group read permission, so group members can access backup files. --> BackupPC should run as user [backuppc]? Please specify an install directory for BackupPC. This is where the BackupPC scripts, library and documentation will be installed. --> Install directory (full path) [/usr/local/BackupPC]? Please specify a data directory for BackupPC. This is where all the PC backup data is stored. This file system needs to be big enough to accommodate all the PCs you expect to backup (eg: at least several GB per machine). --> Data directory (full path) [/data/BackupPC]? /img/BackupPC BackupPC can compress pool files, providing around a 40% reduction in pool size (your mileage may vary). Specify the compression level (0 turns off 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]? 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 somewhere 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/icons/BackupPC --> URL for image directory (omit http://host; starts with '/') []? /icons/BackupPC Ok, we're about to: - install the binaries, lib and docs in /usr/local/BackupPC, - create the data directory /img/BackupPC, - create/update the config.pl file /etc/BackupPC/config.pl, - optionally install the cgi-bin interface. --> Do you want to continue? [y]? Created /usr/local/BackupPC/bin Created /usr/local/BackupPC/doc Created /usr/local/BackupPC/lib/BackupPC/CGI Created /usr/local/BackupPC/lib/BackupPC/Config Created /usr/local/BackupPC/lib/BackupPC/Lang Created /usr/local/BackupPC/lib/BackupPC/Storage Created /usr/local/BackupPC/lib/BackupPC/Xfer Created /usr/local/BackupPC/lib/BackupPC/Zip Created /img/BackupPC Created /img/BackupPC/pool Created /img/BackupPC/cpool Created /img/BackupPC/pc Created /img/BackupPC/trash Created /etc/BackupPC Created /var/log/BackupPC Installing binaries in /usr/local/BackupPC/bin Installing library in /usr/local/BackupPC/lib Installing images in /var/www/icons/BackupPC Making init.d scripts Installing docs in /usr/local/BackupPC/doc Installing config.pl and hosts in /etc/BackupPC PING localhost.localdomain (127.0.0.1) 56(84) bytes of data. 64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.140 ms --- localhost.localdomain ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.140/0.140/0.140/0.000 ms 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, /etc/BackupPC/config.pl, and make sure all the settings are correct. In particular, you will need to set $Conf{CgiAdminUsers} so you have administration privileges in the CGI interface. - Edit the list of hosts to backup in /etc/BackupPC/hosts. - Read the documentation in /usr/local/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. If this is an upgrade and you are using mod_perl, you will need to restart Apache. Otherwise it will have stale code. - 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!
Los pasos post-instalación
*Comprobar en /etc/httpd/modules/ que tenemos mod_perl.so
* Ahora en la configuracion del apache vemos que esté cargado el mod_perl
[root@olmo cgi-bin]# more /etc/httpd/conf/httpd.conf | grep mod_perl LoadModule perl_module modules/mod_perl.so
* Añadir la configuración necesaria de apache…
Alias /bpc/ "/var/www/cgi-bin/BackupPC/" <Directory "/var/www/cgi-bin/BackupPC/"> Options All SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI AddHandler perl-script .pl AddType application/x-perl-httpd .pl PerlHandler ModPerl::Registry PerlSendHeader On </Directory>
Si seguimos estos pasos lo normal es que al invocar la url del backuppc nos salgan errores:
Error: Unable to read config.pl or language strings!! Note: $ENV{REMOTE_USER} is not set, which could mean there is an installation problem. BackupPC_Admin expects Apache to authenticate the user and pass their user name into this script as the REMOTE_USER environment variable. See the documentation.
Esto pasa por los permisos del /etc/BackupPC/... porque el usuario apache no es capaz ni de leer ni de ejecutar el /etc/BackupPC/config.pl
Por tanto vamos a cambiar estos permisos…
[root@olmo cgi-bin]# chmod o+rx /etc/BackupPC/ [root@olmo cgi-bin]# chmod o+rx /etc/BackupPC/config.pl
Ahora la web ya carga, aunque pone:
"Error: Wrong user: my userid is 48, instead of 502(backuppc)
This script needs to run as the user specified in $Conf{BackupPCUser}, which is set to backuppc.
This is an installation problem. If you are using mod_perl then it appears that Apache is not running as user backuppc. If you are not using mod_perl, then most like setuid is not working properly on BackupPC_Admin. Check the permissions on /var/www/cgi-bin/BackupPC/BackupPC_Admin and look at the documentation. "Vamos al config.pl y cambiamos la $Conf{BackupPCUser} al usuario apache.
F5 en la web y da este error…
[root@olmo cgi-bin]# 2010-03-23 12:33:32 Can't create a test hardlink between a file in /img/BackupPC/pc and /img/BackupPC/cpool. Either these are different file systems, or this file system doesn't support hardlinks, or these directories don't exist, or there is a permissions problem, or the file system is out of inodes or full. Use df, df -i, and ls -ld to check each of these possibilities. Quitting... [1]+ Exit 1 sudo -u apache /usr/bin/perl /usr/local/BackupPC/bin/BackupPC -d
Esto pasaba porque estaban a cargo de backuppc y los cambiamos a apache:
[root@olmo cgi-bin]# ll /img total 44 drwxr-x--- 6 backuppc backuppc 4096 Mar 23 12:05 BackupPC [root@olmo cgi-bin]# chown -R apache:apache /img/BackupPC/
Ahora ya nos quita la segunda parte del error, pero no tenemos configurado el fichero host… Lo configuramos con nuestros hostnames, si estos tienen IP estática o dinámica (0 ó 1) y los user “encargados” de cada host. ¡Ojo al editar este fichero si lo hacemos como root, que se macharán los permisos!
vi /etc/BackupPC/hosts
Para que arranque con cada boot de la máquina sigue las instrucciones:
RedHat Linux: ============ When configure.pl is run, the script linux-backuppc is created. It should be copied to /etc/init.d/backuppc: cp /home/miguel/backuppc-install/BackupPC-3.1.0/init.d/linux-backuppc /etc/init.d/backuppc After copying it, you can test it by running these commands as root: /etc/init.d/backuppc start /etc/init.d/backuppc status /etc/init.d/backuppc stop You should then run the following commands as root: chkconfig --add backuppc chkconfig --level 345 backuppc on chkconfig --list backuppc This will auto-start backuppc at run levels 3, 4 and 5.
¡Notar que en el fichero /etc/init.d/backuppc hay que cambiar el usuario backuppc por apache para que funcione todo!
Luego hemos cambiado en el config.pl dónde loggea (lo hemos pasado al /usr/local/BackupPC/log) y lo hemos creado con apache:apache.
Ahora arrancamos el asunto:
/etc/init.d/backuppc start
Sale más o menos, pero vemos en el log que hay problemas…
Backup failed on olmo.unizar.es (File::RsyncP module doesn't exist)
Vamos a instalar ese módulo de perl con CPAN:
Como root ejecutar:
cpan cpan> install File::RsyncP
Luego restart apache y backuppc:
/etc/init.d/httpd restart /etc/init.d/backuppc restart
Pasos opcionales post-instalación
Un plus: se puede colocar el LDAP para validar el acceso por web. Además se permite configurar en el config.pl qué usuarios acceden a administrar cada servidor.
Editamos estas variables en el fichero config.pl (si ponemos * lo dejamos a todos los usuarios, sino solo a user1, user2, p ejemplo):
$Conf{CgiAdminUserGroup} = ''; $Conf{CgiAdminUsers} = 'user1, user2';
Además en la config del apache habrá que meter las siguientes líneas dentro del directory:
# autenticar contra el LDAP AuthType Basic AuthBasicProvider ldap AuthName "Autenticacion OpenLDAP " AuthzLDAPAuthoritative off AuthLDAPURL "ldap://ldapmail.unizar.es/ou=Accounts,dc=unizar,dc=es?uid?sub?(objectClass=person)" Require valid-user
Y restartar todo, como siempre
Ajustar SSH para rsync root
Se puede consultar http://backuppc.sourceforge.net/faq/ssh.html
Más documentación (oficial) por si esto te supera
http://backuppc.sourceforge.net/faq/debugCGI.html#i_get_the_error_error__unable_to_read_config_pl_or_language_strings____how_do_i_fix_this
http://backuppc.sourceforge.net/faq/BackupPC.html
http://backuppc.sourceforge.net/faq/ssh.html
Related posts:
Te hago una consulta, segui todos los pasos anda el backuppc pero no me muestra las imagenes en la web.
Revise el parametro CgiImageDir y CgiImageDirURL y estan apuntados correctamente al directorio de las imagenes.
Que no corresponde al document root indicado en el .conf del apache.
Alguna idea?
Buenas crack buscando el tutorial di con tu página jeje
Buen tutorial aunque por suerte ya teniamos apache y perl por el server asi que nada le meti apt get backuppc y htpasswd /etc/backuppc/htpasswd backuppc y listo.
Ahora me pondre con la configuración a ver si me
De todas formas te cuento como lo hice.
Partiendo de que como era un dedicado ya teniamos apache y perl instalados…
y ya podemos entrar por localhost/backuppc o dominio/backuppc.
En fin ahora a ver si nos apañamos para configurar y a por el openssl, ya iremos hablando si sale algo
joer no se como he escrito el comentario que no lo entiendo ni yo casi :S