HowTo: Synchronize backups with remote servers using git
asked 2015-01-29 12:20:15 +0200
This post is a wiki. Anyone with karma >75 is welcome to improve it.
NOTE: Vault has an extra directory in its .git directory that must be synchronized separately. See Dez's answer for details.
Sailfish backups are stored in a git repository in /home/nemo/.vault. Git is designed to make it easy to keep a local data store syncronized with another server, and this is possible in Sailfish.
On your ssh enabled server with git installed, initialize a bare git repository like this:
git init --bare <path to your repository>
Add your server as a remote like this:
cd /home/nemo/.vault
git remote add <remote name> <your remote git url>
e.g.
git init --bare /var/git/jolla-backup.git (on server)
git remote add origin ssh://me@homeserver/var/git/jolla-backup.git (on phone)
then push the master branch to your remote from the phone:
git push --set-upstream origin master
which will do the initial push then when you create a new backup you can copy that over:
git push origin
Git manages changes rather than the files themselves, so this is very efficient.
If your phone gets wiped/lost, then you should be able to restore your backup vault from the remote using git clone, though I haven't tested this:
git clone <your remote git url> /home/nemo/.vault
My question is, is restoring from a cloned remote vault supposed to work, and is this likely to be a supported way of keeping your phone backups safe in the long term? Pushing git commits is very efficient and versatile for those who can host their own serve, though it's not suitable at all for public services such as github unless you want all your private data copied to the US and possibly published on the web. This could easily get wrapped up in a small app or added to the backup UI with options such as auto-pushing new backups as well as cloning/merging/rebasing remote backups.
Beautiful idea!
I already back up /home/nemo via nightly rsync, but using git is another neat thing. I suppose it could end up being more efficient since rsync treats the repository as black-box binary.
juiceme ( 2015-01-29 13:05:54 +0200 )editI think the beautiful idea is serializing user data to text files and versioning them in git! The implementation is a little odd though. There are symlinks directly into the .git repo...
Andy Branson ( 2015-01-29 16:45:33 +0200 )edit@rdmo stop messing up the code segments
kimmoli ( 2015-04-30 21:09:23 +0200 )edit@kimmoli: Sorry. Manually reverted. Should the '(on phone)' parts be '# (on phone)' ?
rdmo ( 2015-04-30 21:55:05 +0200 )edit