# Creating a duplicate of production environment

**URL:** https://meta.discourse.org/t/creating-a-duplicate-of-production-environment/61966
**Category:** Self-hosting
**Created:** [2 במאי,‏ 2017,‏ 3:38pm UTC](https://meta.discourse.org/t/creating-a-duplicate-of-production-environment/61966 "2017-05-02T15:38:05Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![Henti\_Smith](https://avatars.discourse-cdn.com/v4/letter/h/ebca7d/32.png) [@Henti\_Smith](https://meta.discourse.org/u/Henti_Smith)
#### Post date: [19 במאי,‏ 2017,‏ 2:34pm UTC](https://meta.discourse.org/t/creating-a-duplicate-of-production-environment/61966/9 "2017-05-19T14:34:54Z")

</div>

Just to close the loop. Steps I followed.

# On Production:

Get latest backup from /var/discourse/shared/standalone/backups/default

# On New/Dev instance :

```
mkdir /srv/discourse
git clone https://github.com/discourse/discourse_docker.git /srv/discourse
cd /srv/discourse
# If you need a specific commit, do:
# git reset --hard git_commit_hash_goes_here

```

Copy the app.yml from your production server to new/dev instance. Update app.yml

```
new_hostname=$(hostname -f)
sudo sed -i "s/^ DISCOURSE_HOSTNAME:.*$/ DISCOURSE_HOSTNAME: $new_hostname/g" containers/app.yml
# If you need to duplicate a specific version of discourse, use the git commit hash, otherwise use the branch name. Below we are using stable branch
sudo sed -i 's/^ #version: .*$/ version: stable/g' containers/app.yml
sudo sed -i "s/^ DISCOURSE_DEVELOPER_EMAILS: .*$/ DISCOURSE_DEVELOPER_EMAILS: 'sysadmins@yourcompany.com'/g" containers/app.yml

```

Bootstrap, start the app container

```
sudo ./launcher bootstrap app
sudo ./launcher start app

```

Copy your backup to restore location

```
sudo mkdir /var/discourse/shared/standalone/backups/default -p
sudo cp /tmp/discourse-backup/lgtm* /var/discourse/shared/standalone/backups/default

```

Now we run commands in the container to prepare, and restore the backup, and fix the permissions.

```
backup=$(basename /var/discourse/shared/standalone/backups/default/*)
sudo /usr/bin/docker exec -i app discourse restore $backup
sudo /usr/bin/docker exec -i app chown discourse.www-data /var/www/discourse/public/backups/default/ -R 

```

If you get an error about SiteSettings not allowing restore. (I think it’s older version of discourse that needs this)

```
sudo /usr/bin/docker exec -i app rails runner "SiteSetting.allow_restore = true"

```

I tried using the [Manually create and restore Discourse backups](https://meta.discourse.org/t/advanced-manual-method-of-manually-creating-and-restoring-discourse-backups/18273) method for my restore, but it failed with `rake db:migrate` creating an empty db. Might work for you, I did not test further.

---

_[View the full topic](https://meta.discourse.org/t/creating-a-duplicate-of-production-environment/61966)._
