Archive

Archive for the ‘openSuse’ Category

Windows backup with BackupPC

In my last post I explained how BackupPC is installed on a fresh openSuse 13.1 machine. Now it is time to setup a backup of a windows machine.

Defining hosts

Each host that has to be backuped has to be defined in the /etc/BackupPC/hosts file. As I will be using DHCP you have to put there the real host name (I will be using myhost). Add this line to the end of the hosts file:

myhost 1

The first parameter is the host name, and the second is the using DHCP flag.
To be sure this will work issue the following command on the prompt:

nmblookup -A X.Y.Z.W

Where X.Y.Z.W is the current IP of the myhost. You should get some lines like this back:

Looking up status of X.Y.Z.W
MYHOST - B
MYHOST - B

To define specific backup options for that host create a file named hostname.pl in /etc/BackupPC/pc/. In my case it is /etc/BackupPC/pc/myhost.pl . The content of the file is the following:
$Conf{XferMethod} = 'rsyncd';
$Conf{RsyncdUserName} = 'backuppc';
$Conf{RsyncdPasswd} = 'backuppc';
$Conf{RsyncShareName} = 'backup_folder';

I will be using rsyncd transfer method because it is the fastest one. The username/password I will configure on the myhost will be backuppc/backuppc and I will setup a share named backup_folder there.

We are still not done because BackupPC doesn’t know how to find the host by it’s name. It has to scan a IP range to find it first. To setup the IP range open the /etc/BackupPC/config.pl file and find the $Conf{DHCPAddressRanges} parameter. You can setup multiple ranges, but I need only one. I will use real numbers in this example:

$Conf{DHCPAddressRanges} = [
        {
            ipAddrBase => '192.168.1',
            first => 21,
            last  => 200,
        },
];

This will scann all IPs from 192.168.1.21 to 192.168.1.200 and check the hostname it gets back with the one you defined. It is a nice feature if you have an ADSL router with DHCP which changes your host IP address every time you ask a new lease.

You can now reload the configuration with:

service backuppc reload

Installation on the windows machine

The rsync daemon/service has to be installed on the windows machine. The easiest way is to use the one from the BackupPC repository. The current is this one. Once installed open the c:\rsyncd\rsyncd.conf and setup a share like this:

[backup_folder]
path = /cygdrive/c/Users/
comment = Users folder
strict modes = false
# Limit this share to just these users (needs to match $Conf{RsyncdUserName}
# and the c:/rsyncd/rsyncd.secrets files)
auth users = backuppc
# Password to match $Conf(RsyncdPasswd)
secrets file = c:/rsyncd/rsyncd.secrets
# List the IP address(es) of your BackupPC server(s), so only connections from these hosts will be allowed.
hosts allow = 192.168.1.1/24
# Allows restores to write to this share
read only = true
list = true

This will backup the Users folder which is usually the most important folder people put stuff in. The name in square brackets must match the one defined in the myhost.pl file. Multiple shares can be defined, with different options for each one. This one is readonly, accessible for user backuppc and limited to the local network (192.168.1.1/24). Remember to use foward slashes in this file and that the path mapping of folders is linux-like (c:\ is /cygdrive/c/).

The password for the backuppc user is setup in the c:\rsyncd\rsync.secrets file. Add the following line at the end of that file:

backuppc:backuppc

And be sure to add an empty line at the end.
You can restart the RsyncServer service with a right click on My Computer -> Manage -> Services and Application -> Services -> Rsync Server (right click) -> Restart

Go, go, go…

You are done. The first full backup will occur at the time specified in the BackupPC config file (20:00, from the last post).

Advertisements

Installing BackupPC on openSuse 13.1

29/12/2013 1 comment

I was trying to install BackupPC on my fresh openSuse 13.1 install. There was no package for openSuse so I used the documentation from the original site.

Prerequisites

The missing prerequsite for perl is File::RsyncP which you can install from repository in version 0.43, or use the newer one from Sourceforge in version 0.68. I like being on the bleeding edge (0.43 is from 2003, and 0.68 is from 2006) and actually BackupPC states that it needs at least 0.68.

wget http://downloads.sourceforge.net/project/perlrsync/perlrsync/0.68/File-RsyncP-0.68.tar.gz
tar -xvf File-RsyncP-0.68.tar.gz
cd File-RsyncP-0.68
perl Makefile.PL
make

Error 1:
Make is missing so I have to install that also.

Fix 1:
zypper install make

