Archive for October, 2007

Backing up an entire harddisk, remotely

Saturday, October 27th, 2007

It just crossed my mind that I had to make a backup of some servers. Usually I only backup the home directory and databases, but just to be comfortable, I decided to create a backup of the entire harddisk. In this case, the server needs to keep running and serving websites and is located a couple of hundred kilometres away from here. Therefore it was no option to insert an extra harddisk and do a sector-to-sector copy.

The aim was to copy all files, compress them, and have the compressed file transfered to a mirror location. This can be achieved quite easily:
tar -cj / | ssh username@mirrorlocation.tld "cat > fullbackup_filename.tar.bz2"

After the full backup was created, and transfered to the mirror location, I saw that there was a compress rate of over 60%, which means the backup is still several gigabytes big. Time to buy some tapestreamer…

Creating an SFTP-only / FTP-only account

Wednesday, October 10th, 2007

I’m using Proftpd on a shared webhosting server using PAM authentication. There’re plenty of users that I do want to have an sftp-account, but not an shell-account by default.

Because the way I configured proftpd I need to add ‘real’ linux users (also based on PAM). Which brings me to the problem right-away: The user gets shell-access at that very same time. It took some time, but I figured out this script:
#!/bin/sh

if [ "$*" != "-c /usr/lib/openssh/sftp-server" ]; then
echo "Sorry, this account can be used only for (S)FTP-access.

If you require shell-access, please contact your webhost.";
exit;
fi;
exec /usr/lib/openssh/sftp-server

After setting the the right file-permissions (-rwxrwxr-x ), and changing the shell of a user to this script, that user will have no access to bash, sh, etc :D

Update ZendFramework

Wednesday, October 10th, 2007

I just updated ZendFramework on one of the servers I manage from 1.0.1 to 1.0.2.

cd /usr/share/php
wget http://framework.zend.com/releases/ZendFramework-1.0.2/ZendFramework-1.0.2.tar.gz
tar xvf ZendFramework-1.0.2.tar.gz
rm ZendFramework
ln -s ZendFramework-1.0.2 ZendFramework
chown nobody:nogroup ZendFramework-1.0.2 -R

And just to confirm the creation of the symlink was done succesfully:
ns4:/usr/share/php# ls -la
...
lrwxrwxrwx 1 root root 19 Oct 10 19:21 ZendFramework -> ZendFramework-1.0.2
drwxrwxr-x 5 nobody nogroup 4096 Oct 10 19:21 ZendFramework-1.0.1
drwxrwxr-x 5 nobody nogroup 4096 Sep 25 13:47 ZendFramework-1.0.2
-rw-r--r-- 1 root root 3775664 Sep 25 18:01 ZendFramework-1.0.2.tar.gz