> Source: https://docs.cyberelements.io/bastion/4.6/Usage/Configuration/EdgeGatewayWindows/GWWindowsInstanceDupplication/

# Instance duplication

> **Information**
>
> This documentation describes how to duplicate a first instance of Edge Gateway Windows.
> It can be followed for new instances by replacing the suffix `-2` with `-3` or any other unused values.

> **Prerequisites**
>
> To perform the following operations, administrator rights for the machine are required.

Duplicating instances allows each instance to connect to a different CyberElements platform.
On the same Windows server, it is therefore possible to connect to several CyberElements Bastion platforms.

The first step is to duplicate the `<INSTALLDIR>\IPdiva\IPdivaGateway\` directory.

> **Example**
>
> With an installation in the default directory, you will need to copy the directory `IPdivaGateway` for `IPdivaGateway-2`:
>
> `C:\Program Files (x86)\Systancia\IPdiva\IPdivaGateway\`
> `C:\Program Files (x86)\Systancia\IPdiva\IPdivaGateway-2\`

Then you need to rename the `IPdivaGateway.exe` executable with the same suffix as the one used for the directory copy above.

> **Example**
>
> The executable `IPdivaGateway.exe` becomes `IPdivaGateway-2.exe`:
>
> `C:\Program Files (x86)\Systancia\IPdiva\IPdivaGateway-2\bin\IPdivaGateway.exe`
> `C:\Program Files (x86)\Systancia\IPdiva\IPdivaGateway-2\bin\IPdivaGateway-2.exe`

Modify the file `<INSTALLDIR>\IPdiva\IPdivaGateway<SUFFIX>\conf\gateway.xml` (changes to lines 17 and 19 and addition to line 22):

```
16
17
18
19
20
21
22
23
```

Replace:

- `<SUFFIX>` by the suffix used when copying the `IPdivaGateway` directory
- `<RPC_PORT>` by a TCP port number available on the machine, it is common for the first instance of Edge Gateway to use port 9080 and to increment it for subsequent instances

> **Example**
>
> Continuing with the example where the chosen suffix is `-2` and this is the second instance of Edge Gateway, the TCP port selected is `9081`, the `C:\Program Files (x86)\Systancia\IPdiva\IPdivaGateway-2\conf\gateway.xml` file would be modified as follows:
>
> ```
> 16
> 17
> 18
> 19
> 20
> 21
> 22
> 23
> ```
>
> > **Complete file**
> >
> > ```
> >  1
> >  2
> >  3
> >  4
> >  5
> >  6
> >  7
> >  8
> >  9
> > 10
> > 11
> > 12
> > 13
> > 14
> > 15
> > 16
> > 17
> > 18
> > 19
> > 20
> > 21
> > 22
> > 23
> > 24
> > 25
> > 26
> > 27
> > 28
> > 29
> > 30
> > 31
> > 32
> > 33
> > 34
> > 35
> > ```

Then modify the `<INSTALLDIR>\IPdiva\IPdivaGateway-2\conf\gwmonitor.xml` file (modify line 3 and add line 9):

```
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
```

Replace:

- `<RPC_PORT>` by the previously selected TCP port
- `<SUFFIX>` by the suffix used when copying the `IPdivaGateway` directory

> **Example**
>
> With the RPC port `9081` and suffix `-2`, the `C:\Program Files (x86)\Systancia\IPdiva\IPdivaGateway-2\conf\gwmonitor.xml` file would be modified as follows:
>
> ```
>  1
>  2
>  3
>  4
>  5
>  6
>  7
>  8
>  9
> 10
> ```

Using a `cmd` command prompt as an administrator, we will create a Windows service to automatically start the new instance of Edge Gateway Windows:

```
1
```

Replace:

- `<INSTALLDIR>` by the directory in which the Windows Edge Gateway was installed
- `<SUFFIX>` by the suffix used when copying the `IPdivaGateway` directory

> **Example**
>
> With installation in the default directory and suffix `-2`, the command to create the service is as follows:
>
> ```
> 1
> ```

Finally, all that remains is to manually configure the new instance so that it can connect: [Manually configure the Edge Gateway instance](https://docs.cyberelements.io/bastion/4.6/Usage/Configuration/EdgeGatewayWindows/GWWindowsManualConfiguration/)
