> For the complete documentation index, see [llms.txt](https://docs.glesys.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.glesys.com/products/compute/guides-for-server-management/backup-to-an-external-server.md).

# Backup to an external server

***

When you back up your VM or dedicated server, you might want to store the backups on an external server rather than locally. This is especially relevant when dealing with large backups and you don’t have enough space to keep them on‑premises.

This command opens an SSH session to the external server `backup.mydomain.com` and streams the tar archive directly into the file `/backup/fullbackup.tar.gz`.

{% code title="Command" %}

```
tar zcvf - / | ssh root@backup.mydomain.com "cat > /backup/fullbackup.tar.gz"
```

{% endcode %}

In other words, you no longer need to store the backup on the local hard drive temporarily.&#x20;

## Automation

If you want to run this in a crontab using an SSH key with a password, you need to use an SSH agent to unlock the key. To start the agent and add your SSH key:

{% code title="Commands" %}

```
eval $(ssh-agent -a ~/.ssh/my-ssh-agent.sock)
export SSH_AUTH_SOCK=~/.ssh/my-ssh-agent.sock
ssh-add ~/.ssh/id_ed22519
```

{% endcode %}

Now you can run it in a crontab like this, for example, every 12th hour:

```
0 */12 * * * export SSH_AUTH_SOCK=~/.ssh/my-ssh-agent.sock && tar zcvf - / | ssh root@backup.mydomain.com "cat > /backup/fullbackup.tar.gz"
```

## The other way around

If you want to run a backup **from** the external server, you can do it like this (this command is run from the external server):

```
ssh root@server.mindoman.com 'tar zvcf - /' > /backup/fullbackup.tar.gz
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://docs.glesys.com/products/compute/guides-for-server-management/backup-to-an-external-server.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.
