Maintaining a local mirror of Plesk Autoinstall Servers helps you to avoid wasting a lot of time and traffic on downloading the same files again and again when installing or updating multiple Plesk servers. Local mirrors are available via HTTP, and can be specified as sources for downloading Plesk packages in the course of installation or upgrade.
## Prerequisites for a Local Mirror Repository
1. Virtual host used for mirroring should have all script handlers (php, pl, cgi, py, fcgi etc) disabled.
2. Virtual host or directory used for mirroring should have option `+FollowSymLinks` set.
3. Unless the other sources are specified, the following must be accessible from the machine, where the script is being run, and from the destination machine:
- `rsync://rsync.autoinstall.plesk.com/autoinstall` for Plesk for Linux,
- `rsync://autoinstall-win.plesk.com/autoinstall` for Plesk for Windows.
4. PHP must be compiled with support of the below extensions on the machine, where the script is being run (see http://www.php.net/manual/en/ssh2.installation.php):
- ssh2_connect,
- simplexml,
- XML DOM.
5. Plesk for Windows and Plesk for Linux mirrors can not be located in the same folders. Mirrors must be created in separate paths.
## Configuring a Local Mirror Repository
1. Download and unzip the Plesk Mirror Setup tool
2. Check for available product versions
Use the `show-all-releases` command to view available products and `os-list` command to view OSes supported by particular product:
3. Select product versions you want mirrored
Use `cfg`` ``--add` and `cfg`` ``--remove` to edit the list of product versions that are to be mirrored:
4. Save the configuration of the local mirror repository to a file
Use `cfg`` ``--export` to save the created configuration to a file:
The configuration will be saved to a file `mirror.xml` at the specified location.
To load a saved configuration from a file, use `cfg`` ``--import`:
5. Create the mirror repository
First, create a directory for the mirror:
>
The local mirror repository can now be used in the process of installing and upgrading Plesk.
# wget https://support.plesk.com/hc/en-us/article_attachments/12388062580887/mirrorctl-3.1.4.zip
# unzip mirrorctlv2.0.1.zip
# cd mirrorctl
# ./mirrorctl show-all-releases
# ./mirrorctl os-list --release=PLESK_12_0_18
# ./mirrorctl cfg --add --release=PLESK_12_0_18 --os=cos5_i386
# ./mirrorctl cfg --add --win --release=PANEL_12_0_18_WIN --cfg-file=./plesk_win_mirror
# ./mirrorctl cfg --export --path=./
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<release name="PLESK_12_0_18" version="12.0.18">
<os name="cos5_i386"/>
</release>
</xml>
# ./mirrorctl cfg --import --cfg-file=./mirror.xml
# mkdir /var/www/html/mirror/
# mkdir /var/www/html/mirror_windows/
>
> Then, use the `update` command to synchronize the mirror with the official repository:
>
> >
> >
> >
>
>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > # ./mirrorctl update --path=/var/www/html/mirror/
# ./mirrorctl update --win --path=/var/www/html/mirror_windows/ --cfg-file=./plesk_win_mirror
Note
This repository can be used to install only the product versions and OSes, which were specified in the mirror configuration. All other versions will not be available in this repository for `autoinstaller` utility.
Check the list of product versions available in the created repository:
# ./mirrorctl show-all-releases --src-host=/var/www/html/mirror/
# ./mirrorctl show-all-releases --win --src-host=/var/www/html/mirror_windows/
## Using a Local Mirror Repository
A mirror can be used in either of the following ways:
- by changing DNS resolving and setting up the mirror web host so that `https://autoinstall.plesk.com` (for Plesk Linux) or `http://autoinstall-win.plesk.com/` (for Windows) would point to the mirror;
- by specifying the URL to the mirror in the `SOURCE` variable of the `/root/.autoinstallerrc` file on the machine where autoinstaller is launched;
- by specifying the mirror URL in the `--source` option when launching autoinstaller in interactive mode.
[root@container ~]# cat /root/.autoinstallerrc
SOURCE=http://uri.of.local.mirror/here/
## Maintaining Remote Mirror Repositories
Plesk Mirror Setup tool can manage repositories that are located on the same file system as well as on remote servers. To specify remote source and remote destination mirrors, the `--path` and `--src-host` options are used.
Use `--path` to specify the remote destination mirror:
1. Using a particular user, password and host:
2. Using SSH keys authorization (both private and public keys are required):
If default RSA pair (id_rsa & id_rsa_pub) for current user does not exist, then default DSA pair (id_dsa & id_dsa.pub) from `$HOME/.ssh/` folder will be used.
3. Using particular SSH keys as additional options for mirrorctl utility:
Use `--src-host` to specify the remote source mirror:
1. Using rsync via SSH protocol:
- In the above case it is forbidden to specify user password or SSH port (22).
- In case `--src-host` option is used, the user who launches the tool must have SSH keys authorization set up for him to be able to connect to the host specified under `--src-host` option and under the user specified via that option.
- If the `--src-host` option is used along with the `--path` option, then, again, the user specified in the `--path` option must have SSH keys authorization set up for him to be able to connect from the host specified in the `--path` option to the host specified under `--src-host` option and under the user specified via `--src-host` option.
2. Using rsync daemon on the source host:
Example of rsync configuration:
--path=user:UserSecurePassword@mymirror.tld:344/var/www/html/
--path=user:UserSecurePassword@192.168.100.100:22/var/www/html/
--path=root:RootSecurePassword@localhost:/var/www/html/
--path=192.168.100.100:/var/www/html/
--path=user@mymirror.tld:344/var/www/html/
--path=root@mymirror.tld:344/var/www/html/ --private-key=~/.ssh/id_mirror --public-key=~/.ssh/id_mirror.pub
--src-host=test@192.168.100.100:/var/www/html/test-mirror/
--src-host=mytestmirror.tld:/var/www/html/test-mirror/
--src-host=rsync://mytestmirror.tld:873/testmirror
# head /etc/rsyncd.conf
[testmirror]
path = /var/www/html/test-mirror/
comment = Test repository
# cat /etc/xinetd.d/rsync
service rsync
{
# disable = yes
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
## Example 1: Setting up periodic updates for the local mirror repository
Goal: make sure my mirror with selected product versions is up to date.
1. Create the mirror configuration by adding the needed product versions and operating systems:
2. Configure crontab to automatically update the mirror:
# /home/user/mirrorctl/mirrorctl cfg --add --release=PLESK_12_0_18 --os=cos5_i386 --cfg-file=/var/www/html/mirror/myconfig.xml
# /home/user/mirrorctl/mirrorctl cfg --add --release=PLESK_12_0_18 --os=rhel5_i386 --cfg-file=/var/www/html/mirror/myconfig.xml
# /home/user/mirrorctl/mirrorctl cfg --add --release=PLESK_11_5_30 --os=cos5_i386 --cfg-file=/var/www/html/mirror/myconfig.xml
# /home/user/mirrorctl/mirrorctl cfg --add --win --release=PANEL_12_0_18_WIN --cfg-file=/var/www/html/mirror/windows_myconfig.xml
$ crontab -l
# m h dom mon dow command
59 23 * * * cd /home/user/mirrorctl/ && ./mirrorctl update --path=/var/www/html/mirror/ --cfg-file=/var/www/html/mirror/myconfig.xml > ./mirror-cron.log 2>&1
59 22 * * * cd /home/user/mirrorctl/ && ./mirrorctl update --win --path=/var/www/html/mirror_windows/ --cfg-file=/var/www/html/mirror/windows_myconfig.xml > ./mirror-cron-win.log 2>&1
## Example 2: Adding new operating systems
Goal: add another operating system for a particular product version to my mirror.
1. Import the current configuration of the repository that you created earlier using mirrorctl utility:
2. Add the new OS for a product version:
3. Synchronize the mirror:
# ./mirrorctl cfg --import --path=/var/www/html/mirror/ --cfg-file=myconfig
# ./mirrorctl cfg --add --release=PLESK_12_0_18 --os=deb6.0_i386 --cfg-file=myconfig
# ./mirrorctl update --path=/var/www/html/mirror/ --cfg-file=myconfig
## Example 3: Downloading a particular OS/version
Goal: download a particular OS for a particular product version to my mirror from the official repository without downloading other mirrored versions/OSes.
1. Generate a configuration file containing only the OSes/product versions that you wish to download:
2. Download the specified OSes to an existing repository using push command:
# ./mirrorctl cfg --add --release=PLESK_12_0_18 --os=cos5_i386 --cfg-file=./temp-config
# ./mirrorctl cfg --add --release=PLESK_12_0_18 --os=cos5_x86_64 --cfg-file=./temp-config
# ./mirrorctl push --path=/var/www/html/mirror/ --cfg-file==./temp-config
## Example 4: Creating a mirror for testing new product versions
Goal: create a test mirror for a new product version, test that version and upload only that tested version (without the latest official updates, which I have not yet tested) to the main repository.
1. Create a test mirror for all OSes of the new product version:
2. Test the new version;
3. Upload the whole product version to the main repository:
# ./mirrorctl cfg --add --release=PLESK_12_0_18 --os=all --cfg-file=./test-config
# ./mirrorctl update --path=/var/www/html/test-mirror/ --cfg-file=./test-config
# ./mirrorctl push --src-host=/var/www/html/test-mirror/ --path=/var/www/html/mirror/ --cfg-file=./test-config
Warning
If `--src-host` option is not used, then the new product version will be uploaded from the official repository and may be different from the one you have tested.
## Example 5: Creating a mirror for testing product releases for new OSes
Goal: create a test mirror with a list of particular OSes for already mirrored product versions with the latest updates, test those OSes and then upload some of the tested OSes to the main repository.
1. Create a test mirror where several OSes will be available for selected product version:
2. Get the list of available product releases and OSes from the test mirror created above:
3. Generate a new configuration file containing only those releases and OSes from the test mirror, which you would like to add to the main mirror:
4. Check the created configuration file for the availability of the releases/OSes in the test repository:
5. Upload the selected releases and OSes from the test mirror to the main repository:
# ./mirrorctl cfg --add --release=PLESK_12_0_18 --os=cos5_i386 --cfg-file=./test-config
# ./mirrorctl cfg --add --release=PLESK_12_0_18 --os=cos5_x86_64--cfg-file=./test-config
# ./mirrorctl update --path=/var/www/html/test-mirror/ --cfg-file=./test-config
# ./mirrorctl show-all-releases --src-host=/var/www/html/test-mirror/
# ./mirrorctl os-list --release=PLESK_12_0_18 --src-host=/var/www/html/test-mirror/
# ./mirrorctl cfg --add --release=PLESK_12_0_18 --os=cos5_i386 --src-host=/var/www/html/test-mirror/ --cfg-file=push.xml
# ./mirrorctl cfg --check --src-host=/var/www/html/test-mirror/ --cfg-file=push.xml
# ./mirrorctl push --src-host=/var/www/html/test-mirror/ --path=/var/www/html/mirror/ --cfg-file=push.xml
Warning
If `--src-host` option is not used, then the new product version will be uploaded from the official repository and may be different from the one you have tested.
Warning
If the `--cfg-file` option is not specified, the default configuration file `BUILD/config.xml` (relative to the directory the tool is located in) will be used. I.e. only the versions/OSes from that configuration file will be uploaded to the main repository.
Warning
If the `--cfg-file` option is specified incorrectly, the configuration file specified for the push command will be used.