# Download backup - email link only

**URL:** https://meta.discourse.org/t/download-backup-email-link-only/59626
**Category:** Support
**Created:** [2017年三月21日 15:23 UTC](https://meta.discourse.org/t/download-backup-email-link-only/59626 "2017-03-21T15:23:55Z")
**Posts on this page:** 1
**Showing post:** 11

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [2017年六月3日 10:08 UTC](https://meta.discourse.org/t/download-backup-email-link-only/59626/11 "2017-06-03T10:08:58Z")

</div>

We had an issue here because it made it much harder to download a backup from a (third party) provider where we don’t have shell access, and upload it to one of our own servers. Especially when handling a large backup and both servers are in the USA (we’re in Europe) this process was costing us hours instead of minutes.

Somehow the backup link does not work with an api\_key so a simple `wget` will not work ☹

We made a small script that can be called from the command line. It needs three parameters:

- username
- password
- download link from the email, including the token

So something like

`./download.sh myuser mypass https://forum.mysite.com/admin/backups/mysite-2017-05-31-113000-v20170526125321.tar.gz?token=d31de61bc07f7bc9060717bc57828584`

Here is the script:

```
#!/bin/bash
USERNAME=$1
PASSWORD=$2
URL=$3
HOSTNAME=$(echo $URL | awk -F/ '{print $3}')

TOKEN=$(
curl \
  --header "X-Requested-With: XMLHttpRequest" \
  -A "MSIE" \
  -b cookies.txt \
  -c cookies.txt \
  -v\
  https://$HOSTNAME/session/csrf|awk -F: '{print $2}'|cut -c2-89
)

echo "Using Token $TOKEN Username $USERNAME Password $PASSWORd"
curl \
  --header "X-Requested-With: XMLHttpRequest" \
  --header "X-CSRF-Token: $TOKEN" \
  --header "Origin: https://$HOSTNAME" \
  -A "MSIE" \
  -b cookies.txt \
  -c cookies.txt \
  -v\
  --data "login=$USERNAME&password=$PASSWORD" \
  https://$HOSTNAME/session

curl \
  -A "MSIE" \
  -b cookies.txt \
  -c cookies.txt \
  -O \
  $URL

```

One more suggestion: would it be an idea to exclude the email with the link from being affected by the `disable_email` setting?

---

_[View the full topic](https://meta.discourse.org/t/download-backup-email-link-only/59626)._
