# Migrating existing data from local postgres to newly deploy Phoenix app on fly

**URL:** <https://community.fly.io/t/migrating-existing-data-from-local-postgres-to-newly-deploy-phoenix-app-on-fly/13007>\
**Category:** Phoenix\
**Tags:** postgres\
**Created:** [May 20, 2023, 7:23am UTC](https://community.fly.io/t/migrating-existing-data-from-local-postgres-to-newly-deploy-phoenix-app-on-fly/13007 "2023-05-20T07:23:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kEND](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kend/32/13144_2.png) [@kEND](https://community.fly.io/u/kEND)\
**Post date:** [May 20, 2023, 7:23am UTC](https://community.fly.io/t/migrating-existing-data-from-local-postgres-to-newly-deploy-phoenix-app-on-fly/13007/1 "2023-05-20T07:23:36Z")

</div>

Can I do this from my laptop using `fly postgres import ...`? (via a tunnel?)  
If so, is this an equivalent to a `pg_restore ...`

---

<div class="post-metadata">

**Author:** ![dangra](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/dangra/32/4413_2.png) [@dangra](https://community.fly.io/u/dangra)\
**Post date:** [May 20, 2023, 6:56pm UTC](https://community.fly.io/t/migrating-existing-data-from-local-postgres-to-newly-deploy-phoenix-app-on-fly/13007/2 "2023-05-20T18:56:57Z")

</div>

Yes, you can use to migrate local postgres to fly.

> [@kEND](#):
>
> If so, is this an equivalent to a `pg_restore ...`

It is quite similar, instead of pg\_restore it does:

```auto
pg_dump -d $SOURCE_POSTGRES_URI | psql -d $TARGET_POSTGRES_URI

```

If you are curious, the actual code is at

> <https://github.com/fly-apps/postgres-importer/blob/5138f66c891748ad42b0d92e5994e03e18086b5a/cmd/migrate/main.go#L135-L150>

---

<div class="post-metadata">

**Author:** ![kEND](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kend/32/13144_2.png) [@kEND](https://community.fly.io/u/kEND)\
**Post date:** [May 20, 2023, 7:39pm UTC](https://community.fly.io/t/migrating-existing-data-from-local-postgres-to-newly-deploy-phoenix-app-on-fly/13007/3 "2023-05-20T19:39:31Z")

</div>

Got it working a few hours ago. Worked great! Thanks!
