replicating a subversion repository with svnsync

svnsync can be used to synchronize a remote subversion repository into a local one, this can be useful as a backup mechanism or to allow a trac (http://trac.edgewall.org/) instance to access subversion when it is impractical to host both on the same computer.

Create the new subversion repository and initialize it
svnadmin create svn.example.com

Create the pre-revprop-change hook script required by svnsync

Initialize the repository 
svnsync init file://$PWD/svn.example.com https://svn.example.com/

Resynchronize the repository with the master
svnsync sync file://$PWD/svn.example.com

Setup crontab to perform this operation every 5 minutes
crontab -e
*/5 * * * * /usr/bin/svnsync sync --non-interactive file:///opt/svn.example.com

NOTE: svnsync creates a lock property and if it fails for some reason this lock will prevent any further synchronizations, to remove it use the following
svn proplist --revprop -r 0 file:///opt/svn.example.com/
svn propdel svn:sync-lock --revprop -r 0  file:///opt/svn.example.com/

running appengine on kubuntu 9

I finally got Google appengine running on my Dell mini9 and heres how ...

Download and upzip the appengine stk

unzip google_appengine_1.2.2.zip

appengine does not run on python 2.6 (the kubuntu default version) so install 2.5 from the commandline

sudo apt-get install python2.5

edit the first line of the dev_appserver.py file in the google_appengine sdk folder

#!/usr/bin/env python

to read

#!/usr/bin/env python2.5

Now that's out of the way we have to fix the permissions on the files in the SDK:

cd google_appengine
sudo chmod -R o+rx ./*

All done, enjoy

get package dependencies using apt-get

If your are compiling software from source under linux you may be able to obtain the required packages using apt-get, first locate the packaged software using apt-cache:

sudo apt-cache search [software]

then look for the appropriate package name and then use apt-get to install the required dev packages, libs etc:

sudo apt-get build-dep [package]

mounting a usb key on linux

To mount a usb key on linux first create a folder as your mount target (do this only once!):

mkdir /media/sda

plug the usb key into the computer and execute the following as root

mount /dev/sda1 /media/sda

the drive will now be accessable in /mount/sda and before removing the device type:

umount /media/sda

before removing the key from the computer.

ssh port forwarding notes

mySQL access using ssh:

  1. open terminal
  2. ssh -L 3306:[username]@[database system]:3306 [username]@[ssh gateway]

Tunneling to an internal system using ssh:

  1. open terminal
  2. ssh -L 7777:[username]@[internal system]:22 [username]@[ssh gateway]
  3. open a second terminal
  4. ssh -p 7777 [username]@localhost

Tunneling to an internal IMAP server through ssh when away from the office:

  1. open terminal
  2. update your /etc/hosts file to override the DNS entry for your internal server with localhost:
    1. 127.0.0.1 imap.example.com
  3. open terminal and execute the following:
  4. sudo ssh -i ~/.ssh/id_dsa -L 993:[internal imap server address]:993 [username]@[ssh gateway]
  5. once logged into the ssh gateway server you may need to keep the connection from timing out by issuing a command such as this:
  6. vmstat 30

Notice that the command is issued as root, this is to allow the forwarding of a privileged port (993 if the connection is SSL encrypted or 143 if not). By forwarding the privileged port there is no need to change any of the settings in you email program since the /etc/hosts file overrides the DNS lookup of your mail server.

delete folders

To delete all of the subversion (.svn), CVS (.cvs) or hidden MAC .DS_Store folders from a directory tree use one of the following commands from the console:

rm -rf `find . -type d -name .svn`
rm -rf `find . -type d -name .cvs`
rm -rf `find . -type d -name .DS_Store`

for files use:

rm `find . -name ‘*.tmp’`

rolling directory backup using cron and tar

First lets create a gzip compressed tar file of the directory to be backed up:

tar --create --gzip --absolute-names --preserve-permissions --file=/backups/etc-`date +"%b_%d_%Y"`.tar.gz /etc

this will create a file called etc-Apr_15_2007.tar.gz in your /backups folder. To create a 7 day rolling backup you can use the following:

tar --create --gzip --absolute-names --preserve-permissions --file=/backups/etc-`date +"%A"`.tar.gz /etc

this will create a backup file called etc-Sunday.tar.gz.
To schedule the backup with cron add the following to your crontab file (crontab -e):

0 1 * * * tar --create --gzip --absolute-names --preserve-permissions --file=/backups/etc-`date +"\%A"`.tar.gz /etc

This will run the backup at 1 am every day. Note the use of \% to escape the % symbol in the crontab file.