# Auto-shipment of backups

Many users think about creating regular backups of their data, and this is great! But how do you automate backups?

In this article we will work with the service \* External FTP-repository»

## FTP storage activation

This service is available in the relevant section of [Billing](https://billing.spacecore.pro/). Choose «Dynamic tariff».

<figure><img src="/files/UFscUk4SUgIoofHB38re" alt=""><figcaption></figcaption></figure>

We specify the necessary amount of storage memory (up to **3.5Tb**), for example, **50Gb**, after which we add the tariff to the basket and pay.

<figure><img src="/files/cGCCRy0M5mwIX9EfWWaR" alt=""><figcaption></figcaption></figure>

A few seconds after payment service will be activated and visible in a special section.

<figure><img src="/files/gUXU7D8v6EVQ4gK0U47d" alt=""><figcaption></figcaption></figure>

We can get the data for working with it by selecting the service and clicking on the «Instructions» button.

In a separate window you will see a tab with all the necessary data to work.

<figure><img src="/files/dWEbbHPrVuS8Dve7Glpq" alt=""><figcaption></figcaption></figure>

## Test shipment lftp

Now we go to our main server from which files will be downloaded to **FTP storage**. We will need the article «[Working with FTP-repository](/wiki/administration-and-backups/how-to-use-backup-storage.md)».

We will need **lftp**. Installing the utility on **Debian**/**Ubuntu** is done using the

```
sudo apt-get -y install lftp
```

<figure><img src="/files/hXlgsxW4cG2Lc49WKWjM" alt=""><figcaption></figcaption></figure>

Great! Let’s try to upload the test file, but create it prematurely using the **touch** command.

<figure><img src="/files/BqahLHK3SpTHEOK7wLfS" alt=""><figcaption></figcaption></figure>

Yes. Enter the command to upload the file:

```
lftp ftp://login:pass@backup.s1.fsn.spacecore.pro:21 -e "set ftp:ssl-allow no; put -O / file; quit"
```

{% hint style="info" %}
**login** — storage user name.

**pass** — storage password.

**backup.s1.fsn.spacecore.pro** — shipment server (do not need to change).

**/** — the directory where the file will be uploaded to the repository.

**file** — the file name to be shipped.
{% endhint %}

For our service this command will be relevant, enter.

```
lftp ftp://spacecore35176:KDAcfR4p1tyz@backup.s1.fsn.spacecore.pro:21 -e "set ftp:ssl-allow no; put -O / spacecore; quit"
```

After the input connection to the remote server and the file shipment (the time of shipment varies depending on the size of the transmitted file and the speed of the network). At the end of the process, we can see our file by connecting to the repository via **FTP**.

<figure><img src="/files/njWsLibNIZUh9HntIhvh" alt=""><figcaption></figcaption></figure>

But the question remains: «**How can this process be automated?**».

First, create a script that will perform all the necessary actions for us. Create a file and open the editor using the command

```
nano backup.sh
```

{% hint style="info" %}
Where **backup**.**sh** is the file name
{% endhint %}

```
#!/bin/bash
lftp ftp://spacecore35176:KDAcfR4p1tyz@backup.s1.fsn.spacecore.pro:21 -e "set ftp:ssl-allow no; put -O /backups backup.tar.gz; quit"
```

{% hint style="info" %}
Where **#!/bin/bash** — the necessary string indicating that it is the shell script in front of us.

**/backups** — a new directory for storing the uploaded file in the repository (which must be created on the FTP server itself).

**backup.tar.gz** — the new file name for the shipment is premature.

Optionally, before uploading a file, you can add commands to archive those important data that you need to save on a remote server.
{% endhint %}

We save our script file using a combination **Ctrl + X** **->** **y.** &#x20;

Now we are trying to ship the file using a Shell script (in our case, an archive is specified for shipment backup.tar.gz , so let's create it first). Then we use our script.

```
sh backup.sh
```

Shipment’s started. Waiting for completion of the process.

<figure><img src="/files/esCdp4MhhGCYYBPQQExO" alt=""><figcaption></figcaption></figure>

The script works! Our data archive has been successfully uploaded to a remote FTP server.

<figure><img src="/files/pGnVchKAPu0vexwAMrC5" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/NV0UDUyEfm9WWPmi80I3" alt=""><figcaption></figcaption></figure>

## Automation via CRONTAB

More information about working with **CRON** can be found in the form of public articles on various websites.

Use the command to open the **CRON** configuration.

```
crontab -e
```

Done. Currently it is empty. In the form of comments, information from the developers on setting up automation.

<figure><img src="/files/coCLa00MmNW5BJsGjTqV" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Minute Hour Day Month Money Weeks /Way/To/File**
{% endhint %}

Add this line to set the regular start of our download script every day at 00:00 server time.

```
0 0 * * * /root/backup.sh
```

{% hint style="info" %}
Where **/root/backup.sh** is the path to the executable.
{% endhint %}

Great job! We created our own script for uploading the backup file, and also learned to automate this task via **CRON**.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://spacecore.gitbook.io/wiki/en/administration-and-backups/the-backups-auto-upload.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
