Got a new PC (finally)

June 27th, 2008 by Daniele Muscetta
Got a new PC

So this is a screenshot from my new Quad-Core Intel Q6600, 8GB RAM with Windows 2008 Enterprise x64, running Hyper-V.
I have bought it and installed it a few days ago, and migrated my home Active Directory off the old windows 2003 machine to Windows 2008. Yes, because I have an Active Directory at home. I know, I am probably nuts, but you already knew that much.

Today, I just updated Hyper-V to RTM version. Oh yeah, because Hyper-V has been Released To Manufacturing today! You can get it HERE.

I am having lot of fun with this. I had not bought a new PC in about 7 years and could not really test anything on that old one anymore…
I paid 8GB roughly 100euros, which is not a lot if you think about it. These days even standard "budget" PCs for just doing email and web surfing ship with 2 or 4GB…
With that amount of RAM, I expect it to last several years like the previous one. The one I bought 7 years ago had 512MB when everybody was buying 128 or 256MB. Kinda the same story here.

Wonder what happens to the old PC? That glorious machine that has been my server for years has now been converted to the new kids' PC and will go on for a few more years like that, I hope.

Backup or Store stuff to GMail via IMAP in Ruby

June 10th, 2008 by Daniele Muscetta

Once upon a time, I used to store some automated small backups into GMail just by having the scheduled backup send an email to my GMail account. At one stage they blocked me from doing so, marking those repeated email as SPAM.

After that, I took a different approach: I kept sending the mail on the SAME server as the backup, and using IMAP I could DRAG-and-DROP the backup attachment from the mailbox on one server to the mailbox on another server (=GMail). They did not mark me as a spammer that way, of course.
So that worked for a while, but then I got tired of doing this manually.

So the following ruby script is the way I automated the "move offsite" part of that backup.
For completeness, I will give the due credits about who set me on the right track: I started off by this example by Ryan.

#!/usr/bin/env ruby
begin_ = Time.now

#includes
require 'net/imap'

##Source Info
$SRCSERVER="mail.muscetta.com"
$SRCPORT=143
$SRCSSL=false
$SRCUSERNAME="daniele"
$SRCPASSWORD=""
$SRCFOLDER="INBOX.Backups"

##Destination Info
$DSTSERVER="imap.gmail.com"
$DSTPORT=993
$DSTSSL=true
$DSTUSERNAME="muscetta@gmail.com"
$DSTPASSWORD=""
$DSTFOLDER="Backup"

#connect to source
puts "connecting to source server #{$SRCSERVER}... nn"
srcimap = Net::IMAP.new($SRCSERVER,$SRCPORT,$SRCSSL)
srcimap.login($SRCUSERNAME, $SRCPASSWORD)
srcimap.select($SRCFOLDER)

#connect to destination
puts "connecting to destination server #{$DSTSERVER}... nn"
dstimap = Net::IMAP.new($DSTSERVER,$DSTPORT,$DSTSSL)
dstimap.login($DSTUSERNAME, $DSTPASSWORD)
dstimap.select($DSTFOLDER)

# Loop through all messages in the source folder.
uids = srcimap.uid_search(['ALL'])
if uids.length > 0
	$count = uids.length
	puts "found #{$count} messages to move... nn"

	srcimap.uid_fetch(uids, ['ENVELOPE']).each do |data|
		mid = data.attr['ENVELOPE'].message_id

		# Download the full message body from the source folder.
		puts "reading message... #{mid}"
		msg = srcimap.uid_fetch(data.attr['UID'], ['RFC822', 'FLAGS', 'INTERNALDATE']).first

		# Append the message to the destination folder, preserving flags and internal timestamp.
		puts "copying message #{mid} to destination..."
		dstimap.append($DSTFOLDER, msg.attr['RFC822'], msg.attr['FLAGS'], msg.attr['INTERNALDATE'])

		#delete the msg
		puts "deleting messsage #{mid}..."
		srcimap.uid_store(data.attr['UID'], '+FLAGS', [ :D eleted])
		srcimap.expunge

	end

	#disconnect
	dstimap.close
	srcimap.close
end

total_time = Time.now - begin_
puts "Done. RunTime: #{total_time} sec. nn"