Tuesday, September 25, 2012

Rsync for backups

On my home network I had a need to backup my server and several desktops.  I went out and bought a 2TB external USB drive which I use for this. I decided to use rsync to do the backups and would have it run by cron.

Backup Script.
Here is the script that I wrote to do the backups. 
rsync -av --progress --delete --log-file=/var/log/backups/home-$(date +%Y%m%d)_rsync.log --exclude "/home/username/.gvfs" /home /blackdrive/HomeBackup
rsync -av --progress --delete --log-file=/var/log/backups/root-$(date +%Y%m%d)_rsync.log /root /blackdrive/RootBackup
rsync -av --progress --delete --log-file=/var/log/backups/storage-$(date +%Y%m%d)_rsync.log /storage /blackdrive/StorageBackup
rsync -av --progress --delete --log-file=/var/log/backups/etc-$(date +%Y%m%d)_rsync.log /etc /blackdrive/EtcBackup

I've mounted the drive at /blackdrive  ( Imaginative name.  The case is black).  Some interesting things of note in this script.  I store the logs of the backups in /var/log/backups by date.  and when backing up the home directory on my fedora server I exclude the .gvfs folder.  This is a virtual filesystem used by my desktop that no other processes seem to be able to open and it causes rsync to report problems.  the --delete cleans out files on the target drive that I've deleted on the source drive. 

Cronjob.
I then created a cronjob with this entry:
0 4 * * * /root/backups.sh

This runs the backup script at 4am everyday.  I figured no one in my house would be awake at that time.

If your wondering where the backup of the other desktops occurs.  I mount the /storage volume via nfs and samba on the various boxes in my house and they all push their backups to that folder.

Backup Postgresql Database on Fedora Linux

I had a need to backup my various databases on my home server.  My environment consists of postgresql running on a fedora 17 server.

Backing up
create a cronjob with the command:
crontab -e

put this entry in the file:
50 23 * * * /bin/pg_dumpall -U postgres > /storage/databases/postgres.backup
this tells it to dump all of the databases using the postgres user and put them in a file out in /storage/databases/

Restore
Run the following command as the postgres user.
psql -f /storage/databases/postgres.backup

I back the /storage area up on a nightly basis to external media.

I may in the future incorporate some compression and a file rotation into a script, but at this juncture I haven't had a need for that.

Saturday, January 21, 2012

updating Fedora 15 to 16 using preupgrade-cli

Ok I recently updated my fedora 15 to fedora 16 on my workstation at home.

the really easy way to do this is with preupgrade

I happen to like the command line so I used
 #yum -y install preupgrade  
 #preupgrade-cli "Fedora 16 (Verne)"  

Answer yes to the question of do you want to do this.

Just reboot when done and it will do the upgrade for you.  If you have issues Fedora has a good document at http://fedoraproject.org/wiki/How_to_use_PreUpgrade that has a lot of trouble shooting tips.

Friday, January 20, 2012

How to extract .tar.gz , .tar.bz2, .tgz, and .tar files on linux at the command line

Ok there are lots of flags you can use to extract these but the easiest way that pretty much works for them all is.

 #tar xvf filename  

this should work for all of them on a modern version of linux.

Sunday, September 11, 2011

Released Version 1.2 of Expenses Simply

My Expenses Simply App has been updated to version 1.2.  I've added a feature to email your entries in a comma separated form (easy to import into desktop apps).

Here is the original post announcing the applications.

Tuesday, August 2, 2011

Apps to setup an SSH socks proxy on android

So I had a need to access a website that is on a private home network which resides behind a Linux server. The only way into this box is through an SSH connection that only takes rsa keys.

The two apps I used are sshtunnel and proxydroid. Both of these are available in the market.

My sshtunnel settings



My proxydroid settings




After that just fire up the browser and browse to the site. For quicker access I put the widgets for each application on my desktop so that I can launch them quickly.

Monday, July 25, 2011

Life tracking/hacking

Thought I'd get into a bit of life tracking / hacking and figure out what kind of patterns my body gets into and how they interelate.

First up is to track my sleeping patterns.  I'm going to try to track when I fall asleep initially and when I wake up.  I may follow this up with when I actually get into bed and when I crawl out of bed/hit the sleep alarm.  who knows this might turn into something neat.

I think I might post weekly stats on this blog as I go... who knows.

Wednesday, June 8, 2011

Released Version 1.1 of Expenses Simply

So this is just a minor bug fix.  I've released version 1.1 of my Android App Expenses Simply.  Please give it a whirl and let me know if you are having any issues with it.

Tuesday, May 3, 2011

Replaced the screen on my Dell Streak

So I cracked the screen on my Dell Streak a couples of months back.  It was still functional but the hair line cracks all over it were starting to get really annoying.  I contacted Dell to ask what I would have to do to get them to replace it.  They said I'd need to buy a whole new phone for about $250  ergg.  I searched the web for directions on how to do this myself and came across this excellent article on XDA to replace it.  I order a screen from GadgetFix on ebay and worked my way through the guide.  All done, works perfectly took about 30 minutes to do it.  I have a big thank you to all those on the internet that made it possible for me to do this on $75.

Wednesday, April 20, 2011

Enabling Foreign Keys in sqlite

Once again I must learn to read documentation carefully.

I was perusing the sqlite documentation on implementing foreign keys and created my tables in the way they said to and it wasn't working when I tried to create a row that violated my key constraint.  After a lot of teeth gnashing I finally found a small paragraph in the documentation.  

