Help Docs Control Panel Guides The Ultimate Guide to the InterWorx Control Panel (2025) SiteWorx Manage SiteWorx Backups via CLI

Manage SiteWorx Backups via CLI

The command-line interface (CLI) provides greater flexibility and more options compared to using NodeWorx directly. Automate SiteWorx backups with a Cronjob.

Create a SiteWorx Backup via CLI

  1. Log in to the server at the CLI as root, either via SSH or from the terminal
  2. Run the InterWorx backup script, replacing the {domain} with domain you want to backup.
    [iworx@test-box ~]$ ~iworx/bin/backup.pex --domain {domain}

Parameter

Description

--domains {domain list}

Specify the SiteWorx account domains to back up as a space-separated list. Simple regular expressions are supported.

--domains all

Backs up all of the domains on the server.

Optional flags that may be used when backing up SiteWorx accounts. Some common examples:

Parameter

Description

--backup-options {backup options}

A space separated list of what should be included in this backup. Valid options are:

  • all: Create a full SiteWorx backup, which includes all SiteWorx account related data. If –backup-options is not set, this is the default
  • web: Backup website data
  • mail: Backup email mailboxes
  • db: Backup database data
  • no-logs: By default, site log files are included in a full SiteWorx backup. This option, used along with the “all” option above, indicates the backup should not include site log files
  • no-stats: By default, site stats files are included in a full SiteWorx backup. This option, used along with the “all” option above, indicates the backup should not include stats log files

--structure-only

Creates a backup that only contains SiteWorx related data that is stored in the internal InterWorx database, such as email users and passwords. Actual files, such as website files, actual emails, and database tables, are not included in structure-only backups. Structure-only backups are useful for SiteWorx accounts that have large amounts of data files, where a regular full backup could take a considerable amount of time and resources.

--email {email}

The email address backup results are sent to.

Parameter

Description

--output-dir {path}

Alternate path for saved backups. If this option is omitted, backups will be saved in the SiteWorx account’s backups directory (/home/unixuser/domain.com/iworx-backup).

--tmp-dir {path}

The temporary directory where the backup will be created before it is moved to the final location. If this option is omitted, the default path is set in the iworx.ini, under the [iworx.dir][tmp] setting.

Parameter

Description

–xfer-method {method}

Sets the transfer method type. Valid options are:

  • ftp: Indicates the backup file should be transferred to a remote server via FTP, based on settings in the specified transfer.ini file
  • scp: Indicates the backup should be transferred to a remote server via SCP/SSH, based on settings in the specified transfer.ini file.

If a transfer.ini file is not specified with the –xfer-ini option, the script will look in the default location for the transfer.ini file (/home/unixuser/var/domain.com/.backup.transfer.ini). If the default transfer.ini file is missing, the backup file will be stored in the default local location (/home/unixuser/domain.com/iworx-backup).

–xfer-ini {/path/to/xfer.ini}

Full path of the transfer.ini file that will be used during the backup transfer process. Note: If this option is used with multiple SiteWorx accounts, all the backups will be transferred using this single transfer.ini file.

A full list of options and flags can be seen by adding the -h or --help flag to the command:

[root@installtest ~]# ~iworx/bin/backup.pex -h
Usage: backup.php [-tofescb --all --as-master --compression --databases --domains --email --exclude-exts --ftp --mail --no-disabled --quiet --reseller-id --single-domain --siteworx --structure-only --to-s3-target --web --xfer-bg --xfer-ini --xfer-method]

--as-master                        Create the domain as a master domain
-b --backup-options (optional)values  Set what we should be backing up: (web =
                                   website files, mail = e-mail messages, db
                                   = database data, all = all of the above,
                                   no-logs = do not backup log files,
                                   no-stats = do not backup stats files,
                                   no-mail-contents = do not backup mail
                                   messages, DEFAULT: all
-c --chunk (optional)value         The chunk number to process during the
                                   current run of the backup script(1)
-s --chunksize (optional)value        The number of backups to do during this
                                   run of the backup script.(200)
--compression=<value>              Compression level used when compressing
                                   final archive (6)
--databases                        (DEPRECATED) include database data in the
                                   backup file.  This option is deprecated,
                                   and --backup-options should be used
                                   instead.  This is here for backwards
                                   compatibility, and will be removed in a
                                   future release.
--domains (optional)values         The domain or list of domains to backup.
                                   You may enter multiple domain names
                                   separating them by spaces.You can also use
                                   a regular expression string to match
                                   multiple domain names (i.e. --domain
                                   "^iworx.(.*)$")
--email=<value>                    Backup status will be emailed to this
                                   address ()
-e --exclude-dirs (optional)values    A list of directories to exclude from
                                   the backup, that may have been included
                                   normally.This path is relative to the
                                   webroot.(i.e., --exclude-dirs
                                   html/this/dir/)
--exclude-exts (optional)values    A list of extensions to exclude from
                                   the backup, that may have been included
                                   normally.(i.e., --exclude-exts jpg gif)
-f --filename-format=<value>       Format of filename output: %D=domain name,
                                   %T=unix timestamp, %U = unix username, %R
                                   = reseller id, %t = backup type (full or
                                   partial), %H = hour, %M = minute, %S =
                                   second, %m = month (1..12), %d = day of
                                   month (1..31), %a = 3-letter day of week
                                   (Sun..Sat), %Y = 4-digit year
--ftp                              (DEPRECATED) Indicates the backup file
                                   should be transferred via FTP.  This
                                   option is deprecated, and --xfer-method
                                   should be used instead.  This is here for
                                   backwards compatibility, and will be
                                   removed in a future release.
--mail                             (DEPRECATED) include mail data in the
                                   backup file.  This option is deprecated,
                                   and --backup-options should be used
                                   instead.  This is here for backwards
                                   compatibility, and will be removed in a
                                   future release.
--no-disabled                      Do not backup any domains that are
                                   disabled/inactive.
-o --output-dir (optional)value    The directory where the completed backup
                                   will be saved.()
--quiet                            (DEPRECATED) Specifies that a backup
                                   process should run quietly (no output).
                                   This option is deprecated, redirecting
                                   output to /dev/null should be used
                                   instead.  This is here for backwards
                                   compatibility, and will be removed in the
                                   future
--reseller-id (optional)value      The id of the reseller (1)
--single-domain                    Create a single domain backup.  No
                                   secondary domains will be backed up
--siteworx                         (DEPRECATED) Specifies that a full backup
                                   should be stored in the default location.
                                   This option is deprecated, and simply
                                   omitting this option should be used
                                   instead.  This is here for backwards
                                   compatibility, and will be removed in a
                                   future release.
--structure-only                   Create a structure only backup.  No data
                                   files will be backed up, only the manifest
                                   XML file will be created.  This is useful
                                   for very large backups where moving the
                                   data manually would be easier.Can NOT be
                                   set along with 'backup-options' parameter
-t --tmp-dir (optional)value          The temporary directory where the backup
                                   will be created before the backup is moved
                                   into the final location (/tmp)
--to-s3-target=<value>             Backup to the specified s3 target.
--web                              (DEPRECATED) include web data in the
                                   backup file.  This option is deprecated,
                                   and --backup-options should be used
                                   instead.  This is here for backwards
                                   compatibility, and will be removed in a
                                   future release.
--xfer-bg                          Tells backup.pex to transfer the backup
                                   file in the background.  Default behavior
                                   is to transfer in the foreground.

--xfer-ini (optional)value         Sets the transfer ini file to be used by
                                   the backup process.()
--xfer-method (optional)value      Sets how the backups should be transferred
                                   to their final locations.  Valid values
                                   are 'scp' or 'ftp'.If this option is not
                                   set, the backups will be saved locally to
                                   the hard drive, in the location specified
                                   with the the --output-dir parameter.()

Examples

Create a Backup a Master or Secondary Domain

From the CLI, it is possible to create a backup of a master domain, or a secondary domain.

This is useful when splitting up a multi-domain SiteWorx account to give every domains its own account, or when importing a SiteWorx account to a server with a name conflict.

  1. Log in to the server via CLI as root.
  2. Run one of the following commands:
    • To create a backup of just the master domain, with no secondary domains, run the InterWorx backup script with the --master-only flag
      ~iworx/bin/backup.pex --domain {domain} --master-only
    • To create a backup of a secondary domain as if it were a master domain, run the InterWorx backup script with the --as-master flag
      ~iworx/bin/backup.pex --domain {secondary domain} --as-master

Create a .ini File for Remote Transfers

The following is the proper format for the transfer.ini files used by the InterWorx backup system.

  1. Log in to the server via CLI as root.
  2. Using a text editor, create a file named transfer.ini in whatever path is preferred. The following example uses the Vim text editor:
    vim /root/transfer.ini
  3. Using the following format, provide the required details for the transfer:
    • For SCP transfers:
      [scp]
      username="user"
      password="your password"
      hostname="hostname.domaine.tld"
      remotepath="~/yourbackupdir/"
      port="22"
    • For FTP transfers:
      [ftp]
      username="user"
      password="your password"
      hostname="hostname.domaine.tld"
      remotepath="~/yourbackupdir/"
      port="21"
Note

Note that the text [scp] or [ftp] must be the first line in the file. The [scp] section is used for SCP/SSH remote transfers, and the [ftp] section is used for FTP remote transfers.

Restore a SiteWorx Backup via CLI

Restoring a SiteWorx backup via the CLI is the same process as importing a single SiteWorx account backup, using the --force flag to overwrite the existing SiteWorx account. Please refer to the import documentation for further details.

Was this article helpful?