The Hound of the Wolf

For the strength of Pack is in the Wolf, and the strength of Wolf is in the Pack -Rudyard Kipling

Thursday, February 19, 2009

PHP Script for Automated Backup


1. PHP5 with PECL-SSH2 enabled
2. The SSH2 wrapper library (
3. The killer script:

$s = new SSH2('MYSERVER');
$s->loginWithPassword('MYLOGIN', 'MYPASSWORD');
$_buf = $s->execCommandBlocking('tar cvf - /www/foo_com/');
file_put_contents('foo_com_backup_' . date('Ymd'), $_buf);

Result: Priceless peace of mind knowing that there is a script doing stuff humans should not supposed to regularly do.