Virtuoso Open-Source Wiki
Virtuoso Open-Source, OpenLink Data Spaces, and OpenLink Ajax Toolkit
Advanced Search
Help?
Location: / Dashboard / Main / VirtTipsAndTricksGuide / VirtTipsAndTricksGuideTablesAndIndexesRecover

How can I backup and restore individual table(s) and individual index(s) on a a new fresh db?

This section describes how to get a part of db tables and restore on a new db.

Additionally, part of the steps from below can be used to backup separate table and recover on same db.

Note: Only effective with Virtuoso 6.0 and later.

Sample scenario

  1. Create a function for dumping the key:

    create procedure bkp_key (in f any, in tb_name varchar, in key_name varchar) { backup_prepare (f); backup_index (tb_name, key_name); backup_flush (); backup_close (); } ;

  2. On the source db execute:

    bkp_key ('mylog.txn', 'DB.DBA.T1', 'T1');

    • This will dump in a "mylog.txn" file the T1 table's primary key.
  3. On source db stop server and do:

    virtuoso +crash-dump +foreground +mode l ## ( lower case L )

    • This will dump the schema tables only into the trx file.
  4. On the target db make sure there is no db file and place the trx file produced by previous step. Execute:

    virtuoso +restore-crash-dump +foreground ;

    • This will create a new db with same db schema as on the source db.
  5. Start the target and do:

    replay ('mylog.txn') ;

    • This will insert the PK data into the table from the source db dump.
  6. If the table in question has other indexes must drop them and re-create them, since they are empty as in previous step we have been restoring only the PK.
Note: following the steps from above can be dumped each index and then replay. Also the steps may be combined for multiple tables and keys in the backup procedure - just needs to be added the corresponding calls to the backup_index() function.

Related

Powered By Virtuoso