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
- Log in to the server at the CLI as root, either via SSH or from the terminal
- Run the InterWorx backup script, replacing the {domain} with domain you want to backup.
[iworx@test-box ~]$ ~iworx/bin/backup.pex --domain {domain}
Parameter 384196_934350-fb> | Description 384196_d16986-31> |
|---|---|
| Specify the SiteWorx account domains to back up as a space-separated list. Simple regular expressions are supported. 384196_f7342c-66> |
| Backs up all of the domains on the server. 384196_49c6a8-d4> |
Optional flags that may be used when backing up SiteWorx accounts. Some common examples:
Parameter 384196_8141d1-10> | Description 384196_b80bbd-8b> |
|---|---|
| A space separated list of what should be included in this backup. Valid options are:
|
| 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. 384196_518a3c-0e> |
| The email address backup results are sent to. 384196_eb5a1b-0e> |
Parameter 384196_a5a52e-ba> | Description 384196_fb27fa-ce> |
|---|---|
| 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). 384196_47fef9-66> |
| 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. 384196_6a3b0b-21> |
Parameter 384196_d212ef-9a> | Description 384196_83c325-0d> |
|---|---|
–xfer-method {method} 384196_059c74-19> | Sets the transfer method type. Valid options are:
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). 384196_1847cf-90> |
–xfer-ini {/path/to/xfer.ini} 384196_39e382-95> | 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. 384196_16c205-c5> |
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.
- Log in to the server via CLI as root.
- 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-onlyflag~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-masterflag~iworx/bin/backup.pex --domain {secondary domain} --as-master
- To create a backup of just the master domain, with no secondary domains, run the InterWorx backup script with the
Create a .ini File for Remote Transfers
The following is the proper format for the transfer.ini files used by the InterWorx backup system.
- Log in to the server via CLI as root.
- 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 - 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"
- For SCP transfers:
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.