# Turn my staging server to production

**URL:** https://discourse.roots.io/t/turn-my-staging-server-to-production/15347
**Category:** trellis
**Created:** 2019-04-19T08:18:07Z
**Posts:** 5

## Post 1 by @florentIT — 2019-04-19T08:18:07Z

Hi,

I just finish a website, and during the developpement, we’ve deploy to a staging server ( digital ocean ).  
Now can i just turn this staging server to production by putting the staging variable in the production ansible file and keep my db ?

Sorry if i’m not clear ^^’

Thanks :slight_smile:

PS : Is there a difference between staging and production in treillis ?

---

## Post 2 by @MWDelaney — 2019-04-19T12:44:41Z

The recommended process is to set up a second server for production. You can always tear down Staging when you’re finished if you no longer need it.

You’ll need to migrate the database and uploads from staging, which is pretty easy:

**Uploads**  
Download the `/srv/www/example.com/shared/uploads` directory using (s)FTP

**Database**  
ssh to the staging site:

```
ssh web@staging.example.com
```

Change directories to the current deployment:

```
cd /srv/www/example.com/current
```

Export the database:

```
wp db export
```

Download the exported file with (s)FTP or whatever other method you prefer.

Create and provision your production server.

Deploy to the production server.

Copy the `uploads` directory into the production server’s `/srv/www/example.com/shared` directory with (s)FTP.

Copy the database export from earlier into `/srv/www/example.com/current`

ssh to the production server:

```
ssh web@example.com
```

Change directories to the current deployment:

```
cd /srv/www/example.com/current
```

Reset the database for good measure:

```
wp db reset
```

Import the database export from staging:

```
wp db import [export file name].sql
```

Replace staging URLs with production URLs:

```
wp search-replace staging.example.com example.com
```

And that’s it!

---

## Post 3 by @ben — 2019-04-19T20:54:33Z

Here’s a script you might find useful:

> **[Sync Script for WordPress Database and Uploads | Roots](https://roots.io/plugins/sync-script/)**
>
> Sync your WordPress database and media library between environments with WP-CLI aliases and rsync.

---

## Post 4 by @florentIT — 2019-04-29T11:09:33Z

Thanks a lot :wink: I will do that.

---

## Post 5 by @system — 2019-05-31T08:18:11Z

This topic was automatically closed after 42 days. New replies are no longer allowed.
