Backup-panic!

Tonight I’ve lived a backup-panic situation. It’s solved now, and maybe it’s time to note down some trace of it.

Last time I updated Omelas’ infrastructure , I decided it was the time to finally setup a backup procedure. Not that I have any mission critical here, but there are enough friends&family services here that deserve someone taking care of them.

So, after a quick browsing of alternatives, I decided upon a simple script around rdiff-backup .
The script is simple enough to not even be quoted here. The only problem I found was that the backup structure got any uppercased letter ascii-encoded, so ‘Developers’ become ’;068eveloper’, and 'Library’ becomes ’;076ibrary’. It seems to be a feature, not a bug, trying to make the tool play the good neighbour with case-insensitive filesystems.
Weird… but the system seemed to work, and so I forgot about it.

Now to the panic part; some hours ago I tested a new version of Apache James , which happens to be my mail server, and I managed to crash my configuration. “No problem”, I though. “I’ll restore yesterday’s configuration from the backup”. And then, don’t know how, I managed to invoke rdiff-backup in some way that instructed it to *WIPE* my local directory.

“What the….!!!”, I said. “Ok, let’s manually restore from the backup again”. And then, I realized that this little problem with encoded letters was not “little” at all. Do you know how many uppercased files are inside a living James installation? My god… no way of manually doing this… and my searches in rdiff-backup mailing lists shed no light on the matter. There’s that funky ’–overrides-chars-to-quote" command-line option, I’ve learned. But you should use it before-hand, no way of fixing my mess in the affected directories.

Well… I close the laptop… and went for a night-walk…

Back in home, I tried a small ruby script to fix the problem:

original = ARGV[0]
pattern = /;([0-9]{3})/

original.gsub(pattern) { |cad| original = original.sub(cad, $1.to_i.chr) }
puts original

This small script (saved as sos.rb) will replace any encoded letter in the input with the originally uppercased letter, getting again 'Developer’ from ’;068eveloper’.

Now, let’s invoke it on every file in the restored directory, with a bash loop:

#!/usr/bin/bash
for i in `find james-2.x`
do
nuevo=`ruby sos.rb $i`
if [ "$i" != "$nuevo" ]
then
sudo mv $i $nuevo
else
echo Skipping $i...
fi
done

Enough. My email server is running again. Nightmare passed. My backup procedure uses now “–override-chars-to-quote”. Ruby is still a great tool for quick fixes. Time to go to sleep.