Continuing the installation of File::RsyncP.
make

Error 2:
GCC is missing so I have to install that also.

Fix 2:
zypper install gcc

Continuing the installation of File::RsyncP.
make
make install

There were some warnings, but the tests passed OK, so I think this will work just fine.

Creating a dedicated user and group

For security reasons a dedicated user and group should be used for running BackupPc.

useradd -d /home/backuppc -c 'BackupPC user' -U -r -M backuppc
mkdir /home/backuppc
chown -R backuppc:backuppc /home/backuppc

Getting and installing BackupPC 3.3.0

The source can be downloaded from Sourceforge and the installation is trivial.

wget http://downloads.sourceforge.net/project/backuppc/backuppc/3.3.0/BackupPC-3.3.0.tar.gz
tar -xvf BackupPC-3.3.0.tar.gz
cd BackupPC-3.3.0
perl configure.pl

Now is the time to answer some questions:

  1. Full path to existing main config.pl – leave empty
  2. Are these paths correct? – yes
  3. BackupPC will run on host [your_host_name]? – acknowledge the default
  4. BackupPC should run as user [backuppc]? – use the default
  5. Install directory (full path) – /opt/BackupPC
  6. Data directory (full path) – /home/backuppc/data
  7. Compression level [3]? – user default
  8. CGI bin directory (full path) – /srv/www/cgi-bin
  9. Apache image directory (full path) – /srv/www/htdocs/BackupPC
  10. URL for image directory (omit http://host; starts with ‘/’) – /BackupPC
  11. Do you want to continue? – yes

Now that BackupPC is installed, in needs to be configured. So open /etc/BackupPC/config.pl and configure it:

$Conf{WakeupSchedule} = [20];
$Conf{FullKeepCnt} = [4, 0, 4];
$Conf{IncrLevels} = [1, 2, 3, 4, 5, 6];
$Conf{CgiAdminUsers} = 'your_username';

Run every day at 20:00, have 5 months of full backups (4 * 1 week + 4 * 1 month), create 6 incremental backups between full backups (every day between the weekly full backup), and setup a user as admin.

Acording to this article, the default init script is not good so another one should be used. As that script is also broken, you can use the following:

#!/bin/sh
#
# /etc/init.d/backuppc
#
### BEGIN INIT INFO
# Provides: backuppc
# Required-Start: $local_fs $remote_fs $network
# X-UnitedLinux-Should-Start:
# Required-Stop: $local_fs $remote_fs $network
# X-UnitedLinux-Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: BackupPC - High End Archive Server
# Description: Start the BackupPC daemon
### END INIT INFO

pname=backuppc

set -e

#
BINDIR=/opt/BackupPC/bin
DATADIR=/home/backuppc/data
LOGDIR=/var/log/BackupPC
USER=backuppc
#
NAME=backuppc
DAEMON=BackupPC

test -x $BINDIR/$DAEMON || exit 0

case "$1" in
start)
echo -n "Starting $NAME: "
startproc -p $LOGDIR/BackupPC.pid -u $USER $BINDIR/$DAEMON -d
echo "ok."
;;
stop)
echo -n "Stopping $NAME: "
killproc -TERM -p $LOGDIR/BackupPC.pid $BINDIR/$DAEMON
echo "ok."
;;
restart)
$0 stop
$0 start
;;
reload|force-reload)
echo "Reloading $NAME configuration files"
killproc -SIGHUP -p $LOGDIR/BackupPC.pid $BINDIR/$DAEMON
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload}"
exit 1
;;
esac

exit 0

After that register the service with this command:

install -m 0755 backuppc /etc/init.d/

Go, go, go…

Run the service with:

service backuppc start

And that’s it. Now, to configure clients and Nginx you will have to wait for the next article.

vmWare tools on openSuse 12.3

18/03/2013 1 comment

I was having some problems installing vmWare tools in vmWare Player 5 for the new version of openSuse. It seems some header files are located in the wrong place where the installer of vmWare tools is not looking. The original article about the problems says this should fix the problem:


zypper install kernel-desktop-3.7.10-1.1.1.x86_64
zypper install kernel-desktop-devel-3.7.10-1.1.1.x86_64
mkdir -p /lib/modules/3.7.10-1.1-desktop/build/include/linux
cp /usr/src/linux-3.7.10-1.1-obj/x86_64/desktop/include/generated/uapi/linux/version.h /lib/modules/$(uname -r)/build/include/linux

