copytable

Copies or moves table and index data files for a specified date range to a designated backup path. This command is typically used for periodic backups of table and index data files to NAS storage.

Command properties

ItemDescription
Command typeDriver query
Required permissionAdministrator
License usageN/A
Parallel executionNot supported
Distributed executionNot supported

Syntax

copytable path=STR [from=STR] [to=STR] [tables=STR] [indexpath=STR] [worm=BOOL] [overwrite=BOOL] [incremental=BOOL] [move=BOOL]

Options

path=STR
Backup path for the table. Escape backslashes (\\) if the path contains them (\).
from=STR
Backup start date in yyyyMMdd format.
to=STR
Backup end date in yyyyMMdd format.
tables=STR
Comma-separated list of tables to back up. Supports wildcards (*). When omitted, all tables are included.
indexpath=STR
Path to copy full-text index files. When omitted, only table data files are backed up.
worm=BOOL
When set to t, copies directly to the backup media without creating temporary files (.transfer). When omitted, a temporary file with the .transfer extension is created and then renamed upon completion. Cannot be used with the overwrite or incremental options.
overwrite=BOOL
When set to t, deletes and overwrites existing files on the backup media. Creates a temporary .transfer file, deletes the existing backup file, and renames the temporary file. If the query is cancelled mid-way, the existing backup file is preserved and only the temporary file is deleted. Cannot be used with the worm or incremental options.
incremental=BOOL
When set to t, appends data to the end of existing files on the backup media. No temporary file is created. Cannot be used with the worm or overwrite options.
move=BOOL
When set to t, deletes the source file after copying is complete. The source file is not deleted if the backup file size does not match the original.

Output fields

FieldTypeDescription
_timetimestampTime the backup was processed for the file
typestringType of backup target: table (table data file) or fulltext (full-text index file)
namestringTable name or index name in tablename.indexname format
file_pathstringAbsolute path of the backup file
file_sizelongFile size in bytes
statusstringBackup status
error_msgstringError message when an error occurs. Not assigned for files that are processed successfully.

Error codes

Parse errors
Error codeMessageDescription
41006Invalid backup options.The overwrite, incremental, and worm options are not mutually exclusive.
41009No permission to run the command.Administrator privilege is absent.
41010Invalid date range.The from date is later than the to date.
41011Invalid table name.No table matches the specified name.
41012Start date format ([from]) does not match the format (yyyyMMdd).The from option value is not in yyyyMMdd format.
41013End date format ([to]) does not match the format (yyyyMMdd).The to option value is not in yyyyMMdd format.
41014The specified [file] does not exist or cannot be read.The specified backup path does not exist or cannot be read.
41015Enter a field name.The path option is not specified.
Runtime errors

N/A

Description

The copytable command copies each data file and outputs the current progress as records. When an exceptional situation occurs — for example, a file with the same name already exists, renaming fails, or the backup media runs out of space — the error details are assigned to the error_msg field. You can use this to perform post-processing such as sending an alert email on error. Even if some data files fail to back up, the query continues running until you explicitly cancel it.

By default, a temporary file with the .transfer extension is created during copying and renamed to the original file name upon completion. If the query is cancelled, the temporary file is deleted.

Before starting to copy, the command briefly acquires a table lock to flush buffered data in memory to disk. Tables that are already locked are skipped, as it is guaranteed that they have no data in memory.

When the indexpath option is specified, the command copies the table data files first, then the full-text index files for each table.

Examples

  1. Backing up all tables

    copytable path="/backup/logpresso" from=20260101 to=20260131
    

    Copies January 2026 data files for all tables to /backup/logpresso.

  2. Backing up specific tables with indexes

    copytable path="/backup/logpresso" indexpath="/backup/logpresso" from=20260101 to=20260131 tables="firewall_logs,web_logs"
    

    Backs up data files and full-text index files for firewall_logs and web_logs tables for January 2026.

  3. Incremental backup

    copytable path="/backup/logpresso" from=20260301 to=20260317 incremental=t
    

    Performs an incremental backup by appending data to existing backup files when they already exist.

  4. Backup with source deletion (move)

    copytable path="/backup/logpresso" from=20250101 to=20250131 move=t
    

    Copies data files to the backup path and then deletes the source files.

  5. Overwrite backup

    copytable path="/backup/logpresso" from=20260301 to=20260317 overwrite=t
    

    Deletes and re-copies existing files on the backup media when a file with the same name already exists.