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.