Git and dropbox05 Mar 2018
This blog is in a git repository and I push it to a remote repository on my server. That means I can always go back to a previous version, even if my computer breaks. Even so, I like the idea of having a backup.
Backing up a git-repository to Dropbox
Git and Dropbox don’t play together nicely so I don’t have my git-repositories in Dropbox. Instead I create a zip-file to the Dropbox each time I commit something.
The nice thing is that Git makes this really easy! Just create a
post-commit file in the
.git/hooks directory, make it executable (
chmod +x post-commit) and add the following:
#!/bin/sh echo "Running post-commit" d=`date -j "+%Y%m%d_%H-%M-%S"` exec git archive -o "/Users/username/Dropbox (Personal)/your-backup-folder/"$d.zip head
This creates zip-files with the filename of the current date/time (
- Automatic backup: I don’t have to think about it
- Backups make sense: a commit is a nice time to backup
.gitignore: no useless files are backed up
- The backup becomes huge: there are no increments or auto-deletions
- Only the files of the current head gets backed up: no git-settings, other branches, tags, etc.
- Dropbox is not a real backup tool: somebody with access to my Dropbox can delete the files
Looking forward to hearing other people’s ideas on this!