Script for automatic backup of Postgresql DB
DB_USERNAME=''
DB_NAME=''
DB_PASSWORD=''
DB_HOST=''
DATE=`date +%Y%m%d`
TIME=`date +%H%M`
BACKUP_DIR='/some/path/to/dbackups/'
FILENAME="$DATE-$TIME.sql.gz"
PGDUMP=`which pg_dump`
export PGPASSWORD=$DB_PASSWORD
$PGDUMP -U $DB_USERNAME $DB_NAME | gzip > $BACKUP_DIR$FILENAME
cd $BACKUP_DIR
# Using this amazing tool by Petter Rasmussen: https://github.com/prasmussen/gdrive
# We can uplaod our backup to some Google Drive account
# Thanks Petter! :)
exec drive upload -f $FILENAME -p SOME_DRIVE_ID