Some users want to keep their GRAMPS data on a removable drive, either for portability between computers or for security. This document describes how to accomplish that, and should work whether using a floppy disk, a flash drive, or an external hard drive. Unfortunately, there are no easy instructions for installing GRAMPS and its dependencies on a removable drive, so these instructions assume and require that GRAMPS be installed on any computer to which you connect the drive.

Make Regular Backups

Since removable drives can be more fragile and more easily lost than the hard drive in your computer, be sure to make regular backups of your data if you use this technique. For that matter, you should always make regular backups of important data anyway, because stuff can happen to your hard drive, too. But be especially careful if your data is stored on floppies or flash drives.

Contents

What this does

The magic is done in scripts that you use to start GRAMPS. The scripts figure out the location of the directory they are run from, on your removable drive, then tell GRAMPS to use that directory as its home directory. They do that using the GRAMPSHOME environment variable, which GRAMPS checks to see if its home directory should be somewhere other than the user's home directory. GRAMPS will then read and write its configuration and data to a subdirectory named gramps in directory that contains these scripts.

Installation

Save the scripts below in the directory you want to use as your GRAMPS home directory on the removable drive. When run, the scripts will direct GRAMPS to the directory they are installed in. Edit the SETTINGS section of the scripts you will use, so that the values there are correct for your computer.

If you keep your media files on the removable drive with your GRAMPS data (what use are they otherwise?), be sure to make them use relative paths. Doing so will allow the paths to continue working as you move between computers (with adjustments to the media base path), while absolute paths are almost certain to break.

You will probably need to change the media base path setting in GRAMPS each time you run it on a different computer. You may also need to edit some settings in the scripts for different computers. If there are certain computers which you use regularly that need different settings in the scripts, you can easily make separate script copies for each one, to avoid the need to re-edit them.

Windows

gramps.bat

@echo off
REM Make changes to environment variables local to this block
setlocal
REM START OF SETTINGS
set PYTHON_COMMAND=C:\Python25\pythonw.exe
set GRAMPS_DIR=C:\Program Files\gramps
REM END OF SETTINGS
REM Set GRAMPSHOME to the drive and path of this script
set GRAMPSHOME=%~dp0
REM Go to this script location for good measure
%~d0
cd "%~p0"
REM Run GRAMPS
"%PYTHON_COMMAND" "%GRAMPS_DIR\gramps.py"
REM End the local environment block
endlocal

Usage

Make sure GRAMPS is installed and working on the target computer.

Attach your drive to the target computer.

If necessary, edit the settings in this batch file (or a copy of it) to match the target computer.

Edit gramps/keys.ini and remove database-path from the [behavior] section, if present.

How it works

The setlocal command tells Windows that you want to use a temporary copy of the environment that will be discarded later. The endlocal command tells Windows to go ahead and throw away that temporary environment. What this does is ensure that any changes made to the environment in the script (especially to GRAMPSHOME) do not carry on past the end of the script.

Batch files use %0 to refer to the drive, path and name of the batch file itself. You can also insert codes to reference specific parts of the batch file location. For example, %~d0 refers to just the drive letter, and %~p0 refers to just the path. These codes can be combined. Thus, %~dp0 refers to the drive letter and path where the batch file is located. The batch file uses these to set the value of GRAMPSHOME, then change drive and directory to that location.

Once that is set up, the batch file runs GRAMPS.

Linux

gramps.sh

#!/bin/sh
# START OF SETTINGS
GRAMPS_COMMAND="/usr/bin/gramps"
# END OF SETTINGS
# Set GRAMPSHOME to the path of this script
# Run GRAMPS
GRAMPSHOME="${0%/*}" "$GRAMPS_COMMAND" $*

Usage

Make sure GRAMPS is installed and working on the target computer.

Attach your drive to the target computer and mount it.

If necessary, edit the settings in this script (or a copy of it) to match the target computer.

Edit gramps/keys.ini and remove database-path from the [behavior] section, if present.

How it works

Shell scripts use $0 (or alternately ${0}) to refer to the path and name of the script itself. There are also operators that let you modify that value. The % character is used to remove part of the end of the string, and what follows that character tells what to remove, with * being a wildcard. So ${0%/*} says to remove the last / and everything after it from the path and name of the script, leaving the directory where the script is located.

The script uses that to set the value of GRAMPSHOME, then runs GRAMPS. Setting GRAMPSHOME on the same line as the GRAMPS command makes the value available to GRAMPS. The other way of making the value available, with the export command, would cause the new value to carry over into the environment of the shell that ran this script after GRAMPS has run. That could cause problems running GRAMPS normally later, so we do it this way instead.

Software Versions

While these instructions help you easily move your GRAMPS data between computers, no testing has been done to explore compatibility between different software versions. It is recommended that you only move your data between computers that share the same GRAMPS, Python, database and operating system versions. The more those versions differ, the greater risk of database corruption and data loss. You are encouraged to export your database to GRAMPS XML for safety when moving the data between computers with differing (or unknown) software versions. Do this on your known safe computer before moving to an unknown computer, and again when you have finished with GRAMPS on the new computer before moving back to your regular computer.

GRAMPS

GRAMPS 2.x and 3.x are NOT compatible with each other. The instructions and scripts here are intended for use with GRAMPS 3.0, and it is highly recommended that you ensure the same version of GRAMPS is installed on each computer. A similar technique to that described here could be used with GRAMPS 2.2, but doing so is discouraged due to the risk of database corruption.

Python and Database

GRAMPS stores its data with the BSDDB engine bundled with Python. While the Python and BSDDB developers do make an effort to keep new versions of their software backward compatible, the risk of incompatibility increases with the distance between versions. To determine the versions of Python and BSDDB on a computer, enter the following commands in a terminal window (the input prompts are > and >>>):

Operating System

Moving your GRAMPS data between computers with different operating systems seems possible, but is NOT officially supported. Do so at your own risk!

Backup, backup, backup!

If you do try to move your data between operating systems like this, ALWAYS export your database to GRAMPS XML before changing operating system. If you don't, you may live to regret it.

You can experiment with this by simply putting both the above gramps.bat and gramps.sh scripts in the same directory on your removable drive. If you then run gramps.bat on Windows and gramps.sh on Linux, GRAMPS will use the same configuration and data files on both operating systems.

Since this behavior is neither encouraged nor tested, there are any number of possible problems you may encounter. Here are some of the known problems you will see:

When first opening a database after changing operating system, you may get an error that says "Low level database corruption detected" and instructs you to use the Repair button to fix the problem. This seems to work, but it is not known for sure whether any data loss may occur in the process.

You will need to update the media base path in Preferences every time you switch operating system.

If your media files are referenced with any directory information (either absolute paths or relative paths with subdirectories), each path will only work on the operating system on which it was entered.