Backup architecture - hamstar/Braincase GitHub Wiki

See also: Backup format

The backup architecture is the most important feature in the project, putting an emphasis on data survive-ability. It is responsible for making sure that users of the system cannot lose more than 24 hours worth of entered knowledge. It must store the data on an external service so that if the server goes down or is disabled for any reason, permanently or temporarily the knowledge contained within is available to individual users.

Diagram

http://i.imgur.com/7bxjI.png

Backup Tools

Ruby Backup 3

This is a ruby gem that allows a user to backup their data by running a backup with parameter stored in a backup model that is generated. The backup model and configuration are stored in each users home directory under a folder called Backup (i.e. /home/james/Backup). Every night at midnight the braincase-backup script is run which iterates through each Braincase user on the system and performs a backup of their data.

The backup model is slightly enhanced by Braincase objects to make it more user agnostic, and allows the same model to be used across users. It logs output of it's operations to the users home folder (under /home/james/logs/backup.log.

Cron

Cron is the standard linux scheduling daemon. It runs the backup at midnight every night and logs it's output to /var/log/cron.log.

Backup Locations

Backup Scripts

  • ~/Backup/models/daily_backup.rb: an object oriented backup class that ruby backup uses
  • [braincase-backup](/hamstar/Braincase/wiki/braincase-backup): runs the nightly backups

The Actual Backups

  • Local: /home/user/backups/daily_backup/yyyy.mm.dd.hh.mm.ss
  • Dropbox: /home/user/Dropbox/Braincase/Memorize/yyyy.mm.dd.hh.mm.ss

External Backups

Dropbox

Dropbox is a cloud storage service that allows users to store 50GB of data on the internet. It allows synching data and will only upload changed data. The following is a description of how Dropbox works taken from http://webapps.stackexchange.com/questions/26692/when-does-dropbox-delta

Dropbox uses a binary diff algorythm to break down all files into blocks, and only upload blocks that it doesn't already have in the cloud. All of this is done locally on your computer.

Dropbox doesn't just use your files that you have already uploaded, it aggregates everyones files into one database of blocks, and checks each local block hash against that database.

Dropbox no longer de-duplicates across all users (there was a bug that allowed people to pirate files by only having a hash of the file; rather than fix the bug, Dropbox opted to simply disable the feature). The blocks will only not be uploaded if they're already in your own account.

Users can enable Dropbox on their Braincase accounts using the web interface. They receive an email with the authorization link upon completion of the process.

When the backup is exported to Dropbox the timestamped folder is copied into Braincase/Memories.

~/backups/daily_backup/2012.10.25.00.00.01 => ~/Dropbox/Braincase/Memories/2012.10.25.00.00.01

Special Considerations

Git and Locking

Git presented an issue where it's files can be backed up in an inconsistent state if changes are being pushed at the time of backup. Because we don't want to risk corrupting the bare repository we make a bare mirror of the bare repository before the backup - back it up - then delete the mirror once the backup is finished.

Improvements

  • Currently daily_backup.rb is copied to the users home, it is user agnostic so should be linked so users backup script is upgraded with the system