Giter Site home page Giter Site logo

abook2git's Introduction

abook2git

A script to backup Baikal addressbook to git

Reason: if you store your addressbook on a self-hosted Baïkal server (meaning you have access to its db.sqlite file), you might want to save all contacts (vcards) to plaintext files and put them in git.

It will help in case you accidentally delete 50 less-frequently-used contacts from it, and realise it only half a year later (happened to me).

Alternatively, you can use a WebDAV-interface access to the addressbook, and with help of something like davfs access all your contacts as plain files. Then you don't need this script and can just copy them to a git repo, git add, git commit, and git push! (check maybegit function in the script file for exact set of commands)

Requirements

  • Self-hosted Baïkal server (so you have access to its db.sqlite file)

  • A working backup system (so you have a copy of the above file, which inode number changes every time there is a change) - simplest it just to use rsync to copy that file somewhere

  • A private git repo (github gives you few for free)

  • sqlite3 and sqldiff utilities - while script might be adapted to work without the second one, I haven't done so yet.

Installation

  1. clone this repo (or just take the abook2git.sh file)

  2. On the same partition where you have your backup version of db.sqlite file, find a place to keep its hardlink (it will be used to check for changes).

  3. clone or init a private repo somewhere

Usage

After your normal backup procedure (which includes rsync'ing db.sqlite from Baikal server to a backup place), cd into directory with your private repo, and run:

path/to/abook2git.sh path/to/rsynced/db.sqlite path/to/its/hardlink "$(date +"%F %T")"

How it works

To quickly check if there were any changes in the database, this script checks if the hardlink is still in place (first two arguments to the script point to the same file). This script relies on rsync (or other utility) to detect change in the database and break the hardlink.

After that, it exports all contacts into *.vcf files (one file per user), and commits them to git, using output of sqldiff --summary as the commit message.

abook2git's People

Contributors

lex-2008 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.