3CX Backup & Restore Commands

Introduction

These commands can be used to create scripts and schedule backup and restore operations, externally to the built-in 3CX Management Console functionality. This is useful when hosting on cloud for archiving in bulk PBX users, data and configuration for safekeeping.

BackupCmd

The BackupCmd command line tool enables backups to be taken with these options:

-l, --log=VALUE

Log filename or full file path, e.g.

--log=/var/lib/3cxpbx/bak_cmd_run.log

-f, --file=VALUE

*Filename to backup in default backup location or full zip archive path, e.g.

--file=/home/pi/backups/backup.zip

-o, --options=VALUE

Backup options, specifying to include in the backup:

  • ALL - include everything, or
  • add following comma-separated options to only include:
  • CH - Call History
  • LIC - License
  • FQDN - Phone System FQDN
  • PROMPTS - Voice Prompts
  • FW - Phone Firmware
  • REC - Recordings
  • VM - Voicemails

--pwd=Value

Encrypt backup files with password (V15.5 Sp2 onwards), e.g.

--pwd=MyB4ckup_Pa55

-h, --help

Display command help

--noemail

Do not send an email on backup completion, successful or not.

Notes:

  • Mandatory options are denoted above with *.
  • Specifying an existing backup file with the
    -f
    or
    --file
    switch, overwrites it without warning.
  • Specify an existing log file with the
    -l
    or
    --log
    switch to append to.
  • Values, filenames and paths with space(s) are not recommended, otherwise they need to be enclosed in double quotes when used in option arguments.
  • Ensure that specified backup and log file paths are writable on Linux by the “phonesystem” user, and on Windows by the executing user.

General

Specifying a filename with the “--file” or “--f” switch as a:

  • filename, the backup file is stored in the backup location configured in the Management Console, e.g.

BackupCmd -f=my-pbx_full_bak.zip

  • full filename path, overrides the configured location and stores the backup file in the specified path, e.g.

BackupCmd -f=c:\backup\my-pbx_full_bak.zip

When the “--log” argument is specified, it has to be followed by either:

  • a filename to store the log in the current working directory, e.g.

BackupCmd -l=bak_cmd.log -f=my-pbx_full_bak

  • a full path to a local filename to override and store in the file specified, e.g.

BackupCmd -l=c:\backup\bak_cmd.log -f=my-pbx_full_bak

Backup Command on Windows

To use the backup command on Windows, open a command prompt with administrative privileges, change to this directory using

cd C:\Program Files\3CX Phone System\Bin
and run the command to:

  • Display available backup command options:

BackupCmd.exe --help

  • Make a full PBX backup and keep a log:

BackupCmd.exe --file=full_pbx_backup.zip --options=ALL --log=backup_cmd.log

  • Make a backup including call history, license and FQDN, keeping a log:

BackupCmd.exe --file=partial_pbx_backup.zip --options=CH,LIC,FQDN --log=backup_cmd.log

Backup Command on Linux

To use the backup command on Linux, run the command in a terminal as user

phonesystem
using
sudo
to:

  • Display available backup command options:

sudo -u phonesystem 3CXBackupCmd --help
command to see all available options.

  • Make a full PBX backup and keep a log:

sudo -u phonesystem 3CXBackupCmd --file=full_pbx_backup.zip --options=ALL --log=/var/tmp/pbx-backup_cmd.log

  • Make a backup including call history, license and FQDN, keeping a log:

sudo -u phonesystem 3CXBackupCmd --file=partial_pbx_backup.zip --options=CH,LIC,FQDN --log=/var/tmp/pbx_backup_cmd.log

RestoreCmd

The RestoreCMD tool enables to restore backups via command line with these options:

-l, --log=VALUE

Log path or filename

-f, --file=VALUE

*Backup path or filename to restore

-h, --help

Show command help

--pwd=Value

Decrypt backup with given password (V15.5 SP2 onwards)

--failover

Failover mode - services are not started after restore on a PBX set up as passive failover node

Notes:

  • Mandatory options are denoted above with *.
  • Specify an existing log file with the
    -l
    or
    --log
    switch to append to.
  • Values, filenames and paths with space(s) are not recommended, otherwise they need to be enclosed in double quotes when used in option arguments.
  • Ensure that specified log file paths are writable on Linux by the
    phonesystem
    user, and on Windows by the executing user.

General

Specifying a filename with the “--file” or “--f” switch as a:

  • filename, retrieves the backup file from the backup location configured in the Management Console, e.g.

RestoreCmd -f=my-pbx_full_bak.zip -l=c:\backup\restore_cmd.log

  • full filename path, overrides the configured location and retrieves the backup file from the specified path, e.g.

RestoreCmd -f=c:\backup\my-pbx_full_bak.zip -l=c:\backup\restore_cmd.log

When the “--log” argument is specified, it has to be followed by either:

  • a filename to store the log in the current working directory, e.g.

BackupCmd -l=bak_cmd.log -f=my-pbx_full_bak

  • a full path to a local filename to override and store in the file specified, e.g.

BackupCmd -l=c:\backup\bak_cmd.log -f=my-pbx_full_bak

Note that the specified path needs to be writable:

  • on Linux for the “phonesystem” user
  • on Windows for the user set to execute the task.

Restore Command on Windows

To use the restore command on Windows, open a command prompt with administrative privileges, change to this directory using

cd C:\Program Files\3CX Phone System\Bin
and run the command to:

  • Display available restore command options:

RestoreCmd.exe --help

  • Restore a backup and start 3CX services immediately after restore:

RestoreCmd.exe --file=pbx_backup.zip --log=restore_cmd.log

  • Restore a backup in failover mode and keep 3CX services stopped on a PBX set up as passive failover node:

RestoreCmd.exe --file=pbx_backup.zip --log=restore_cmd.log --failover

Restore Command on Linux

To use the restore command on Linux, run the command in a terminal as user

phonesystem
using
sudo
to:

  • Display available restore command options:

sudo -u phonesystem 3CXRestoreCmd --help

  • Restore a backup and start 3CX services immediately after restore:

sudo -u phonesystem 3CXRestoreCmd --file=pbx_backup.zip --log=restore_cmd.log

  • Restore a backup in failover mode and keep 3CX services stopped on a PBX set up as passive failover node:

sudo -u phonesystem 3CXRestoreCmd --file=pbx_backup.zip --log=restore_cmd.log --failover

See Also

Last Updated

This document was last updated on 11 June 2023

https://www.3cx.com/docs/backup-restore-command-line/