TryLearn More

Use SIP trunks, WebRTC & Apps

Slash your Phone Bill by 80%

3CX Backup & Restore cmd

On this topic

3CX Backup & Restore cmd

Introduction

Backup cmd

General

Windows

Linux

Restore cmd

General

Windows

Linux

Introduction

Starting from v15.5 SP1 two command line tools have been added to 3CX so that users can now take and restore backups via command line. This can be used to script scheduled backups/restore outside of the management console features which is useful for cloud hosting looking into archiving all their users 3CX configurations in a safe location, in bulk. These are available on Windows and Linux and shipped by default in the 3CX installation.

Backup cmd

BackupCMD is the command line tool that allows backups to be taken via command line. It offers the following options:

  • l, --log=VALUE            Log path or filename
  • f, --file=VALUE            Zip path or filename to backup *
  • o, --options=VALUE    Backup options (what to include in the backup) *

                                                      ALL - include all

                                                 Any combination of following strings (comma-

                                                     separated):

                                                     CH - include CallHistory

                                                     LIC - include license

                                                    FQDN - include FQDN

                                                    PROMPTS - include Prompts

                                                    FW - include Firmware

                                                    REC - include Recordings

                                                    VM - include VoiceMails

  • c, --cfg=VALUE            Configuration file full path
  • h, --help                       Show this help
  • --pwd=Value                 Encrypt Backup with Password (V15.5 Sp2 onwards)

Arguments with * are mandatory.

General

If specifying only a filename in the --file argument, the backup file will be stored in the configured backup location set in the Management Console, which is either a local folder, FTP, or Google Drive folder. If specifying a full path it will override the configured location and Backup file and will be stored as specified.

If not specified the--log argument, Log file will be stored in: C:Program Files3CX Phone SystemInstance1Binbackup.log on Windows and /var/lib/3cxpbx/Instance1/Bin/backup.log on Linux. Otherwise, if the argument is specified, a filename may be used and the log will be stored in the same folder, or a full path may be used to override this default location (only local disks).

Note that it needs to be a writable path for “phonesystem” user on Linux and on Windows based on the user the schedule is being executed with.

The --cfg argument is only necessary if the backup-tool is not running from the directory defined in Step 1 below. In this case it must be set to:


Windows
C:Program Files3CX Phone SystemInstance1BinRestoreCmd.exe.config

Linux

/var/lib/3cxpbx/Instance1/Bin/RestoreCmd.exe.config

Windows

  1. Open Command Prompt as Administrator and go to:
    cd C:Program Files3CX Phone SystemInstance1Bin
  2. Enter BackupCmd.exe --help command to see all available options.
  3. To make a full backup run this command:
    BackupCmd.exe --file=backuptest.zip --options=ALL --log=backuptest.log
  4. To make a backup including Call history, license and FQDN, run this command: BackupCmd.exe --file=backuptest.zip --options=CH,LIC,FQDN --log=backuptest.log

Linux

All following commands must be run as user phonesystem using sudo as below:

  1. Open a Terminal and go to:
    cd /var/lib/3cxpbx/Instance1/Bin/
  2. Run sudo -u phonesystem /usr/sbin/3CXBackupCmd --help” command to see all available options.
  3. To make a full backup run this command:
    sudo -u phonesystem /usr/sbin/3CXBackupCmd --file=backuptest.zip --options=ALL --log=/tmp/backuptest.log
  4. To make a backup including Call history, license and FQDN, run this command:
    sudo -u phonesystem /usr/sbin/3CXBackupCmd --file=backuptest.zip --options=CH,LIC,FQDN --log=/tmp/backuptest.log

Restore cmd

RestoreCMD is the command line tool that allows to restore backups via command line. It offers the following options:

 

  • -l, --log=VALUE           Log path or filename
  • -f, --file=VALUE           Zip path or filename to restore *
  • -c, --cfg=VALUE          Configuration file full path
  • -h, --help                         Show this help
  • --pwd=Value                 decrypt Backup with Password (V15.5 Sp2 onwards)
  • --failover                      Failover mode (services will not be started after restore)

Arguments with * are mandatory.

General

If specifying only a filename in the --file argument, the backup file will be read from the configured backup location, which is either a local folder, FTP, or Google Drive folder.

If specifying a full path it will override the configured location and the backup file will be read as specified.

If not specified the --log argument, Log file will not be stored.

If specifying a filename, log file will be stored in: C:Program Files3CX Phone SystemInstance1Bin on Windows and /var/lib/3cxpbx/Instance1/Bin/ on Linux. A full path can be used to override this default location.

Note that it needs to be a writable path for “phonesystem” user on linux and on windows based on the user the schedule is been executed with..

The --cfg argument is only necessary if the backup-tool is not running  from the directory defined in step 1 below. In this case it must be set to:


Windows
C:Program Files3CX Phone SystemInstance1BinRestoreCmd.exe.config

Linux

/var/lib/3cxpbx/Instance1/Bin/RestoreCmd.exe.config

Windows

  1. Open Command Prompt as Administrator and go to the tools directory using command:
    cd C:Program Files3CX Phone SystemInstance1Bin
  2. Enter RestoreCmd.exe --help command to see all available options.
  3. To restore a backup, you must run this command:
    RestoreCmd.exe --file=restoretest.zip --log=restoretest.log
  4. To restore a backup in failover mode run this command:
    RestoreCmd.exe --file=restoretest.zip --failover --log=restoretest.log

Linux

  1. Open a Terminal and go to the 3CX binary directory using command:
    cd /var/lib/3cxpbx/Instance1/Bin/
  2. Run sudo -u phonesystem /usr/sbin/3CXRestoreCmd command to see all available options.
  3. To restore a backup run this command:
    sudo -u phonesystem /usr/sbin/3CXRestoreCmd --file=restoretest.zip --log=/tmp/restoretest.log
  4. To restore a backup in failover mode run this command:
    sudo -u phonesystem /usr/sbin/3CXRestoreCmd --file=restoretest.zip --failover --log=/tmp/restoretest.log

Free for up to 1 year! Select preferred deployment:

On-Premise

for Linux on a $200 appliance or as a VM

Get the ISO

On-Premise

for Windows as a VM

Download the setup file

On the cloud

In your Google, Amazon, Azure account

Take the PBX Express