and then to run the vmware-install.pl script.
It worked like a charm.

Categories: openSuse, vmWare Tags: , ,

Redmine 2.2.3 on openSuse 12.3

I wanted to install the newest Redmine on the last version of openSuse (12.3 – released yesterday). So, here are the steps from the official Redmine site (Installing Redmine).

Getting Redmine

 
You usually get the source from the RubyForge site, so let’s do it.

wget http://rubyforge.org/frs/download.php/76771/redmine-2.2.3.tar.gz

Unpacking it is easy.

tar -xvf redmine-2.2.3.tar.gz

Dependencies installation

 
The documentation states that Redmine needs:

  • ruby 1.8.7, 1.9.2, 1.9.3, jruby-1.6.7
  • Rails 3.2.12
  • RubyGems <= 1.8

From now on re run this as root:

zypper install ruby
zypper install rubygem-rails-3_2

RubyGems will get installed with ruby 1.9.3, as a dependency.
Bundler will get installed with Rails 3.2.12, as a dependency.

The hard part

 
We will try to install the rest of the remaining dependencies using the patented method of useless attempts.

Attempt 1

cd redmine-2.2.3
bundle install --without development test

Error 1:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9 extconf.rb
mkmf.rb can’t find header files for ruby at /usr/lib64/ruby/include/ruby.h

Gem files will remain installed in /usr/lib64/ruby/gems/1.9.1/gems/json-1.7.7 for inspection.
Results logged to /usr/lib64/ruby/gems/1.9.1/gems/json-1.7.7/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.7.7), and Bundler cannot continue.
Make sure that `gem install json -v ‘1.7.7’` succeeds before bundling.

Fix 1: missing ruby development package

zypper install ruby-devel

Attempt 2

bundle install --without development test

Error 2:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9 extconf.rb
creating Makefile

make
sh: make: command not found

Gem files will remain installed in /usr/lib64/ruby/gems/1.9.1/gems/json-1.7.7 for inspection.
Results logged to /usr/lib64/ruby/gems/1.9.1/gems/json-1.7.7/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.7.7), and Bundler cannot continue.
Make sure that `gem install json -v ‘1.7.7’` succeeds before bundling.

Fix 2: missing make

zypper install make

Attempt 3

bundle install --without development test

Error 3:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9 extconf.rb
creating Makefile

make
compiling generator.c
make: gcc: Command not found
make: *** [generator.o] Error 127

Gem files will remain installed in /usr/lib64/ruby/gems/1.9.1/gems/json-1.7.7 for inspection.
Results logged to /usr/lib64/ruby/gems/1.9.1/gems/json-1.7.7/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.7.7), and Bundler cannot continue.
Make sure that `gem install json -v ‘1.7.7’` succeeds before bundling.

Fix 3: missing gcc

zypper install gcc

Attempt 4

bundle install --without development test

Error 4:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9 extconf.rb
checking for rb_thread_blocking_region()… yes
checking for rb_wait_for_single_fd()… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lmygcc… no
checking for mysql_query() in -lmysqlclient… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/bin/ruby1.9
–with-mysql-config
–without-mysql-config
–with-mysql-dir
–without-mysql-dir
–with-mysql-include
–without-mysql-include=${mysql-dir}/include
–with-mysql-lib
–without-mysql-lib=${mysql-dir}/
–with-mysqlclientlib
–without-mysqlclientlib
–with-mlib
–without-mlib
–with-mysqlclientlib
–without-mysqlclientlib
–with-zlib
–without-zlib
–with-mysqlclientlib
–without-mysqlclientlib
–with-socketlib
–without-socketlib
–with-mysqlclientlib
–without-mysqlclientlib
–with-nsllib
–without-nsllib
–with-mysqlclientlib
–without-mysqlclientlib
–with-mygcclib
–without-mygcclib
–with-mysqlclientlib
–without-mysqlclientlib

