# Clone System

## <span class="mw-headline" id="bkmrk-what-it-does-1">What it does</span>

Clones the entire webapp to another server.

Only works on linux.

## <span class="mw-headline" id="bkmrk-first-setup-1">First setup</span>

1. Generate an SSH key for the tomcat-user on the source server `sudo -u tomcat ssh-keygen`
2. Add the public key to a user on the target server that has sudo-access
3. Connect from the source server, as tomcat, to the target server and accept the certificate
4. Add configurations

## <span class="mw-headline" id="bkmrk-how-to-invoke-1">How to invoke</span>

Invoke the codeunit, as an admin. eg.

`[SERVER]/main?command=common.CloneSystem`

### <span class="mw-headline" id="bkmrk-options-1">Options</span>

Control the behavior with the following url-parameters.

<table class="wikitable" id="bkmrk-parameter-desctiptio"><tbody><tr><th>Parameter</th><th>Desctiption</th></tr><tr><td>with-users</td><td>Also clones the users and their groups</td></tr><tr><td>with-files</td><td>Also clones the files uploaded</td></tr><tr><td>dont-backup-target</td><td>Does not create a copy of the database on the target server with the name `_backupyyyyMMddHHmm`</td></tr><tr><td>dont-clean</td><td>Does not remove the sql files on both systems</td></tr></tbody></table>

## <span class="mw-headline" id="bkmrk-configuration-1">Configuration</span>

<table class="wikitable" id="bkmrk-config-default-descr"><tbody><tr><th>Config</th><th>Default</th><th>Description</th></tr><tr><td>CloneSystem.targetServer</td><td> </td><td>IP or domain of target server</td></tr><tr><td>CloneSystem.targetUser</td><td>ec2-user</td><td>Name of the user that is being used on the target server</td></tr><tr><td>CloneSystem.targetBasePath</td><td>Policy:applicationBasePath</td><td>Webapps, folder on target server</td></tr><tr><td>CloneSystem.targetApp</td><td>Policy:applicationName</td><td>Application name on target server</td></tr><tr><td>CloneSystem.targetDb</td><td>DbLive-name</td><td>Name of live server on target server</td></tr></tbody></table>

## <span class="mw-headline" id="bkmrk-developer-info-1">Developer info</span>

- Type: [CodeunitPagecontent](https://docs.tsnocode.com/books/codeunit-reference/chapter/pagecontent)
- Security: Requires session
- Classpath: com.tsnocode.codeunit.common.CloneSystem