Monthly Archive for January, 2006Page 2 of 2

How to convert an sqlite 2 database into an sqlite 3 database

sqlite2 path/to/olddb .dump > backupfile
sqlite3 path/to/newdb < backupfile

Google Answers

Google Answers is a service where a research request can be posted with a price, and then people on the web can do the research and submit the results. A while back I thought I would give Google Answers a try, mostly to see how the process went, but also because I was genuinely curious about this question:

Where is the “bottom” in the stock market? I realize that it is basically all driven by hype, psychology, etc now, but in theory, what is being traded? Why would/should a corporation’s performance theoretically affect the value of it’s [sic] share [sic]? is it something to do with what happens if the corporation dissolved [sic]?

You can see the entry and the responses it generated here.

When I got the first response, I had basically full confidence in what elids said. elids seemed reasonably knowledgable, and was certainly very confident and enthusastic. Then elwtee comes on the scene and shakes everything up with a completely different answer! elwtee seems just as knowledgable and self-assured as elids!

It makes me wonder about who these two people are, what their motivations are, and what they do with their time. Keep in mind that these were both left as comments to the question and not submitted as answers, so they aren’t in it for the money.

My Backup Scripts

This is a followup to Operation: Simple Functional Backup.

Okay, here are the glorious scripts I came up with.

I call this one dailybackup: [UPDATE: a newer version of my script is posted here]

BASH:
  1. #!/bin/sh
  2.  
  3. SOURCEDIR=/Users/john ;
  4. ARCHIVEROOT=/Volumes/fire/backup ;
  5. ARCHIVENAME=PowerBookHomeDirectory ;rsync \
  6. -a –delete -delete-excluded \
  7. –exclude “/Music/” \
  8. –exclude “/tmp/” \
  9. –exclude “/Library/Caches/” \
  10. –exclude “/Desktop/downloads/” \
  11. $SOURCEDIR/ $ARCHIVEROOT/$ARCHIVENAME ;

I call this one monthlybackup:

BASH:
  1. #!/bin/sh
  2.  
  3. # Comment this out if you want to use the built-in disk burner. If you want to use an external device find it’s name from `hdiutil burn -list`
  4. DEVICE=‘-device IOService:/MacRISC2PE/pci@f4000000/AppleMacRiscPCI/firewire@E/AppleFWOHCI/IOFireWireController/IOFireWireDevice@30e00150abd577/IOFireWireUnit/IOFireWireSBP2Target/IOFireWireSBP2LUN/com_apple_driver_Oxford_Semi_FW911/IOSCSIPeripheralDeviceNub/IOSCSIPeripheralDeviceType05/IODVDServices’ ;
  5.  
  6. # Where the scripts should keep its files while working with them. everything is deleted in the end anyway so /tmp should be suitable.
  7. SCRATCH=/tmp ;
  8.  
  9. # Where dailybackup keeps its archive
  10. ARCHIVEROOT=/Volumes/fire/backup ;
  11.  
  12. # The name of the archive that dailybackup makes.
  13. ARCHIVENAME=PowerBookHomeDirectory ;
  14. # ARCHIVENAME=testtest ;
  15.  
  16. # The size of the chunks that gsplit should make, for DVD or CD.
  17. # I have not experimented with how much overhead there is for each type.
  18. # Please let me know if you have found an optimal size: john AT johnjosephbachir DOT org
  19. MEDIASIZE=4300 ;
  20. #MEDIASIZE=600 ;
  21.  
  22. # stop editing ###########################
  23. cd $ARCHIVEROOT ;
  24. echo “–creating $ARCHIVENAME.tar.gz–” ;
  25. tar czf $SCRATCH/$ARCHIVENAME.tar.gz $ARCHIVENAME ;
  26. cd $SCRATCH ;
  27. echo “–splitting $ARCHIVENAME.tar.gz into $MEDIASIZE MegaByte pieces–” ;
  28. gsplit –numeric-suffixes -b$MEDIASIZE“m” $ARCHIVENAME.tar.gz $ARCHIVENAME.tar.gz_ ;
  29.  
  30. echo “Pieces:”
  31. TOTAL=0 ;
  32. for i in $ARCHIVENAME.tar.gz_* ; do
  33. echo ”   $i” ;
  34. ((TOTAL++)) ;
  35. done;
  36.  
  37. echo “Archive has been split into $TOTAL part(s).” ;
  38.  
  39. echo “–deleting $ARCHIVENAME.tar.gz–” ;
  40. rm $ARCHIVENAME.tar.gz ;
  41.  
  42. COUNTER=0 ;
  43. for i in $ARCHIVENAME.tar.gz_* ; do
  44. ((COUNTER++)) ;
  45. NAME=$ARCHIVENAME.tar.gz_“$COUNTER”_of_“$TOTAL” ;
  46. mkdir $NAME ;
  47. mv$i$NAME ;
  48. echo “–creating disk image of $NAME–” ;
  49. hdiutil create -fs HFS+ -volname $NAME -srcfolder $NAME$NAME”.dmg ;
  50. echo “–deleting $NAME–” ;
  51. rm -r $NAME ;
  52. done;
  53.  
  54. for i in *.dmg ; do
  55. echo “–burning $i–”
  56. hdiutil burn -noverifyburn $DEVICE$i” ;
  57.  echo “–deleting $i–” ;
  58.  rm$i” ;
  59. done;

