Technical support 3CX responds: backup and restore 3CX from the command line

Starting from 3CX v15.5 SP1, we added two console utilities to backup and restore PBX configurations. They are used primarily in automation scripts, or if there is no access to the server interface.

If you are servicing a large number of cloud instances of 3CX, the automatic backup script is very convenient, because works from a single console, without requiring login to the management interface of each server. Console utilities are available in both the 3CX version for Linux and for Windows.

BackupCMD command


BackupCMD - console backup command. It has the following parameters:

  • l, --log = VALUE, the name or path of the log file
  • f, --file = VALUE, the name or path of the zip file of the archive is a required parameter
  • o, --options = VALUE, Backup options (what is backed up) is a required parameter

  • c, --cfg = VALUE, full path to the configuration file
  • h, --help, show help (list of these parameters)
  • --pwd = Value, archive encryption password (v15.5 SP2 and higher)

Use of parameters


If you specify only the file name (the --file parameter), the backup will be created in the location specified in the 3CX management interface. The storage location can be a local folder, an FTP server or Google Drive. But if the parameter specifies the full path to the file, it is used, and the settings in the interface are ignored.

If the log file parameter is not specified, the file is created in the default location C: \ Program Files \ 3CX Phone System \ Instance1 \ Binbackup.log (Windows) or /var/lib/3cxpbx/Instance1/Bin/backup.log (Linux) . If only the file name is specified in the parameter, it will be used in the default location. And if the full path is specified, it overrides the default location of the log file (you can only specify a local path).

Please note that when launching the system backup script, the “phonesystem” user should have the right to write to the backup folder.

The option --cfg is used only if the BackupCMD utility is launched from a folder other than the default folder (for example, from your utility folder). In this case, the parameter value is set as follows:

  • C: \ Program Files \ 3CX Phone System \ Instance1 \ Bin \ BackupCmd.exe.config (Windows)
  • /var/lib/3cxpbx/Instance1/Bin/BackupCmd.exe.config (Linux)

Windows Backup


  1. Run the command prompt as administrator and type: cd C: \ Program Files \ 3CX Phone System \ Instance1 \ Bin
  2. To display help, type: BackupCmd.exe --help
  3. An example of a full backup command: BackupCmd.exe --file = backuptest.zip --options = ALL --log = backuptest.log
  4. An example of the call history, license and FQDN backup command: BackupCmd.exe --file = backuptest.zip --options = CH, LIC, FQDN --log = backuptest.log

Linux Backup


Commands are executed by the user “phones system” with sudo privileges:

  1. Run Terminal and type: cd / var / lib / 3cxpbx / Instance1 / Bin /
  2. To display help, type: sudo -u phonesystem / usr / sbin / 3CXBackupCmd --help
  3. An example of a full backup command: sudo -u phonesystem / usr / sbin / 3CXBackupCmd --file = backuptest.zip --options = ALL --log = / tmp / backuptest.log
  4. Example of the call history, license and FQDN backup command: sudo -u phonesystem / usr / sbin / 3CXBackupCmd --file = backuptest.zip --options = CH, LIC, FQDN --log = / tmp / backuptest.log



RestoreCMD command


RestoreCMD is a console command for restoring a 3CX server backup. It has the following parameters:

  • -l, --log = VALUE, name or path of the log file
  • -f, --file = VALUE, the name or path of the zip file of the archive is a required parameter
  • -c, --cfg = VALUE, full path to the configuration file
  • -h, --help, show help (list of these parameters)
  • --pwd = Value, archive decryption password (v15.5 SP2 and higher)
  • --failover, failsafe mode (3CX services do not start after recovery)

Use of parameters


When specifying only the file name (the --file argument), the backup is searched in the location specified in the 3CX control interface. But if the parameter specifies the full path to the file, it is used, and the settings in the interface are ignored.

If no log file option is specified, the file is not created. If only the file name is specified in the parameter, the file will be created in the default location C: \ Program Files \ 3CX Phone System \ Instance1 \ Binbackup.log (Windows) or /var/lib/3cxpbx/Instance1/Bin/backup.log (Linux ). And if you specify the full path, a log file is created along this path.

The --cfg option is used only if the RestoreCMD utility is not running from the default folder. In this case, the parameter is set as follows:

  • C: \ Program Files \ 3CX Phone System \ Instance1 \ Bin \ RestoreCmd.exe.config (Windows)
  • /var/lib/3cxpbx/Instance1/Bin/RestoreCmd.exe.config (Linux)

Windows Recovery


  1. Run the command prompt as administrator and type: cd C: \ Program Files \ 3CX Phone System \ Instance1 \ Bin
  2. To display help, type: RestoreCmd.exe --help
  3. Sample 3CX server recovery command: RestoreCmd.exe --file = restoretest.zip --log = restoretest.log
  4. Example of a failover node restore command: RestoreCmd.exe --file = restoretest.zip --failover --log = restoretest.log

Linux Recovery


Commands are executed by the user “phones system” with sudo privileges:

  1. Run Terminal and type: cd / var / lib / 3cxpbx / Instance1 / Bin /
  2. To display help, type: sudo -u phonesystem / usr / sbin / 3CXRestoreCmd --help
  3. Example restore command: sudo -u phonesystem / usr / sbin / 3CXRestoreCmd - file = restoretest.zip - log = / tmp / restoretest.log
  4. Sample failover node restore command: sudo -u phonesystem / usr / sbin / 3CXRestoreCmd --file = restoretest.zip --failover --log = / tmp / restoretest.log

Also popular now: