How to: Backup and Restore SiteWorx Accounts from NodeWorx and the CLI

System Administrators and resellers have the ability to create and restore SiteWorx account backups, both from the NodeWorx interface and from the CLI.

For information on how to create SiteWorx account backups from within SiteWorx, see How to Backup and Restore a SiteWorx Account in SiteWorx.

InterWorx also provides a plugin for Acronis and supports S3 backups.

Note

Backup creation within NodeWorx is on-demand. However, it is possible to schedule automated backups of all SiteWorx accounts using the SiteWorx Backup Plugin.

Managing SiteWorx Backups in NodeWorx

To Create a SiteWorx Backup in NodeWorx

  1. Log into NodeWorx from the browser (https://ip.ad.dr.ess:2443/nodeworx)

  2. In NodeWorx, navigate to SiteWorx > Backup / Restore

  3. Select the Reseller that owns the account(s) from the Reseller dropdown

    • If logged in with a NodeWorx Reseller account, only the SiteWorx accounts owned by that reseller will be shown

  4. Select the checkboxe(s) for the SiteWorx account(s)

    • Selecting the checkbox next to the With Selected dropdown will select all accounts

  5. Select the backup type from the With Selected dropdown

    • Full Backup: Create a full SiteWorx backup, which includes all SiteWorx account related data

    • Structure-Only Backup: 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

    ../../../../_images/nw-sw-backup.png
  6. Click Go. This opens the Create Backup form

  7. (Optional) Update the E-mail Status To field with the email that should be notified when the backup process finishes

  8. Click Create

To Restore a SiteWorx Backup in NodeWorx

  1. Log into NodeWorx from the browser (https://ip.ad.dr.ess:2443/nodeworx)

  2. In NodeWorx, navigate to SiteWorx > Backup / Restore

  3. Select the Reseller that owns the account(s)

    • If logged in with a NodeWorx Reseller account, only the SiteWorx accounts owned by that reseller will be shown

  4. Click Manage next to the SiteWorx account. This opens the Backup Management page

    • If there are no backups for a SiteWorx account, instead of Manage, it will say No Backups

    manage backups
  5. Click Restore next to the backup to restore. This opens the Confirmation form

  6. Select the Confirm Action checkbox

    Warning

    Restoring an account backup will overwrite exiting SiteWorx account data.

  7. Click Restore to confirm

To Delete a SiteWorx Account Backup in NodeWorx

  1. Log into NodeWorx from the browser (https://ip.ad.dr.ess:2443/nodeworx)

  2. In NodeWorx, navigate to SiteWorx > Backup / Restore

  3. Select the Reseller that owns the account(s)

    • If logged in with a NodeWorx Reseller account, only the SiteWorx accounts owned by that reseller will be shown

  4. Click Manage next to the SiteWorx account. This opens the Backup Management page

    • If there are no backups for a SiteWorx account, instead of Manage, it will say No Backups

  5. Click the Trashcan next to the backup to be deleted. This opens the Confirmation form

  6. Click Delete to confirm

Managing SiteWorx Backups from the CLI

The CLI method of backing up accounts is less user-friendly than doing so through NodeWorx, however, it offers more options and flexibility. It is most useful when automating the creation of SiteWorx backups via a Cronjob.

To Create a SiteWorx Backup via the 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. It has one required parameter:

    [iworx@test-box ~]$ ~iworx/bin/backup.pex --domain {domain}
    

Parameter

Description

--domains {domain list}

Space-separated list of SiteWorx account domains to backup. simple regular expressions are also allowed.

--domains all

Backup all domains on the server.

There are also several 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 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.()

[root@installtest ~]#

To Create a Backup of Only the Master or Secondary Domain

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

This is useful if splitting up a multi-domain SiteWorx account so all domains have their own accounts, or if importing a SiteWorx account to a server where a domain with the same name already exists, and will need to be overridden upon import (see Import Hosting Accounts to InterWorx).

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. 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
    
  3. 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
    

To 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 at the CLI as root, either via SSH or from the terminal

  2. Using a text editor, create a file named transfer.ini in whatever path is preferred

    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.

To Restore a SiteWorx Backup via the 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.