Lost MySQL Docker database data after accidental redeploy – need snapshot restore
Anonymous
HOBBYOP

2 months ago

Hi,

I accidentally clicked "Redeploy" on my MySQL 8.0 service (running via Docker) on Railway.

After the redeploy, the database came back empty, as if it was freshly initialized:

- All my production customer data is gone (user accounts, posts, etc.).

- Before the redeploy, everything was working fine in production.

- I think the data directory (/var/lib/mysql) may have been reset or a new disk was created.

I need urgent help to recover the old database state.

My questions:

1) Does Railway keep any snapshots or backups for this MySQL Docker service or its disk (/var/lib/mysql)?

2) If yes, how can I restore a snapshot/backup from before the redeploy time (around: [approximate date and time]) so that my old data comes back?

3) If there is any internal way on your side to attach the previous disk or restore the previous state, please do it or guide me how to do it.

This is critical production data for my customers, so any help to restore the previous database state as fast as possible would be really appreciated.

Thank you.

Solved$10 Bounty

Pinned Solution

2 months ago

Your data is gone. There is no way to recover this unless you have explicitly created off-site backups yourself.

Data in containers is ephemeral - it only exists for the lifetime of the container. By redeploying your service, you have destroyed the existing container (along with all data) and created a new one, with a fresh filesystem.

To solve this, containers have a concept of volumes - these are like directories that you can link (mount) to a specific path within a container.

If you right-click your service, you will see an option to attach a volume. It will prompt you for a mount path, which in your case should be set to /var/lib/mysql. Any data written by the service to this directory (and subdirectories) will be stored in the volume instead of the container. If the container is ever destroyed and re-created, the data will remain.

IMPORTANT: I do not know if attaching a volume to a directory that already contains data will cause that data to be moved over to the volume, though I suspect this will not be the case, therefore I implore you to backup any data you do have (i.e. via phpMyAdmin exports) before you attach a volume.

Further, I would encourage you to explore the Backups option that is available to volumes.

8 Replies

Anonymous
HOBBYOP

2 months ago

From the MySQL logs I can see shutdown and startup times like:

2026-01-12T00:42:54Z - Received SHUTDOWN

...

2026-01-17T04:54:44Z - Received SHUTDOWN (after I clicked redeploy)

2026-01-17T04:54:51Z - MySQL starting again

Before the last shutdown on 2026-01-17, all my customer data was present.

After the restart, the database looks empty.

If you have any snapshots/backups around or before these timestamps, please help me restore them.


2 months ago

Hello,
You do not have a volume for persistent storage. Without that, your data is gone.
I will open this up to the community so they can help you prevent this again in the future.
Best,
Brody


Status changed to Awaiting User Response Railway about 2 months ago


2 months ago

Your data is gone. There is no way to recover this unless you have explicitly created off-site backups yourself.

Data in containers is ephemeral - it only exists for the lifetime of the container. By redeploying your service, you have destroyed the existing container (along with all data) and created a new one, with a fresh filesystem.

To solve this, containers have a concept of volumes - these are like directories that you can link (mount) to a specific path within a container.

If you right-click your service, you will see an option to attach a volume. It will prompt you for a mount path, which in your case should be set to /var/lib/mysql. Any data written by the service to this directory (and subdirectories) will be stored in the volume instead of the container. If the container is ever destroyed and re-created, the data will remain.

IMPORTANT: I do not know if attaching a volume to a directory that already contains data will cause that data to be moved over to the volume, though I suspect this will not be the case, therefore I implore you to backup any data you do have (i.e. via phpMyAdmin exports) before you attach a volume.

Further, I would encourage you to explore the Backups option that is available to volumes.


Status changed to Solved Anonymous about 2 months ago


thaumanovic

Your data is gone. There is no way to recover this unless you have explicitly created off-site backups yourself.Data in containers is ephemeral - it only exists for the lifetime of the container. By redeploying your service, you have destroyed the existing container (along with all data) and created a new one, with a fresh filesystem.To solve this, containers have a concept of volumes - these are like directories that you can link (mount) to a specific path within a container.If you right-click your service, you will see an option to attach a volume. It will prompt you for a mount path, which in your case should be set to /var/lib/mysql. Any data written by the service to this directory (and subdirectories) will be stored in the volume instead of the container. If the container is ever destroyed and re-created, the data will remain.IMPORTANT: I do not know if attaching a volume to a directory that already contains data will cause that data to be moved over to the volume, though I suspect this will not be the case, therefore I implore you to backup any data you do have (i.e. via phpMyAdmin exports) before you attach a volume.Further, I would encourage you to explore the Backups option that is available to volumes.

Anonymous
HOBBYOP

2 months ago

Ok, thanks for the clarification and help.

I’ll set up a proper volume and backups so this doesn’t happen again.


Status changed to Awaiting Railway Response Railway about 2 months ago


brody

Hello,You do not have a volume for persistent storage. Without that, your data is gone.I will open this up to the community so they can help you prevent this again in the future.Best,Brody

Anonymous
HOBBYOP

2 months ago

Ok, thanks for your help.


2 months ago

You are most welcome. Please feel free to reach out again if you require further assistance.


Anonymous
HOBBYOP

2 months ago

Can I get information about the backup policy in Railway, especially for Pro plans? Are all plans without automatic backups?


Can I get information about the backup policy in Railway, especially for Pro plans? Are all plans without automatic backups?

2 months ago

You can configure backup schedules on volumes. The options available are daily, weekly, and monthly, each with their own retention policies.

I believe (though I'm not sure) these are only available on the Pro plan - the docs don't seem to mention unfortunately.


Status changed to Solved brody about 2 months ago


Loading...