migrate#

swordfish.function.migrate()#

Restore the backup. It returns a table containing the restored data of each table. It must be executed by a logged-in user.

The migrate function has the following 3 usages:

  • migrate(backupDir): Restore the backup of all databases in this directory. The restored database name and table name are the same as the original ones.

  • migrate(backupDir, backupDBPath): Restore the backup of the specified database in this directory. The restored database name and table name are the same as the original ones.

  • migrate(backupDir, backupDBPath, backupTableName, [newDBPath], [newTableName]): Restore the backup of the specified table of the specified database in the directory.

    • If newDBPath and newTableName are not specified, the restored database name and table name are the same as the original ones.

    • If newDBPath and newTableName are specified, the restored database name and table name will be newDBPath and newTableName, respectively.

Parameters:
  • backupDir (Constant) – A string indicating the directory to save the backup.

  • backupDBPath (Constant) – A string indicating the path of a database.

  • backupTableName (Constant) – A string indicating a table name.

  • newDBPath (Constant) – A string indicating the new database name. If not specified, the default value is backupDBPath. To specify the parameter, make sure that the storage engine of the backup database is the same as the engine of newDBPath, and the partitionScheme must be the same (except for VALUE). For a VALUE partitioned database, the partitioning scheme of the backup database must be a subset of that of the database to be restored.

  • newTableName (Constant) – A string indicating the new table name. If not specified, the default value is backupTableName.

  • keyPath (Constant, optional) – (Linux only) A STRING scalar that specifies the path to the key file used for restoring an encrypted backup. The key version used for restoring the data must match the version specified during the backup. Note that when restoring an encrypted table, both the backup table and the target table must use the same encryption mode (i.e., the same encryptMode parameter specified during table creation).