Run Gramps from a portable drive
This article's content is incomplete or a placeholder stub. |
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.
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/grampsxx/gramps.ini and remove database-path from the [behavior] section, if present.
- Double click the batch file to run Gramps.
- If necessary, edit the media base path in Gramps to match your removable drive.
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.
The 'xx' in gramps/grampsxx/gramps.ini will depend on the version of Gramps you are running and will be the major & minor version numbers concatenated, so that for version 4.2.xxxx, the path will be gramps/gramps42/gramps.ini
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/grampsxx/gramps.ini and remove database-path from the [behavior] section, if present.
- Run this script to run Gramps.
- If necessary, edit the media base path in Gramps to match your mount point.
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 'xx' in gramps/grampsxx/gramps.ini will depend on the version of Gramps you are running and will be the major & minor version numbers concatenated, so that for version 4.2.xxxx, the path will be gramps/gramps42/gramps.ini
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 >>>
):
> python Python 2.5.1 (r251:54863, Mar 7 2008, 03:41:45) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import bsddb >>> bsddb.__version__ '4.4.5.2' >>> exit()
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.