Gem files will remain installed in /usr/lib64/ruby/gems/1.9.1/gems/mysql2-0.3.11 for inspection.
Results logged to /usr/lib64/ruby/gems/1.9.1/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v ‘0.3.11’` succeeds before bundling.

Fix 4: missing mysql development

zypper install libmysqlclient-devel

Attempt 5

bundle install --without development test

Error 5:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9 extconf.rb
checking for pg_config… no
No pg_config… trying anyway. If building fails, please try again with
–with-pg-config=/path/to/pg_config
checking for libpq-fe.h… no
Can’t find the ‘libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/bin/ruby1.9
–with-pg
–without-pg
–with-pg-dir
–without-pg-dir
–with-pg-include
–without-pg-include=${pg-dir}/include
–with-pg-lib
–without-pg-lib=${pg-dir}/
–with-pg-config
–without-pg-config
–with-pg_config
–without-pg_config

Gem files will remain installed in /usr/lib64/ruby/gems/1.9.1/gems/pg-0.14.1 for inspection.
Results logged to /usr/lib64/ruby/gems/1.9.1/gems/pg-0.14.1/ext/gem_make.out
An error occurred while installing pg (0.14.1), and Bundler cannot continue.
Make sure that `gem install pg -v ‘0.14.1’` succeeds before bundling.

Fix 5: missing postgresql development

zypper install postgresql-devel

Attempt 6

bundle install --without development test

Error 6:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9 extconf.rb
checking for Ruby version >= 1.8.5… yes
checking for gcc… yes
checking for Magick-config… no
Can’t install RMagick 2.13.2. Can’t find Magick-config in /sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/bin/ruby1.9

Gem files will remain installed in /usr/lib64/ruby/gems/1.9.1/gems/rmagick-2.13.2 for inspection.
Results logged to /usr/lib64/ruby/gems/1.9.1/gems/rmagick-2.13.2/ext/RMagick/gem_make.out
An error occurred while installing rmagick (2.13.2), and Bundler cannot continue.
Make sure that `gem install rmagick -v ‘2.13.2’` succeeds before bundling.

Fix 6: missing ImageMagic development

zypper install libMagick++-devel

Attempt 7

bundle install --without development test

Error 7:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9 extconf.rb
checking for sqlite3.h… no
sqlite3.h is missing. Try ‘port install sqlite3 +universal’
or ‘yum install sqlite-devel’ and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/bin/ruby1.9
–with-sqlite3-dir
–without-sqlite3-dir
–with-sqlite3-include
–without-sqlite3-include=${sqlite3-dir}/include
–with-sqlite3-lib
–without-sqlite3-lib=${sqlite3-dir}/
–enable-local
–disable-local

Gem files will remain installed in /usr/lib64/ruby/gems/1.9.1/gems/sqlite3-1.3.7 for inspection.
Results logged to /usr/lib64/ruby/gems/1.9.1/gems/sqlite3-1.3.7/ext/sqlite3/gem_make.out
An error occurred while installing sqlite3 (1.3.7), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v ‘1.3.7’` succeeds before bundling.

Fix 7: missing sqlite development

zypper install sqlite3-devel

Attempt 7

bundle install --without development test

Win!!

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Setup the database

 
Now we have to connect to a database and create a user. I will choose postgresql because I have it already installed.

su - postgres
psql postgres
postgres=# CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'my_password' NOINHERIT VALID UNTIL 'infinity';
postgres=# CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;

Tweak the pg_hba.conf to allow the redmine user to login. Add the following line before any other definition. Beware that this is only for demonstration purposes and should not be used like this for serious purposes.

host redmine redmine 127.0.0.1/32 trust

Reload the postgresql service as root:

systemctl reload postgresql.service

Configure the database connection creating a redmine-2.2.3/config/database.yml file using the redmine-2.2.3/config/database.yml.example as a template. I used the following configuration:

production:
  adapter: postgresql
  database: redmine
  host: 127.0.0.1
  username: redmine
  password: "my_password"
  encoding: utf8

The password is not needed because we have configured the database to trust the redmine user when connection to the redmine database on the same host.

Session store secret generation

 
As a regular user generate the secret random key used to encrypt cookies

cd redmine-2.2.3
rake generate_secret_token

Creating the tables in the database

 
Now we have to create the tables for Redmine.

RAILS_ENV=production rake db:migrate

Loading the default data

 
Some initial data needs to be inserted into the redmine database.

RAILS_ENV=production REDMINE_LANG=en rake redmine:load_default_data

File system permissions

 
Some permissions should be given on log, tmp and public/plugin_assets folders.

mkdir tmp tmp/pdf public/plugin_assets
chmod -R 755 files log tmp public/plugin_assets

Go go go!!!

 
And we are done 🙂 Run the server and connect on http://localhost:3000. You can use the admin/admin for username/password.

ruby script/rails server webrick -e production

I hope that this at least helped someone to avoid getting stuck with dependency issues installing Redmine.

Categories: openSuse, Redmine Tags: , ,