---
title: "Manage SiteWorx Backups via CLI"
source: "https://docs.nexcess.com/hosting/control-panel/interworx/siteworx/manage-siteworx-backups-via-cli/"
description: "The command-line interface (CLI) provides greater flexibility and more options compared to using NodeWorx directly. Automate SiteWorx backups with a Cronjob. Cr…"
vertical: "Hosting"
date: "2025-07-01"
last_modified: "2026-06-30"
---

# 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 ~]<em># ~iworx/bin/backup.pex -h</em>
Usage: backup.php [-tofescb --all --<strong>as</strong>-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]

--<strong>as</strong>-master                        Create the domain <strong>as</strong> 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 <strong>not</strong> backup log files,
                                   no-stats = do <strong>not</strong> backup stats files,
                                   no-mail-contents = do <strong>not</strong> 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 <strong>in</strong> the
                                   backup file.  This option <strong>is</strong> deprecated,
                                   <strong>and</strong> --backup-options should be used
                                   instead.  This <strong>is</strong> here <strong>for</strong> backwards
                                   compatibility, <strong>and</strong> will be removed <strong>in</strong> a
                                   future release.
--domains (optional)values         The domain <strong>or</strong> 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 <strong>from</strong>
                                   <strong>the</strong> backup, that may have been included
                                   normally.This path <strong>is</strong> relative to the
                                   webroot.(i.e., --exclude-dirs
                                   html/this/dir/)
--exclude-exts (optional)values    A list of extensions to exclude <strong>from</strong>
                                   <strong>the</strong> 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 <strong>or</strong>
                                   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 <strong>is</strong> deprecated, <strong>and</strong> --xfer-method
                                   should be used instead.  This <strong>is</strong> here <strong>for</strong>
                                   backwards compatibility, <strong>and</strong> will be
                                   removed <strong>in</strong> a future release.
--mail                             (DEPRECATED) include mail data <strong>in</strong> the
                                   backup file.  This option <strong>is</strong> deprecated,
                                   <strong>and</strong> --backup-options should be used
                                   instead.  This <strong>is</strong> here <strong>for</strong> backwards
                                   compatibility, <strong>and</strong> will be removed <strong>in</strong> a
                                   future release.
--no-disabled                      Do <strong>not</strong> 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 <strong>is</strong> deprecated, redirecting
                                   output to /dev/null should be used
                                   instead.  This <strong>is</strong> here <strong>for</strong> backwards
                                   compatibility, <strong>and</strong> will be removed <strong>in</strong> 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 <strong>in</strong> the default location.
                                   This option <strong>is</strong> deprecated, <strong>and</strong> simply
                                   omitting this option should be used
                                   instead.  This <strong>is</strong> here <strong>for</strong> backwards
                                   compatibility, <strong>and</strong> will be removed <strong>in</strong> 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 <strong>is</strong> useful
                                   <strong>for</strong> very large backups where moving the
                                   data manually would be easier.Can NOT be
                                   set along <strong>with</strong> 'backup-options' parameter
-t --tmp-dir (optional)value          The temporary directory where the backup
                                   will be created before the backup <strong>is</strong> moved
                                   into the final location (/tmp)
--to-s3-target=<value>             Backup to the specified s3 target.
--web                              (DEPRECATED) include web data <strong>in</strong> the
                                   backup file.  This option <strong>is</strong> deprecated,
                                   <strong>and</strong> --backup-options should be used
                                   instead.  This <strong>is</strong> here <strong>for</strong> backwards
                                   compatibility, <strong>and</strong> will be removed <strong>in</strong> a
                                   future release.
--xfer-bg                          Tells backup.pex to transfer the backup
                                   file <strong>in</strong> the background.  Default behavior
                                   <strong>is</strong> to transfer <strong>in</strong> 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' <strong>or</strong> 'ftp'.If this option <strong>is</strong> <strong>not</strong>
                                   set, the backups will be saved locally to
                                   the hard drive, <strong>in</strong> the location specified
                                   <strong>with</strong> 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} --<strong>as</strong>-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] <br></br>username="user" <br></br>password="your password" <br></br>hostname="hostname.domaine.tld" <br></br>remotepath="~/yourbackupdir/" <br></br>port="22"`
    - For FTP transfers:  
        `[ftp] <br></br>username="user" <br></br>password="your password" <br></br>hostname="hostname.domaine.tld" <br></br>remotepath="~/yourbackupdir/" <br></br>port="21"`

NoteNote 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](https://appendix.interworx.com/current/nodeworx/account_management/siteworx/imports/import-interworx-hosting-accounts.html) for further details.
