# Restore Failure - S3 (compatible) backup

**URL:** https://meta.discourse.org/t/restore-failure-s3-compatible-backup/157939
**Category:** Support
**Created:** [July 16, 2020, 2:16pm UTC](https://meta.discourse.org/t/restore-failure-s3-compatible-backup/157939 "2020-07-16T14:16:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![markersocial](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markersocial/32/170136_2.png) [@markersocial](https://meta.discourse.org/u/markersocial)
#### Post date: [July 16, 2020, 2:16pm UTC](https://meta.discourse.org/t/restore-failure-s3-compatible-backup/157939/1 "2020-07-16T14:16:11Z")

</div>

So I’ve been trying to restore a backup, but getting errors. Looks like it has to do with the s3 backups.

Important to note, this is with a S3 compatible service (Scaleway). However I’m unsure if this error is specific to the compatible service or not, setting it up worked very seamlessly and has been working well. If it is specific to Scaleway, then I’ll likely stop using their service as I understand that only AWS S3 is officially supported.

I used this guide to set up: [Configure an S3 compatible object storage provider for uploads](https://meta.discourse.org/t/using-object-storage-for-uploads-s3-clones/148916#configuration) so this is in the app.yml file.

```plaintext
  after_assets_precompile:
    - exec:
        cd: $home
        cmd:
          - sudo -E -u discourse bundle exec rake s3:upload_assets

```

Used the same configuration for Scaleway too in the app.yml file (did not set it up in the admin settings as it seemed unnecessary): [scaleway config](https://meta.discourse.org/t/using-object-storage-for-uploads-s3-clones/148916#scaleway-object-storage)

I’ve tried both from the admin area and command line on the current server, as well as configuring a new server (copied the app.yml over) and restoring via command line. Got the same errors.

```
[STARTED]
'system' has started the restore!
Marking restore as running...
Making sure /var/www/discourse/tmp/restores/default/2020-07-16-131434 exists...
Downloading archive to tmp directory...
#<Thread:0x000055c73a831df8@/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:116 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
	1: from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:120:in `block (3 levels) in thread_batches'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:128:in `write': undefined method `split' for nil:NilClass (NoMethodError)
EXCEPTION: undefined method `split' for nil:NilClass
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:128:in `write'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:120:in `block (3 levels) in thread_batches'
Trying to rollback...
There was no need to rollback
Cleaning stuff up...
Removing tmp '/var/www/discourse/tmp/restores/default/2020-07-16-131434' directory...
Unpausing sidekiq...
Marking restore as finished...
Notifying 'system' of the end of the restore...
#<Thread:0x000055c73a831510@/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:116 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
	1: from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:120:in `block (3 levels) in thread_batches'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:128:in `write': undefined method `split' for nil:NilClass (NoMethodError)
#<Thread:0x000055c73a8316c8@/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:116 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
	1: from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:120:in `block (3 levels) in thread_batches'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:128:in `write': undefined method `split' for nil:NilClass (NoMethodError)
#<Thread:0x000055c73a8319e8@/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:116 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
	1: from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:120:in `block (3 levels) in thread_batches'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/aws-sdk-s3-1.66.0/lib/aws-sdk-s3/file_downloader.rb:128:in `write': undefined method `split' for nil:NilClass (NoMethodError)
Finished!
[FAILED]
Restore done.

```

Maybe the error is just for downloading the backup? 🧐

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [July 16, 2020, 4:36pm UTC](https://meta.discourse.org/t/restore-failure-s3-compatible-backup/157939/2 "2020-07-16T16:36:17Z")

</div>

> [@markersocial](#):
>
> Maybe the error is just for downloading the backup?

Sounds like it.

I would move backup location to local in the app.yml, rebuild, download the backup file manually and restore from console.

---

<div class="post-metadata">

### Author: ![markersocial](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markersocial/32/170136_2.png) [@markersocial](https://meta.discourse.org/u/markersocial)
#### Post date: [July 16, 2020, 4:44pm UTC](https://meta.discourse.org/t/restore-failure-s3-compatible-backup/157939/3 "2020-07-16T16:44:28Z")

</div>

Ah, that makes sense. Thanks @Falco! 🙂

I’ll give it a shot in the morning and report back~

---

<div class="post-metadata">

### Author: ![markersocial](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markersocial/32/170136_2.png) [@markersocial](https://meta.discourse.org/u/markersocial)
#### Post date: [July 17, 2020, 7:31am UTC](https://meta.discourse.org/t/restore-failure-s3-compatible-backup/157939/4 "2020-07-17T07:31:39Z")

</div>

Thanks @Falco, appreciate it! Worked completely smoothly 😃

I migrated to a new server, seems like it would have been fine staying on the same server as well.

In case someone else wants to reference this later, the steps in more detail where (note that my s3 settings were just in the app.yml file as specified [here](https://meta.discourse.org/t/using-object-storage-for-uploads-s3-clones/148916), nothing customised in the admin settings):

1. On source site, if not a rollback, enable ‘disable emails’ (might not be necessary) and turn on read-only mode (remember to switch these back on the new instance once migration is complete). Create backup, once complete, consider stopping the old instance also (./launcher stop app). Regardless of if a rollback or not, update DNS A records to point to the new server IP. You can do these in a more elegant way or order to minimise downtime, downtime wasn’t a concern for my case (rollback, not launched forum).

2. Install Discourse on the new server and migrate everything custom in the app.yml over including s3 settings, have the Discourse versions be the same or close to the same.

3. Comment out these two records (other s3 settings in the app.yml can be left as is):  
DISCOURSE\_S3\_BACKUP\_BUCKET: BucketName  
DISCOURSE\_BACKUP\_LOCATION: s3

4. Manually download desired backup from s3 or s3 compatible service.

5. Navigate to /var/discourse/shared/standalone/backups and create a new folder called ‘default’ if it doesn’t exist (it won’t if it’s a new install). Then, while in the backups directory run (this changes folder permissions to match what this folder would normally have if Discourse created a local backup - not sure if necessary):  
`chown -R 1000:www-data default`

6. Upload backup into the backups/default folder using a SFTP client, don’t rename the backup file.

7. Rebuild app:  
cd /var/discourse  
./launcher rebuild app

8. Enter app, enable backups and restore (rename BackupFileName.tar.gz):

```plaintext
./launcher enter app
discourse enable_restore
discourse restore BackupFileName.tar.gz

```

1. Once complete, uncomment the two s3 backup file lines in the app.yml from step 2 and rebuild app.

2. You can delete the local backups/default folder and contained backup (/var/discourse/shared/standalone/backups).

Reference:

> [@Restore a backup from the command line](https://meta.discourse.org/t/restore-a-backup-from-command-line/108034):
>
> bookmark This guide explains how to restore a Discourse backup from the command line without using the Discourse web UI. person_raising_hand Required user level: Administrator wrench Console access required Here’s how to restore a Discourse backup from the command line, without ever booting the Discourse web UI. This is handy when you’re moving servers. Prerequisites Before you start, make sure you complete the following steps: Download the latest backup file from the source Disco…

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [August 16, 2020, 7:31am UTC](https://meta.discourse.org/t/restore-failure-s3-compatible-backup/157939/5 "2020-08-16T07:31:54Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
