James Emmrich

10 Mar, 2010

Website Updates

Posted by: James In: Miscellaneous

I have been updating various pages throughout the site, mainly my Fresh Ubuntu install page which can be found under the Linux section.

Over the next few days I will have more updates. I am also going to add a post on using Git and possibly include it in a post regarding rapid web development. However both are pretty big and can be quite complex topics.



Tweet This

As mentioned before somewhere in my blog, here is the script I have written to back up my databases. This is actually my local backup script, I have a much different one on the server which uses a passwordless ssh connection to backup the databases offsite.

#!/bin/sh
# Database backup 2008 <jemmrich@gmail.com>
# Nightly Usage:
# 0 0 * * * /home/james/Dropbox/Home/mobilewolf/scripts/backup.sh &> /dev/null

LOGFILE="/home/james/Dropbox/Home/mobilewolf/databases/databases.log"
BACKUPDIR="/home/james/Dropbox/Home/mobilewolf/databases"
STARTTIME="$(date +%Y-%m-%d-%r)"

# MySQL Login
SQLUSER="sqluser"
SQLPASS="sqlpass"

# Dump databases
echo "*** Database Backup Started: $STARTTIME" >> $LOGFILE

# Keep yesterdays databases
rm -f $BACKUPDIR/yesterday/*
mv $BACKUPDIR/*.gz $BACKUPDIR/yesterday/

for i in `echo "show databases" | mysql -u $SQLUSER -p$SQLPASS | grep -v Database`;
do
 mysqldump -u $SQLUSER -p$SQLPASS $i > /tmp/$i.sql
 echo $i >> $LOGFILE
 gzip /tmp/$i.sql

 # Send Databases
 cp /tmp/*.sql.gz $BACKUPDIR/

 # Remove our dumps to keep us clean
 rm -f /tmp/*.sql.gz
done

echo "*** Database Backup Ended: $(date +%Y-%m-%d-%r)" >> $LOGFILE
echo "\n" >> $LOGFILE

Setup

  1. Change the user and password to a user that has ability to access all databases for dump
  2. Download and set executable permissions chmod +x backup_databases.sh
  3. edit cron to execute every night: crontab -e
  4. add: 0 0 * * * /home/james/Dropbox/Home/mobilewolf/scripts/backup_databases.sh &> /dev/null

Ideas for your setup

  • The line following “Send databases” replace cp, with scp to send the databases to remote server. You will need to have passwordless ssh connections setup.
  • Have the log file emailed to you once completed

My Future Improvements

  • Enable backup archiving for the past week rotated daily so I can go back to a database from 2 or 3 days or even a week ago


Tweet This

21 Feb, 2010

How I use Dropbox on Ubuntu

Posted by: James In: Linux| ProTip

Dropbox.com has become a huge time saver for me, and most likely a life saver as well.

I have a folder in my Dropbox called Home. Here I have sub folders for each machine that I have. My two laptops, a desktop which hold computer specific files that are different for each computer I have.

Files such as:

  • /etc/hosts
  • /etc/fstab
  • /databases/

Rather than copying these manually, I have simply moved the files to the dropbox and then symbolically linked them. That way when the system updates these files, Dropbox does it’s sync.

The databases folder is a folder which contains database dumps. My crontab is setup to nightly dump databases in tar form and place them here, for Dropbox to store.

I also have a folder called Resources. This contains files that are shared between computers. I have symbolically linked my .fonts folder here. Now whenever I install a new font for a design project, all my other computers are updated too.

For chat software like Pidgin and XChat, I have symbolically linked their folders .purple and xchat2 respectively, to my Dropbox home folder. Because these will be shared between computers I don’t have them in their respect computer sub folder. Now no matter what computer I chat on, my chat logs and software settings are up to date.

Projects that I work on are placed in my Dropbox under a folder called Projects, with each project as its own sub folder.

During my work, or daily routine I tend to shuffle, download, delete, and create new files. While I don’t always place these files to my Dropbox, I am very careful to not hold them on my laptops for long periods of time.

For files that I want to hold, I either move them to my Dropbox or to my NAS server depending solely on their importance and need of accessibility.

The results

I can now format my hard drive at any time, provided that Dropbox has had time to sync any changes. I also have the feeling of security knowing that my hard drive crashes will not take me out of commission.



Tweet This

Upcoming Events

  • Sat, Mar 13:AMA Supercross - Toronto
  • Sat, Mar 20:AMA Supercross - Dallas
  • Sat, Mar 27:AMA Supercross - Jacksonville
  • Sun, Apr 4:CMRC South Western Ontario - Gopher Dunes Practice
  • Sat, Apr 10:AMA Supercross - Houston
  • Sun, Apr 11:CMRC South Western Ontario - Gopher Dunes Spring Classic
  • Sat, Apr 17:AMA Supercross - St. Louis
  • Sun, Apr 18:CMRC South Western Ontario - RJ Motosport Spring Classic
  • Sat, Apr 24:AMA Supercross - Seattle
  • Sun, Apr 25:CMRC South Western Ontario - Auburn Hills Spring Classic

Flickr PhotoStream

    Montreal SupercrossAuburn Hills Aug 31 2008Auburn Hills Aug 31 2008Auburn Hills Aug 31 2008Auburn Hills Aug 31 200827000km milestonePissing at Transcan 2008x7-29-7-1360x7-29-7-1019x7-29-7-1002x7-29-7-972x7-29-7-941

Twitter Me

I'm a totally rad web application developer, linux affectionado, and a super hardcore motorcycle enthusiast. I'm self employed and have big ideas and big dreams.


Twitter Updates