Giter Club home page Giter Club logo

dump's Introduction


dump

Logical backup and restore of a Tarantool instance.

Why you need a logical backup

Tarantool provides a physical backup with box.backup module. But you may still want a logical one.

Here's why:

  • A logical backup contains tuples, not files. By making a logical backup, you ensure that the database server can read the contents of the database. A logical backup sees the database through the same lense as your application.
  • If Tarantool binary file layout changes, you still can restore data from a logical backup.
  • You could use a logical backup to export data into another database (although we recommend using Tarantool's MySQL or PostgreSQL connectors for this).

How to use

This module takes each space in Tarantool and dumps it into a file in a specified directory. This includes data for system spaces _space and _index, which are dumped first. The restore is performed in the opposite order, when files for restore are sorted according to their id (system spaces have id < 512, so their data is naturally restored first). Restoring the system spaces first ensures that all definitions for user-defined spaces are already in place when a user-defined space dump file is restored.

Preparation

Ensure that the database is not being changed while dump or restore is in progress.

Execution

local status, error = require('dump').dump('/path/to/logical/backup')

The path should not exist, or be an empty directory. It is created if it does not exist. The command then dumps all space and index definitions, users, roles and privileges, and space data. Each space is dumped into a file in the path named <space-id>.dump.

local status, error = require('dump').restore('/path/to/logical/backup')

Please note that this module does not throw exceptions, and uses Lua conventions for errors: check the return value explicitly to see if your dump or restore has succeeded.

This command restores a logical dump.

Advanced usage

You can use a filter function as an additional argument to dump and restore. A filter is a function that takes a space and a tuple and returns a tuple. This function is called for each dumped/restored tuple. It can be used to overwrite what is written to the dump file or restored. If it returns nil the tuple is skipped.

For example, 'filter' option can be used to convert memtx spaces to vinyl as shown below:

dump.restore('dump', {
    filter = function(space, tuple)
        if space.id == box.schema.SPACE_ID then
            return tuple:update{{'=', 4, 'vinyl'}}
        else
            return tuple
        end
    end
})

Details

The backup utility creates a file for each dumped space, using space id for file name. The dump skips spaces with id < 512 (the system spaces), with the exception of tuples which contain metadata of user-defined spaces, to ensure smooth restore on an empty instance. If you want to restore data into an existing space, delete files with ids < 512 from the dump directory and create the destination space manually with Lua during restore. Alternatively, you can keep all files with id < 512, this will restore or space definitions, and your particular space file, and pass this to dump. For more intellectual filtering, use dump/restore filtering.

dump's People

Contributors

kostja avatar lenkis avatar locker avatar totktonada avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dump's Issues

Не информирует о ошибке

Сдампил гигабайтный спейс, и пытаюсь восстановить, на чистый инстанс один спейс 520.dump

Процедура проходит без ошибок, но по времени очевидно что ничего не восстановлено.

Включив же дебаг-лог, оказывается что критическая ошибка.
Reading contents of /home/den/tnt-temps/back/ Found 1 files SystemError at /build/tarantool-1.10.2.149/src/lua/fio.c:53

Если спейс маленький, то можно и не заметить что ничего не восстановилось, поэтому хорошо бы информировать о успешности процесса.

Provide versioned rocks release

We version all of our rocks packages to ensure stability, and I can't specify a version to install from this package as it's not provided in the rocks repo, it seems to check out whatever is on the master branch of this repo, which could change without our knowledge.

Please could we have a versioned release to pin our rockspec to

Unneeded space trying to restore

Пройдя ошибку описанную https://github.com/tarantool/dump/issues/9
наткнулся на Duplicate key exists in unique index 'user' in space 'auth_oauth_app'

Но восстанавливается вовсе не этот спейс!
В директории только дамп другого спейса, все остальные остались в другой виртуалке.
Спейс auth_oauth_app вообще пустой в сдампленной базе, а восстанавливаемый - почти гигабайт

По описанию, если в восстанавливаемой директории только дамп одного спейса, то восстанавливается только он. Но дебаглог показывает:
`Reading contents of /home/den/tnt-temps/back/

Found 1 files

Started restoring space auth_oauth_app
`
Почему восстанавливается auth_oauth_app??
Поиск внутри дампа по слову "oauth" ничего не нашел
Может это название ошибочно берется из создаваемого в процессе модулем authman?

Или может это связано с тем что дампил ТТ1.9, а восстанавливается на 1.10.2-149?

Add an options to dump/restore spaces by names, not ids, and omit system spaces

Currently restoration of system spaces may be hard enough (for ex between 1.7 and 1.6)
It would be great to have an option to dump/restore spaces by their names (since usage of ids is not portable)

Ex:

require 'dump'.dump("path/to/backup", { names = true, system = false })
require 'dump'.restore("path/to/backup", { names = true })

Report dump/restore progress

Neither dump nor restore reports how much time it is going to take. This is annoying as the user has to guess, e.g. by looking at the xlog file size. We should make the logging more verbose. For example, we could log the elapsed time and the remaining time estimate every time a chunk of say 1GB is dumped or restored.

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.