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

Categories

Upcoming Events

  • Sat, Sep 11 – Sun, Sep 12:CMRC Ontario ATV - Eagles Nest
  • Sat, Sep 11 – Sun, Sep 12:WEC Enduro National Championships - Parry Sound, Ontario
  • Sat, Sep 11 – Sun, Sep 12:CMRC South Western Ontario - Walton Vet National
  • Sat, Sep 18 – Sun, Sep 19:WEC Enduro National Championships - Labelle, Quebec
  • Sun, Sep 19:CMRC South Western Ontario - Port Perry Fall Series
  • Sat, Sep 25 – Sun, Sep 26:CMRC Ontario ATV - Grand Bend
  • Sun, Sep 26 – Mon, Sep 27:MXdN Thunder Valley Motocross Park
  • Sun, Sep 26:CMRC Ontario Cross Country Series - Gopher Dunes
  • Sun, Sep 26:CMRC South Western Ontario - RJ Motosport Fall Series
  • Sun, Oct 3:CMRC South Western Ontario - Walton Practice

  • Matt Emmerton: Awesomer? Sounds like it needs a $0.25 mocha shot. We tried this a while ago and while they are good, they need a better cooking method.
  • James: Simon, in the network manager, you will see something like this: Available: 23:AF:45:BE:12:FA PANU All you have to do is disconnect from any WiF
  • simon: I don't know why, but I still can't get it to use the tethered connection for internet access. I have paired, trusted and connected, enabled tether

Flickr PhotoStream

    Drew and i at motoparkLol mistyMontreal 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-1002

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