There are a lot of backup options out there for linux, and everyone seems to want to roll their own, which is understandable when there are just so many different environments and setups.
I have a fairly large database of photos, which I really needed to keep backed up, but obviously this will work on any type of file.
First things first, I suggest backing up to an external USB drive, I simply used a spare 250gb drive, and a USB caddy for it, linux automatically detected it, and I was able to mount it from /dev/sda1straight away. Now, for the backup itself, this is stupidly simple, and for simple home use - absolutely perfect for me.
I simply setup a cronjob that copies from my local photo directory, to my USB drive, it's a one-liner which does the following things:
cp -au /path/to/photos/ /mnt/backup/
I simply saved this file in the cron.daily folder, and gave it the permissions 755. Now I feel a bit safer with an extra copy. If your drive is permanently attached to your computer, don't forget to add an entry into /etc/fstab so it mounts each bootup!
Occasionally when uploading your own photos, or artwork, or even if you run a site that hosts images and you wish to mark them, watermarking can be a useful technique. The aim is to simply overlay an unobtrusive graphic over your source image, I find white text, with a black shadow seems to work the best on both light and dark source images.
It's rather easy in PHP and GD2, and as a bonus we can use a PNG image with alpha transparancy as the "watermark" image, which means proper antialiasing on text, and dropshadows are possible!
You'll need a source JPG image, and also a small watermark image - the script below is well commented so you can see how each step works, simply change the first two variables to point to your image files on the server.
An example using my setup below can be found here (water mark is in the bottom right corner).
/*
/* setup the source file and watermark */
$sourceImg = 'beach_large.jpg';
$watermarkImg = 'watermark.png';
/*
/* create source file with alphablending */
$image = imagecreatefromjpeg($sourceImg);
imagealphablending($image, true);
/*
/* create watermark holder */
$watermark = imagecreatefrompng($watermarkImg);
/*
/* get image and watermark dimensions */
$width = imagesx($image);
$height = imagesy($image);
$wmWidth = imagesx($watermark);
$wmHeight = imagesy($watermark);
/*
/* caclulate where to place watermark */
$xPos = $width - $wmWidth;
$yPos = $height - $wmHeight;
/*
/* Copy the watermark to the top right of original image */
imagecopy($image, $watermark, $xPos, $yPos, 0, 0, $wmWidth, $wmHeight);
/*
/* output image directly to browser */
header("Content-Type: image/jpeg");
imagejpeg($image);




