Moving a Telegram bot from Railway to a VPS: what to check

Copying a SQLite database file can leave the latest requests behind. See how to avoid that during a Railway-to-VPS migration, verify startup and prepare a rollback.

The SQLite experiment uses test data, not customer data. The pilot checks an existing Python bot's compatibility and confirms terms before VPS payment. The owner maintains the application and backups after handover.

English transcript

When you launch a bot for the first time, mistakes are not so serious: fix the settings and try again. But a running Telegram bot already has users and a history. Moving it from Railway to your own VPS is a different job. Here is what you must not forget.

Start with the environment. The repository contains code, but may not contain the database, uploaded files or environment variables. Check the Python version and dependencies. Move the bot token separately from the code, not into a public repository.

Imagine: a bot has just accepted a new request. You transfer its SQLite database file to a new server, start the bot — and the request is missing. The fresh record may still be in a separate SQLite journal. We reproduced this with test data: copying only the database file left the latest record out. A backup made using SQLite preserved the record. Before moving, restore the backup and check that the latest records are present.

There is another trap. If the bot receives messages through long polling, do not run two copies with the same token at the same time. Pause message processing, wait for writes to finish and make the final snapshot while the source files are still accessible: on Railway, stopping the process can terminate the container itself. Disable the old instance and its automatic startup. Only after restoring the data should you start the copy on the VPS.

Now configure automatic startup with systemd. Reboot the VPS and check: the bot responds and new records are saved, with no errors in the logs. Simply seeing a running process is not enough.

Do not delete the old project immediately. If you need to roll back, stop the new copy, make a fresh snapshot and restore it on the original server. Otherwise you will lose records that arrived after the move.

On MOTSELL, we published a verified example and instructions. If you already have a Python bot using long polling, with SQLite or no database, you can request a migration. We will check compatibility and agree on the terms before you pay for a VPS. Everything is at motsell.com.