hamstar / Braincase

A personal knowledge base system for expansion of the mind in a virtual space.
4 stars 1 forks source link

Locking of Backups #272

Closed bhavicp closed 12 years ago

bhavicp commented 12 years ago

Problem

James thinks that we need to lock files when backing up data to prevent inconsistencies. We need to do more research on this and do what is recommended by each software package we use that will be backed up. Currently these are:

It's as simple as backing up the files - ignoring lock files and the cache.

Git

We should clone the bare repo then tar it up.

bhavicp commented 12 years ago

https://www.dokuwiki.org/faq:backup says that backups is "simple and easy" and that the files simply need to be backed up.

hamstar commented 12 years ago

Backing up Git

To backup a git repository with working files we would need to use the git bundle command.

However the directory /home/james/james.git is a bare repository. Git bundle will not work on it, and if it is being changed at the time of the backup there could be inconsistencies[1].

It would probably also be a good time to prune the repository

There are two possible ways to address this.

Option 1: Mirror-clone the repo then bundle

Using bundles is convenient, but the files can be large since it contains the working directory as well. It also does not backup hooks in the bare repo.

git clone --mirror /home/james/james.git /home/james/backups/tmp/james-backup.git
cd /home/james/backups/tmp/james-backup.git
git bundle /home/james/backups/tmp/james.git.bdl --all

Bundles can be accessed just like a repository... they don't even need to be checked out. So restoring could go something like this:

rm -fr /home/james/james.git # be safe
git clone /home/james/backups/tmp/james.git.bdl /home/james/james.git

But from what I can see this will not allow us to rebuild a bare repo... (maybe git clone --bare james.git.bdl?)

Option 2: Bare-clone the repo then tar

This way means the users hooks are backed up... which is probably important - especially if the user has added their own hooks.

git clone --bare /home/james/james.git /home/james/backups/tmp/james-backup.git
tar -czf /home/james/backups/tmp/james.git.tar.gz /home/james/backups/tmp/james-backup.git

Restoring from a tar is the classic:

/home/james/james.git # be safe
tar -xzf /home/james/backups/tmp/james.git.tar.gz -C /home/james/james.git

It is my informed decision that using option 2 is the best way to do this

Sources

  1. http://stackoverflow.com/questions/11154211/git-backups-can-i-copy-a-git-bare-repository-while-its-being-pushed-to
  2. http://heipei.net/2008/03/09/backing-up-a-git-repository-with-git-bundle/
  3. http://stackoverflow.com/questions/1251713/backup-of-github-repo
  4. http://agile.dzone.com/articles/git-backups-and-no-its-not
  5. http://git-scm.com/docs/git-bundle
  6. http://stackoverflow.com/questions/4510582/git-bare-what-to-backup
  7. http://stackoverflow.com/questions/1251713/backup-of-github-repo
  8. http://stackoverflow.com/questions/3517945/back-up-git-repo-archive-mirror-clone-what-about-tar-pzcf
  9. http://www.mail-archive.com/git-users@googlegroups.com/msg02912.html
hamstar commented 12 years ago

For Dokuwiki as well, we would need to ignore:

Sources