Wednesday 4 September 2013

Debian Samba NAS/Crashplan Backup/Google Music Manager server

Got myself a HP Proliant MicroServer N54L during the current cashback period. I'll be using it purely for storage as a Samba box and with Crashplan installed to be used both as a local backup location for other machines, and to backup the files stored with Samba. I keep other copies of what will be in Samba anyway, so I'll have a robust enough backup solution for me - online copy + "online"/offline copy + remote copy.

Google Music Manager will also be installed. I find it extremely useful, though now I'm setting up this box I'm regretting not ripping all my CDs to FLAC rather than HQ MP3, since Music Manager takes care of transcoding for playback remotely anyway!

Debian 7.1 AMD64 has been installed to an internally held 4GB USB flash drive I had spare. Root user disabled - using sudo only for a change.

Tweaks for running from a flash drive

/etc/sysctl.d/99-sysctl.conf

vm.swappiness=1
vm.vfs_cache_pressure=50

/etc/fstab

noatime,commit=60

Samba/Smartmontools have been installed.
sudo aptitude install samba smartmontools
sudo chgrp staff /etc/samba/smb.conf
sudo chmod g+w /etc/samba/smb.conf
sudo usermod -a -G staff rogalian
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.master
sudo testparm -s /etc/samba/smb.conf.master >/etc/samba/smb.conf


The scripts found here to show the current IP address on the console have been adapted.
sudo cp /etc/issue /etc/issue-standard
sudo nano -w /etc/network/if-up.d/issue-ip
#!/bin/sh
if [ "$METHOD" = loopback ]; then
    exit 0
fi

# Only run from ifup.
if [ "$MODE" != start ]; then
    exit 0
fi

cp /etc/issue-standard /etc/issue
/sbin/ifconfig | grep "inet addr" | grep -v "127.0.0.1" | awk '{ print $2 }' | awk -F: '{ print $2 }' >> /etc/issue
echo "" >> /etc/issue
sudo chmod u+x /etc/network/if-up.d/issue-ip

ZFS

ZFS installed from the ZFS on Linux Debian instructions. I create one pool with four filesystems (one for incoming CrashPlan backups, aether for files I'm not concerned about losing, chaos for unsorted/WIP files and order for sorted/categorised/finished work).
wget http://archive.zfsonlinux.org/debian/pool/main/z/zfsonlinux/zfsonlinux_1%7Ewheezy_all.deb
sudo dpkg -i zfsonlinux_1~wheezy_all.deb
sudo aptitude update
sudo aptitude install debian-zfs
sudo zpool create -f pool /dev/disk/by-id/scsi-SATA_VB0250EAVER_Z3TLXK2B
sudo zpool set autoexpand=on pool
sudo zpool attach -f pool /dev/disk/by-id/scsi-SATA_VB0250EAVER_Z3TLXK2B /dev/disk/by-id/scsi-SATA_ST3500418AS_5VMWXFAR
sudo zfs set compression=lzjb pool
sudo zfs create pool/crashplan
sudo zfs create pool/aether
sudo zfs create pool/chaos
sudo zfs create pool/order

/etc/default/zfs

ZFS_MOUNT='yes'

/etc/cron.weekly/zfs-scrub

#!/bin/bash

# set PATH
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# set pool name
ZFS_POOL="pool"

# start scrub
zpool scrub "$ZFS_POOL"
chmod u+x /etc/cron.weekly/zfs-scrub

CrashPlan

Happy customer of a few years. I only back up a few hundred gigabytes with them, and the initial backup did take a while - but subsequent backup/restore/machine adoption has all been quick and reliable. Off site backup is a must - I keep two copies of everything myself then leave the off site work to CrashPlan, whether it's backing up a machine I'm using or this storage server. Completely worth the price.

sudo aptitude install default-jre
wget http://download.crashplan.com/installs/linux/install/CrashPlan/CrashPlan_3.5.3_Linux.tgz
tar xvzf CrashPlan_3.5.3_Linux.tgz
cd CrashPlan-install
sudo ./install.sh

Store backups in /pool/crashplan
sudo chgrp -R staff /pool/crashplan
sudo chmod g+w /pool/crashplan

/etc/sysctl.d/99-sysctl.conf

fs.inotify.max_user_watches=1048576

/usr/local/crashplan/conf/my.service.xml

Change serviceHost appropriately. Update ui.properties on the machine you'll run CrashPlan Desktop from. Change cachePath to /pool/aether/tmp

sudo update-rc.d crashplan defaults
sudo mv /etc/rc2.d/S01crashplan /etc/rc2.d/S99crashplan
sudo invoke-rc.d crashplan restart
 Addendum 20140408 I've picked up a cheap USB WiFi stick so that this box can sit with just a power cable. It requires the
non-free
package
firmware-realtek
. For actually managing the connection:
wicd-curses
Also wanted an ftp server. Decided on pure-ftpd