Next: , Previous: , Up: Command Reference   [Contents][Index]

4.10 Database

All of these commands require that the database is specified, either via --db or the current workspace.

mtn db changesetify [--db=dbfile]

Converts the database to the changeset format.

This is only needed when upgrading very old monotone databases, created with monotone versions less than 0.15.

mtn db check [--db=dbfile]

Monotone always works hard to verify the data it creates and accesses. For instance, if you have hard drive problems that corrupt data in monotone’s database, and you attempt to retrieve this data, then monotone will notice the problem and stop, instead of silently giving you garbage data.

However, it’s also nice to notice such problems early, and in rarely used parts of history, while you still have backups. That’s what this command is for. It systematically checks the database dbfile to ensure that it is complete and consistent. The following problems are detected:

This command also verifies that the SHA1 hash of every file, manifest, and revision is correct.

mtn db dump [--db=dbfile]

This command dumps a sequence of SQL instructions representing the entire state of dbfile to the standard output stream. It is a very low-level command, and produces the most “recoverable” dumps of your database possible. It is sometimes also useful when migrating databases between variants of the underlying SQLite database format.

mtn db execute [--db=dbfile] sql-statement

This is a debugging command which executes sql-statement against your database, and prints any results of the expression in a tabular form. It can be used to investigate the state of your database, or help diagnose failures.

mtn db fix_certs [--db=dbfile] [--drop-bad-certs]

Attempt to fix bad certs.

Older monotone versions could sometimes associate certs with the wrong key. This fixes such certs if you have the correct key, and if --drop-bad-certs is given, drops any certs that you don’t have the correct key for. This should only be needed if you had such certs in your db when upgrading from monotone 0.44 or earlier, or if you loaded such certs with ’mtn read’.

mtn db info [--db=dbfile] [--full | --concise]

This command prints information about the monotone database dbfile, including its schema version and various table size statistics. --full prints additional info about timestamps; the default is --concise.

mtn db init [--db=dbfile]

This command creates and initializes a new monotone database at dbfile.

mtn db load [--db=dbfile]

This command applies a raw SQL statement, read from the standard input stream, to the database dbfile. It is most useful when loading a database dumped with the dump command.

Note that when reloading a dumped database, the schema of the dumped database is included in the dump, so you should not try to init your database before a load.

mtn db migrate [--db=dbfile]

This command attempts to migrate the database dbfile to the newest schema known by the version of monotone you are currently running. If the migration fails, no changes should be made to the database.

If you have important information in your database, you should back up a copy of it before migrating, in case there is an untrapped error during migration.

mtn db regenerate_caches

Regenerates the caches stored in the database.

This is only needed to recover from a newly discovered bug in monotone, or if your database becomes corrupted for some other reason.

mtn db rosterify

Converts the database to the rosters format.

This is only needed when upgrading very old monotone databases, created with monotone versions less than 0.15.

mtn db set_epoch branch epoch

Sets the branch’s epoch. See Rebuilding ancestry for discussion of epochs.

mtn db version [--db=dbfile]

This command prints out just the schema version of the monotone database dbfile.

mtn local kill_certs selector certname [certval]

This command deletes certs with the given name on revisions that match the given selector (see Selectors). If a value is given, it restricts itself to only delete certs that also have that same value. Like mtn local kill_revision, it is a very dangerous command; it permanently and irrevocably deletes historical information from your database. Also like kill_revision, this only deletes the certs from your local database; if there are other databases that you sync with which have these certs they will reappear when you sync, unless the owners of those databases also delete those certificates locally.

Early versions of monotone had db kill_tag_locally and db kill_branch_certs_locally commands. These can be emulated with local kill_certs i: tag TAG and local kill_certs i: branch BRANCH, respectively.

mtn local kill_revision id

This command “kills”, i.e., deletes, a given revision (see Selectors), as well as any certs attached to it. It is a very dangerous command; it permanently and irrevocably deletes historical information from your database. If you execute this command in a workspace, whose parent revision is the one you are about to delete, the killed revision is re-applied to this workspace which makes it possible for you to fix a problem and commit again later on easily. For this to work, the workspace may not have any changes and/or missing files.

There are a number of other caveats with this command:

Next: , Previous: , Up: Command Reference   [Contents][Index]

Quick Links:    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status