# Multisite restores uploads to 'default' instead of actual db name

**URL:** <https://meta.discourse.org/t/multisite-restores-uploads-to-default-instead-of-actual-db-name/130778>\
**Category:** Development\
**Created:** [October 11, 2019, 11:30am UTC](https://meta.discourse.org/t/multisite-restores-uploads-to-default-instead-of-actual-db-name/130778 "2019-10-11T11:30:04Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [October 11, 2019, 11:30am UTC](https://meta.discourse.org/t/multisite-restores-uploads-to-default-instead-of-actual-db-name/130778/1 "2019-10-11T11:30:04Z")

</div>

On Discourse latest beta, docker install, multisite.

Trying to restore a backup with original database `REDACTED` to current database `db8015`. Uploads end up in `default`, both on filesystem and in database.

This happens both when the restore is triggered from the GUI, and when the restore is done on the command line using `RAILS_DB=db8015 RAILS_ENV=production script/discourse restore`.

During the restore process, `RailsMultisite::ConnectionManagement.current_db` changes from the correct database to `default`. I have been able to pin this down to `[Rake::Task['db:_dump'].invoke` in `db.rake`]([https://github.com/discourse/discourse/blame/master/lib/tasks/db.rake#L59](https://github.com/discourse/discourse/blame/master/lib/tasks/db.rake#L59)). )

Before that line, `RailsMultisite::ConnectionManagement.current_db` has the correct value (db8015), after that line, it is `default`.

Looks like [this fix](https://meta.discourse.org/t/hello-from-gitpod-installing-on-google-cloud-automated-dev-setup/128783/11) has broken production somehow @sam?

Logs:

```
[STARTED]
'DHSupport' has started the restore!
Marking restore as running...
Making sure /var/www/discourse/tmp/restores/db8015/2019-10-11-104940 exists...
Copying archive to tmp directory...
Unzipping archive, this may take a while...
No metadata file to extract.
Validating metadata...
  Current version: 20191007140446
  Restored version: 20190908234054
Extracting dump file...
Creating missing functions in the discourse_functions schema
Cannot restore into different schema, restoring in-place
Enabling readonly mode...
Pausing sidekiq...

[deleted a lot of irrelevant stuff]

Clear theme cache
Extracting uploads...
Remapping uploads...
Remapping 'uploads/REDACTED' to 'uploads/default'
Optimizing site icons...
Posts will be rebaked by a background job in sidekiq. You will see missing images until that has completed.
You can expedite the process by manually running "rake posts:rebake_uncooked_posts"
Executing the after_restore_hook...
Cleaning stuff up...
Dropping function from the discourse_functions schema
Removing tmp '/var/www/discourse/tmp/restores/db8015/2019-10-11-104940' directory...
Unpausing sidekiq...
Marking restore as finished...

```

---

_[View the full topic](https://meta.discourse.org/t/multisite-restores-uploads-to-default-instead-of-actual-db-name/130778)._
