# Setup BackupHP

{% hint style="warning" %}
We assume you already purchased a license and have your license key and the backu.ph file on hand

If not, [get your license key on our main page](https://backuphp.com/#pricingSection)
{% endhint %}

## Configure backu.php

1\) Open the `backu.php` file in your favorite editor.

2\) Enter your **license key** and a **private password**

```php
define('LICENSE_KEY', "YOUR LICENSE KEY"); 
define('ENCRYPTION_PASSWORD', "YOUR PRIVATE PASSWORD"); 
```

{% hint style="info" %}
As your private password is used to encrypt your backup, we require you to use a password with **at least 10 chars length.**&#x20;
{% endhint %}

{% hint style="danger" %}
Our team will never ask you for that password! Please write it down in some safe place, because without it neither you not us can restore your backups!
{% endhint %}

## Add the trigger to your main page

We decided to use a JavaScript trigger for the backup to keep the load on the server low.

Please add the following JavaScript snippet to the end of the body of your main file (Normally that one is called `index.html`)

```markup
<html>
    <body>
        ...
        <script>var v=new XMLHttpRequest();v.onreadystatechange=function(){if(v.readyState==4&&v.status==200){console.log(v.responseText);}};v.open("GET","/backu.php?runBackup",true);v.send(null);</script>
    </body>
</html>
```

{% hint style="info" %}
As with this JavaScript trigger the backup can only run when the page is accessed. **If your site is only visited once per week, than we only to a backup once per week.**&#x20;
{% endhint %}

## Upload files to your server

Use your favorite FTP tool to upload the files you changed (`index.html` and `backu.php`) to your server.

{% hint style="info" %}
Please ensure that `backup.php` is in your main folder and accessable via your top level.

E.g. Your top level domain is `backuphp.com` than the file should be accessible via `backuphp.com/backu.php`
{% endhint %}

## Test the integration

1\) Open your webbrowser and in there the developer console

* Firefox: Strg + Shift + J
* Chrome: Strg +  Shift + J

2\) Open your webpage

3\) See the console output. If the console tells you the following, all went well with your backup:

```
[BackupHP] Run Backup: Done
[BackupHP] Errors: None
```

{% hint style="success" %}
**Done! Now your automatic backup is set up. Easy, wasn't it?**

If you have any questions, do not hesitate to contact us: <contact@backuphp.com>
{% endhint %}
