• Backups for Google Calendar – a ruby application

    I admit I’ve not been so busy posting the to blog this year. One thing that’s kept me busy has been learning Ruby on Rails making my first opensource application.

    I’m a hobby programmer, so the idea of sharing my code is worrying. I’m sure there are lots of errors, bad practice and so on. On the other hand, I had a problem to solve at work and the application I wrote may help others. I use lots of open source applications for home and work so it seems only right to share my efforts with others.

    What have I created? An application that backs up google calendars for all of our office users.

    Why? Because occasionally we delete something we didn’t mean too. For example Mrs X phones up to cancel an appointment with Mr A. Mr A is out of the office but Mr B can edit Mr A’s calendar, so deletes the appointment. Except Mr A had all the Mrs X contact information on that appointment and hadn’t yet created our own internal computer record. We’ve no longer got any way of contacting Mrs X.

    How? The application I wrote reads the Private XML feed of a google calendar. That contains the most recent newly created or amended appointments. I check each entry in that feed to see if it’s new, or if it’s an existing appointment that’s been modified. If they are new or modified, I add them to a database. If they’re old and unchanged, I ignore them.

    One thing to note – it doesn’t restore appointments. As you’ve got all the content though, it shouldn’t be so difficult to add it again should you need to.

    Where to get it? I’ve shared it through github – http://github.com/steveroot/Google-Calendar-Backup


  • CRON – multiple cron jobs on one line (running consecutively, not concurrently)

    This post will (hopefully) remind me in the future how to do something very simple.

    A crontab is normally running one command on each line. EG:

    # m h dom mon dow command
    01 00 * * * /home/cronscripts/vine-warn-when-large-user-profile
    05 00 * * * /home/cronscripts/vine-get-remote-pc-backup.sh
    01 01 * * * /home/cronscripts/vine-samba-users
    01 02 * * * /home/cronscripts/vine-database-backups

    So the above jobs run at 00:01, then 00:05, then 01:01am then 02:01am.

    Instead, I can run these cron tasks one after the other by putting && between each task. EG:

    # m h dom mon dow command
    01 00 * * * /home/cronscripts/vine-warn-when-large-user-profile && /home/cronscripts/vine-get-remote-pc-backup.sh && /home/cronscripts/vine-samba-users && /home/cronscripts/vine-database-backups

    So these jobs start running at 00:01am. When vine-warn-when-large-user-profile finishes, vine-get-remote-pc-backup.sh starts immediately, and so on.

    Why is this useful?

    I have several backup scripts for our linux servers. Each script creates a tar archive of a directory, compresses it, SFTP’s it off site, then deletes the tar archive from the server.

    If the scrips all run at the same time, the server runs out of disk space. I need them to run one after the other. I can’t effectively guess when to start each one. The backup can’t start until after midnight and must be finished by 7am when users are likely to start work again. Some directories can take minutes to archive, compress, send, delete. Others can take 2 or 3 hours. One server also collects backups from a couple of other places, so that script has to complete before others start too.

    Running this scripts concurrently means no useful transfer time is lost and I don’t have to guess the time each script will take to run.


  • cciss-vol-status on Ubuntu didn't work, it was cciss_vol_status

    In the hope I find this post next time I’m trying to monitor a SmartArray drive controller, A fresh install of Ubuntu 10.04, installing package cciss-vol-status didn’t seem to work. I couldn’t even find the file on the system using ‘locate’.

    For some reason, it installed as cciss_vol_status (using underscores instead of hyphens).


Search this site


Free apps

  • birthday.sroot.eu – Your birthday or other celebration date based on [years on other planets] / [how many seconds/days] / [how far you’ve travelled around the sun]
  • stampulator.sroot.eu – Calculates the combination and how many 1st, 2nd, large 1st and large 2nd class Royal Mail stamps you need on large envelopes and packets

Recent posts


Archives


Categories