QUOTED:

Enabling Foreign Key Support

In order to use foreign key constraints in SQLite, the library must be compiled with neither SQLITE_OMIT_FOREIGN_KEY or SQLITE_OMIT_TRIGGER defined. If SQLITE_OMIT_TRIGGER is defined but SQLITE_OMIT_FOREIGN_KEY is not, then SQLite behaves as it did prior to version 3.6.19 - foreign key definitions are parsed and may be queried using PRAGMA foreign_key_list, but foreign key constraints are not enforced. The PRAGMA foreign_keys command is a no-op in this configuration. If OMIT_FOREIGN_KEY is defined, then foreign key definitions cannot even be parsed (attempting to specify a foreign key definition is a syntax error).
Assuming the library is compiled with foreign key constraints enabled, it must still be enabled by the application at runtime, using the PRAGMA foreign_keys command. For example:
sqlite> PRAGMA foreign_keys = ON;
Foreign key constraints are disabled by default (for backwards compatibility), so must be enabled separately for each database connection separately. (Note, however, that future releases of SQLite might change so that foreign key constraints enabled by default. Careful developers will not make any assumptions about whether or not foreign keys are enabled by default but will instead enable or disable them as necessary.) The application can can also use a PRAGMA foreign_keys statement to determine if foreign keys are currently enabled. The following command-line session demonstrates this:
sqlite> PRAGMA foreign_keys;
0
sqlite> PRAGMA foreign_keys = ON;
sqlite> PRAGMA foreign_keys;
1
sqlite> PRAGMA foreign_keys = OFF;
sqlite> PRAGMA foreign_keys;
0
Tip: If the command "PRAGMA foreign_keys" returns no data instead of a single row containing "0" or "1", then the version of SQLite you are using does not support foreign keys (either because it is older than 3.6.19 or because it was compiled with SQLITE_OMIT_FOREIGN_KEY or SQLITE_OMIT_TRIGGER defined).
It is not possible to enable or disable foreign key constraints in the middle of a multi-statement transaction (when SQLite is not in autocommit mode). Attempting to do so does not return an error; it simply has no effect.
It seems I have to turn it on or off..

DOH..  Hopefully this blog entry will help someone.

Monday, April 18, 2011

Android Database Tutorial I found on the net

This is an extremely useful Android database tutorial I found on the net at Another Android Blog.  I had been trying to wrap my head around an easy way to use sqlite in Android and this really put me over the top.  Show the guy some love and send him a donation if it helps you.

Tuesday, April 12, 2011

Android in action, second edition

So I have this Safari Online account through work.  As I get more and more into my Android development hobby I find my self referring to this book "Android in Action" a lot.  I just thought I'd share it with the rest of whoever reads this blog.

10 useful solutions for Android developers courtesy of Shaman.sir

Here's a very useful article for Android developers courtesy of Shaman.sir

Monday, April 4, 2011

Video on Android UI patterns

Here's a video I stumbled soon on ui patterns from Google I/O. Its caused me to rethink a lot of my impressions.

Sunday, April 3, 2011

Android project #2: My Savings

I think I've come up with my next project. My wife is a big time coupon clipper so to help her I'm planning to develop some sort of tracker for couponing. I think initially I'm going to start with calculating savings and then moving on from there. I might even add a bar code reader into it.

Wednesday, March 30, 2011

Kenny Singing in preschool

Thought I'd post this.  Its not really tech related, just a video of my son singing in preschool.

Expenses Simply 1.0

It's here, I've settled on an application name "Expenses Simply".  I did a bunch of Google searching and didn't see any hits on it.  It's a pretty straight forward application.


  • Add expenses using the top bar.
  • Delete a single item by accessing the context menu with a long press.
  • Delete all items through the menu button.
  • Undelete through the menu button.
  • Items are sorted by date.
Please let me know if you have any issues with the application by leaving me a comment on this post.  

It should be on the android market soon. Link to application in the market.
QR code for those that know how to use them.


UPDATE:
Release 1.2 is here see post for details

Friday, March 11, 2011

Easy way to backup over ssh

Here's a really nice easy way to backup a folder over ssh.

tar zcvf - /localfolder | ssh user@remotehost "cat > /storage/location/filename.tar.gz"

Thursday, March 10, 2011

Arduino 3x3x3 LED cube

I got bored the other night and took a first run at an LED 3x3x3 Cube.  Here it is.
The software side is still rather rough so I'm not going to post it yet.

As for how it's put together,  the cathodes (Negatives) on each level are soldered together, the anodes (Positive) are soldered together vertically.  Each column and each level is on a separate digital pin on my Arduino Uno.  The way to turn a LED on or off is by setting the level low and the column high.  To turn more than one off I just turn them on and off really fast.  The eye can't see that it's only one LED at a time.  I think I may switch to using a transistor switch to turn the various columns and levels on or off as that way I can better regulate the amount of power going out to the cube.  Look for updates in the future along with code snippets.

Wednesday, March 9, 2011

Removing "at" jobs in bash.

Here's a basic bash command to remove a job named 'poweroff''  this can remove other at jobs just by changing what you are greping for.  This is handy as I can use this in a script or send it out remotely to multiple systems and it doesn't require any interaction.

for job in `at -l | cut -f 1`; do at -c $job | grep -e 'poweroff' >/dev/null && atrm $job; done



Have fun with it.