<< Click to Display Table of Contents >> BackupDatabase |
Creates an on-demand backup of the PDQ Inventory database. This is the command line equivalent of the Backup Now button in Options > Database Settings.
When no path is specified, the backup is written to the configured backup directory. When a directory path is specified, a timestamped filename is generated automatically. When a full file path is specified, the backup is written to that exact location.
PDQInventory BackupDatabase [-Path <path>] [-Force]
Parameter |
Required |
Description |
|---|---|---|
-Path |
No |
Path for the backup. Supports absolute and relative paths. Path handling: •Paths ending with a separator (\ or /) are treated as directories; a timestamped filename is generated. •Paths with a file extension are used as the exact backup file path. •Paths without a trailing separator and without an extension are treated as a file path with .db appended. •If not specified, uses the configured backup directory from Options > Database Settings. |
-Force |
No |
Creates parent directories without prompting when the specified path does not exist. Use this flag for unattended scripts and scheduled tasks. |
Exit Code |
Meaning |
|---|---|
0 |
Backup completed successfully. |
1 |
Backup failed (general error). |
2 |
Insufficient disk space to write the backup. |
3 |
Insufficient permissions to write to the specified location. |
4 |
Invalid or inaccessible path. Also returned when the directory creation prompt is cancelled. |
5 |
Database is locked or in use and cannot be backed up. |
6 |
Default backup path is not configured. Use -Path to specify a backup location, or configure a backup directory in Options > Database Settings. |
Backup to the configured backup directory:
PDQInventory BackupDatabase
Backup to a specific directory (filename is generated automatically):
PDQInventory BackupDatabase -Path "C:\Backups\PDQ\"
Backup to a specific file:
PDQInventory BackupDatabase -Path "C:\Backups\pre-upgrade-backup.db"
Backup to a new directory without prompting:
PDQInventory BackupDatabase -Path "C:\Backups\PDQ\" -Force
Use in a PowerShell script before making changes:
PDQInventory BackupDatabase -Path "C:\Backups\pre-change.db"
if ($LASTEXITCODE -eq 0) {
Write-Host "Backup succeeded, proceeding with changes."
} else {
Write-Warning "Backup failed with exit code $LASTEXITCODE, aborting."
exit 1
}
NOTE: The backup uses SQLite's built-in hot backup API, which allows the database to remain in use during the backup. It is not necessary to stop the background service before running this command.
NOTE: Every backup is verified with an integrity check before the command returns. If the backup is corrupted the file is deleted and the command returns exit code 1.
NOTE: When -Path is not specified, this command applies the configured Keep retention setting (deleting oldest backups). When -Path is specified, retention is not applied. The Last backup timestamp shown in Options > Database Settings is not updated by this command - that timestamp belongs to the automatic backup schedule and is only updated when a scheduled or Backup Now backup runs through the background service.
NOTE: Backup compression (.db.cab) is not applied by the CLI even when Compress backups is enabled in Options > Database Settings. CLI backups are always written as uncompressed .db files.
© 2026 PDQ.com Corporation. All rights reserved.
PDQ.com is a trademark of PDQ.com Corporation. All other product and company names are the property of their respective owners.
Help Version: 20.1.14.0