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
| Item | Description |
|---|---|
| Command type | Driver query |
| Required permission | Administrator |
| License usage | N/A |
| Parallel execution | Not supported |
| Distributed execution | Not supported |
Syntax
Options
path=STR- Backup path for the table. Escape backslashes (
\\) if the path contains them (\). from=STR- Backup start date in
yyyyMMddformat. to=STR- Backup end date in
yyyyMMddformat. 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.transferextension is created and then renamed upon completion. Cannot be used with theoverwriteorincrementaloptions. overwrite=BOOL- When set to
t, deletes and overwrites existing files on the backup media. Creates a temporary.transferfile, 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 thewormorincrementaloptions. 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 thewormoroverwriteoptions. 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
| Field | Type | Description |
|---|---|---|
| _time | timestamp | Time the backup was processed for the file |
| type | string | Type of backup target: table (table data file) or fulltext (full-text index file) |
| name | string | Table name or index name in tablename.indexname format |
| file_path | string | Absolute path of the backup file |
| file_size | long | File size in bytes |
| status | string | Backup status |
| error_msg | string | Error message when an error occurs. Not assigned for files that are processed successfully. |
Error codes
Parse errors
| Error code | Message | Description |
|---|---|---|
| 41006 | Invalid backup options. | The overwrite, incremental, and worm options are not mutually exclusive. |
| 41009 | No permission to run the command. | Administrator privilege is absent. |
| 41010 | Invalid date range. | The from date is later than the to date. |
| 41011 | Invalid table name. | No table matches the specified name. |
| 41012 | Start date format ([from]) does not match the format (yyyyMMdd). | The from option value is not in yyyyMMdd format. |
| 41013 | End date format ([to]) does not match the format (yyyyMMdd). | The to option value is not in yyyyMMdd format. |
| 41014 | The specified [file] does not exist or cannot be read. | The specified backup path does not exist or cannot be read. |
| 41015 | Enter 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
-
Backing up all tables
copytable path="/backup/logpresso" from=20260101 to=20260131Copies January 2026 data files for all tables to
/backup/logpresso. -
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_logsandweb_logstables for January 2026. -
Incremental backup
copytable path="/backup/logpresso" from=20260301 to=20260317 incremental=tPerforms an incremental backup by appending data to existing backup files when they already exist.
-
Backup with source deletion (move)
copytable path="/backup/logpresso" from=20250101 to=20250131 move=tCopies data files to the backup path and then deletes the source files.
-
Overwrite backup
copytable path="/backup/logpresso" from=20260301 to=20260317 overwrite=tDeletes and re-copies existing files on the backup media when a file with the same name already exists.