CrashPlan/FreeBSD

From Segfault
Jump to navigation Jump to search

Installation

While CrashPlan is not supported on FreeBSD[1], there are quite a few tutorials[2][3][4] on how to install CrashPlan on FreeBSD.

Enable Linux compatibility:

  • Add linux_enable="YES" to /etc/rc.conf
  • Add linproc to /etc/fstab and mount it
  • Install linux-f10-procps and maybe openjdk

We will also create a separate user to run CrashPlan via adduser[5], e.g.

$ adduser -d /opt -w none
Username: crashplan
Full name: 
Uid (Leave empty for default): 
Login group [crashplan]: 
Login group is crashplan. Invite crashplan into other groups? []: 
Login class [default]: 
Shell (sh csh tcsh bash rbash nologin) [sh]: 
Home directory [/opt/crashplan]: 
Home directory permissions (Leave empty for default): 
Use password-based authentication? [yes]:   
Use an empty password? (yes/no) [yes]: 
Lock out the account after creation? [no]: 

Change its shell to the Linux compatibility version of bash:

$ chsh -s /compat/linux/bin/bash crashplan

Note: In our case, /opt was a separate partition and we need to make it available in our compatibility environment too. The data to be backed up is located on a network share, this has to be made available as well:

$ grep nullfs /etc/fstab 
/opt                      /compat/linux/opt            nullfs noauto,rw 0 0
/mnt/nfs/data             /compat/linux/mnt/nfs/data   nullfs noauto,ro 0 0

$ mount /compat/linux/opt && mount /compat/linux/mnt/nfs/data

We're ready to change to the new user and lo and behold:

# su - crashplan 
$ uname -sr
Linux 2.6.16

Now we can install CrashPlan as this user:

$ tar -xzf ../CrashPlan_3.7.0_Linux.tgz && cd CrashPlan-install
$ ./install.sh                                                      # Patch with install-sh.diff

Once installed, we have to make the same modifications again, plus a few more:[6]

sed 's/TARGETDIR\/\${NAME}\.pid/TARGETDIR\/log\/\${NAME}\.pid/' -i.bak bin/CrashPlanEngine
sed 's/OPTS=\"/&-Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider -Djava.io.tmpdir=\/opt\/crashplan\/tmp /' -i.bak bin/run.conf
sed 's/FINE/WARN/;s/INFO/WARN/' -i.bak conf/service.log.properties

Another important setting may be which JRE to use. This can be configured via install.vars:

JAVACOMMON=/opt/crashplan/jre/bin/java                              # Use /usr/local/bin/java to use FreeBSD's version of Java

sysutils/linux-crashplan

There's even an "official" FreeBSD port called sysutils/linux-crashplan[7].

cd /usr/ports/sysutils/linux-crashplan/
make install

This might fail if no JRE can be found:

> linux-sun-jre17-7.67 You must manually fetch the J2SE RE download for the Linux platform
> (jre-7u67-linux-i586.tar.gz) from http://www.oracle.com/technetwork/java/javase/downloads/index.html, 
> place it in /usr/ports/distfiles and then run make again.

Download the respective JRE[8] and try again:

 make install

With that, CrashPlan will be installed in /usr/local/share/crashplan/ - and will leak logfiles and temporary files across the disk. But we want CrashPlan to be contained in our (encrypted) /opt partition.

Trial 1

cp -a /usr/local/share/crashplan /opt/crashplan
mkdir /opt/crashplan/tmp
chown -R crashplan:crashplan /opt/crashplan

Again, add the following to /opt/crashplan/bin/run.conf:

-Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider -Djava.io.tmpdir=/opt/crashplan/tmp

Adjust /opt/crashplan/install.vars:

TARGETDIR=/opt/crashplan
BINSDIR=/opt/crashplan/bin

And we even have to adjust /opt/crashplan/bin/CrashPlanEngine:

PIDFILE="/opt/crashplan/log/${NAME}.pid"
: ${LOGDIR=/opt/crashplan/log}                                    # Wat?

With that in place, CrashPlan will start - but will immediately try to update itself to a newer version[9]. After this is done, CrashPlan may not be able to start because our much needed modifications to run.conf are gone and have to be applied again.

I 01/26/15 08:24PM CrashPlan started, version 3.6.3, GUID 488943415928029291
I 01/26/15 08:24PM Upgrades available at central.crashplan.com:443
I 01/26/15 08:24PM Downloading a new version of CrashPlan.
I 01/26/15 08:24PM Download of upgrade complete - version 1388642400364.
I 01/26/15 08:24PM Download of upgrade complete - version 1388728800370.
I 01/26/15 08:24PM Installing upgrade - version 1388642400364
I 01/26/15 08:24PM Upgrade installed - version 1388642400364
I 01/26/15 08:24PM CrashPlan stopped, version 3.6.3, GUID 488943415928029291
I 01/26/15 08:25PM CrashPlan started, version 3.6.4, GUID 488943415928029291

[...]
jtux Loaded.
Exiting!!! java.lang.RuntimeException: Unexpected IO Exception constructing selector engine - e=java.io.IOException: Function not implemented
java.lang.RuntimeException: Unexpected IO Exception constructing selector engine - e=java.io.IOException: Function not implemented
        at com.code42.nio.SelectorEngine.<init>(SelectorEngine.java:75)
        at com.code42.nio.net.MultiSelectorEngine.<init>(MultiSelectorEngine.java:49)
        at com.code42.nio.net.Factory.<init>(Factory.java:100)
        at com.code42.messaging.nio.MessageProvider.<init>(MessageProvider.java:89)
        at com.backup42.service.CPService.initPeerControllers(CPService.java:686)
        at com.backup42.service.CPService.start(CPService.java:451)
        at com.backup42.service.CPService.main(CPService.java:1865)
Caused by: java.io.IOException: Function not implemented
        at sun.nio.ch.EPollArrayWrapper.epollCreate(Native Method)
        at sun.nio.ch.EPollArrayWrapper.<init>(Unknown Source)
        at sun.nio.ch.EPollSelectorImpl.<init>(Unknown Source)
        at sun.nio.ch.EPollSelectorProvider.openSelector(Unknown Source)
        at java.nio.channels.Selector.open(Unknown Source)
        at com.code42.nio.SelectorEngine.<init>(SelectorEngine.java:73)
        ... 6 more

Trial 2

We tried this again, but this time we did not appropriate the crashplan directory to the crashplan user but only a few essential parts:

cp -a /usr/local/share/crashplan /opt/crashplan
chgrp crashplan /opt/crashplan/bin/run.conf /opt/crashplan/install.vars
chmod g+r /opt/crashplan/bin/run.conf /opt/crashplan/install.vars
mkdir -m0700 /opt/crashplan/tmp
touch /opt/crashplan/bin/vars.sh
chown crashplan:crashplan /opt/crashplan/{conf,log,tmp} /opt/crashplan/bin/vars.sh

Again, add the following to /opt/crashplan/bin/run.conf:

-Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider -Djava.io.tmpdir=/opt/crashplan/tmp

Adjust /opt/crashplan/install.vars:

TARGETDIR=/opt/crashplan
BINSDIR=/opt/crashplan/bin

And we even have to adjust /opt/crashplan/bin/CrashPlanEngine:

PIDFILE="/opt/crashplan/log/${NAME}.pid"
: ${LOGDIR=/opt/crashplan/log}                                    # Wat?

With that in place, CrashPlan will start - and will be unable to upgrade. With because of that, it refuses to work:

CrashPlan Upgrade Failed
CrashPlan failed to apply an upgrade and will try again automatically in one hour

Links

References