They could use some further refinement, but for the most part I am happy as a clam.

Two initial questions/problems:

  1. Do any of my geeky readers have recomendations for other things I should exclude in the first script?
  2. split seems to only want to make chunks that are about 600 megabytes each, even though I am specifying 4700 megabytes (DVD size). This is really annoying, but I am assuming that either I am missing something simple, or another solution will present itself.

    update: the problem is the split that ships with OS X seems to have a max size of 2^32 bytes. I installed the gnu coreutils using darwinports (sudo port install coreutils, which installs all the utils as "g__", very nice. If you get the coreutils source from gnu, it builds without a hitch but will install without the "g" prefix), switched to gsplit, and ta-da, everything is working.

Operation: Simple Functional Backup

Okay, after months and years of wanting a good backup solution, searching the net, and trying various scripts and shareware, I still don't have a simple effective backup solution.

I have a .mac account (It's overpriced and kind of flakey, I know I know) and with it comes Backup. Backup used to be pretty weak, but the newest version, version 3, Is put together pretty darn well in most regards. The interface is simple and functional, the preset backup plans are handy for novice users (I even use a couple of them myself), and it can handle incremental backups to disk or network, and backups that span multiple CDs or DVDs.

One place where it is sorely lacking is in the way it does incremental backups. If a file has changed since the last time you backed up, it makes a new copy of the entire file, instead of just the differences between the two files. So if you are working on a 3 gig file and only make 100k worth of changes every day, Backup will make another copy of your 3 gig file every day, which of course eats up your storage space very quickly.

If you don't mind loosing a week's worth of incremental backups, you can wipe all of your backups (including the original) and start over once a week, but there is no way to automate this.

Another problem is that as far as I can tell, it uses no compression whatsoever.

So I have decided to roll my own backup solution using rsync. There are a lot of these floating around out there, but they all seem to have more features or environment requirements than I need or want to deal with.

My system will have 2 scripts.

  1. A script which either I or a cron job runs every day or so, and does a compressed rsync on my home directory, excluding certain directories (Music, Library/Caches, Desktop/downloads, and tmp).
  2. A script that I run once a month or so, which makes a copy of the archive created by the first script, splits it into DVD sized chunks, and makes a .dmg out of each one, which I can then use Finder or Toast to burn to disk.

This solution actually won't solve the incremental problem, because I am no longer making incremental backups. But if I am not mistaken, the only way to make a complete new backup each day using Backup, without doing incremental backups, is to make a completely new backup from scratch.

Also, because I will be compressing the backups, they will hopefully fit on 1 DVD instead of 2 like they do now.

I'll keep both my readers posted on my progress.

UPDATE: here's what I came up with




Close
Powered by ShareThis