DB Backup with a simple ruby script

I've created a simple ruby script which gets a backup of your postgres database, store it on S3 and send it to your email. It works very nice with small databases (about 1-2MB) which I tested, you may want to remove the mail part if your database is huge though. Here is the script:

In the script I am using postgres as a backup database, S3 for uploading and savnig the file and gmail for sending me the backup. So the configurations are related to them. After that, you need to add a cronjob, I like using whenever gem. If you want to skip whenever, you can do it manually as follows. Type crontab -e for editing your cronjobs and put the following command:
0 12 * * 5 /bin/bash -l -c 'ruby /home/your_user/your_backups//cron.rb'
Script will run every friday on 12pm. As a final note, be sure that your user have the appropriate permissions to write on these folders and to the database.

Max one mail per week.