forgejo/discussions
49
43

How to move Forgejo from a server to another ? #292

Open
opened 2025年02月08日 04:53:03 +01:00 by KaKi87 · 8 comments
Member
Copy link

Hello,

As I'm ending my current server rental and starting another, how to move my Forgejo from one to the other ?

I'm sorry if this was already asked, I looked but I didn't find anything.

Thanks

Hello, As I'm ending my current server rental and starting another, how to move my Forgejo from one to the other ? I'm sorry if this was already asked, I looked but I didn't find anything. Thanks

That's interesting and I don't think this happens quite often, but I think you can frame moving Forgejo between servers as backing it up on the current server and then trying to restore Forgejo from the backup on the other server.

That's interesting and I don't think this happens quite often, but I think you can frame moving Forgejo between servers as backing it up on the current server and then trying to restore Forgejo from the backup on the other server.
Owner
Copy link

@KaKi87 If you need assistance, it would help a lot to explain your setup, for example the procedure differs between a setup in docker and from binary and depends on the database.

Basically, the steps for a binary installation should look like this:

  • prepare the next server for Forgejo by following the installation instructions (e.g. for binary https://forgejo.org/docs/latest/admin/installation-binary/)
    • set up the user
    • install dependencies such as git and git-lfs
    • set up the database server if you don't use SQLite
  • stop Forgejo on the old server
  • move the data from the old server
    • Git repos, attachments data etc, and place it in the same location
    • Forgejo binary, config files, maybe other utilities such as systemd service and if you use the system's ssh service, don't forget the SSH keys, e.g. from /home/git/.ssh/authorized_keys
    • move the database, in case of sqlite copy the db file and verify there is no .wal file next to it. If it exists, copy it as well.
  • double-check the filesystem permissions on the moved data: It should be read- and writable by the system user of Forgejo and by no one else
  • start Forgejo again and see what happens :)

For docker, it means moving the mounted volumes associated to your container and then starting the same container setup on the new server.

If you face any issues, let us know how we can be of assistance.

@KaKi87 If you need assistance, it would help a lot to explain your setup, for example the procedure differs between a setup in docker and from binary and depends on the database. Basically, the steps for a binary installation should look like this: - prepare the next server for Forgejo by following the installation instructions (e.g. for binary https://forgejo.org/docs/latest/admin/installation-binary/) - set up the user - install dependencies such as git and git-lfs - set up the database server if you don't use SQLite - stop Forgejo on the old server - move the data from the old server - Git repos, attachments data etc, and place it in the same location - Forgejo binary, config files, maybe other utilities such as systemd service and if you use the system's ssh service, don't forget the SSH keys, e.g. from /home/git/.ssh/authorized_keys - move the database, in case of sqlite copy the db file and verify there is no .wal file next to it. If it exists, copy it as well. - double-check the filesystem permissions on the moved data: It should be read- and writable by the system user of Forgejo and by no one else - start Forgejo again and see what happens :) For docker, it means moving the mounted volumes associated to your container and then starting the same container setup on the new server. If you face any issues, let us know how we can be of assistance.

I find myself wanting to know the same thing.

I'm moving from a stand alone install, to a docker install. How would I move files that are part of the git?
I suppose I could do a git pull and then a git push

I find myself wanting to know the same thing. I'm moving from a stand alone install, to a docker install. How would I move files that are part of the git? I suppose I could do a git pull and then a git push

@forgejo-moderation @PlayBoxTech reads like spambot to me.

@forgejo-moderation @PlayBoxTech reads like spambot to me.
Author
Member
Copy link

Thank you for your answers, and sorry for the lack of details, I indeed wanted a generic answer first, which would eventually make its way to the documentation, as I looked there before asking and I think it would be great for people trying to do this in the future to have it there.

I did setup from binary, as that's wh I like about Forgejo : being as simple to install as running a binary next to a con file containing database details. I miss that about new apps. Anyhoo...

backing it up on the current server and then trying to restore Forgejo from the backup on the other server

That's actually what I did, and here's the issue I encountered : release files are no longer downloadable, even though they are listed, and everything else works fine.

Thanks

Thank you for your answers, and sorry for the lack of details, I indeed wanted a generic answer first, which would eventually make its way to the documentation, as I looked there before asking and I think it would be great for people trying to do this in the future to have it there. I did setup from binary, as that's wh I like about Forgejo : being as simple to install as running a binary next to a con file containing database details. I miss that about new apps. Anyhoo... > backing it up on the current server and then trying to restore Forgejo from the backup on the other server That's actually what I did, and here's the issue I encountered : release files are no longer downloadable, even though they are listed, and everything else works fine. Thanks

I'm moving from a stand alone install, to a docker install. How would I move files that are part of the git?

I had this scenario around December 2024. My approach was:

Old machine running Debian Bookworm using the downloaded binary in combination with SystemD and PostgreSQL:

  1. Set Nginx (my reverse proxy) to maintenance mode (= return HTTP Status code 503).
  2. Run forgejo doctor check all (see https://forgejo.org/docs/v10.0/admin/upgrade/#backup)
  3. Run forgejo manager flush-queues
  4. Run forgejo dump to generate a archive (I went with the extra option for a .tar.gz to maintain file permissions)
  5. Run pg_dump resp. pg_dumpall with the respective database (or the whole cluster)
  6. scp the SQL dump and tarball to the new server

On the new server running Debian Bookworm using Podman with the rootless OCI, generating SystemD files. Still PostgreSQL as database.

  1. Add a user for Forgejo (preferably the first one (uid 1000) as this eases the communication between the host and the containers).
  2. Enable linger to that user (so you can start SystemD services without the user being logged in)
  3. Move the tarball and SQL dump into the home
  4. Make sure the environment variable XFG_RUNTIME_DIR is set to the correct value.
  5. Create a pod with the exposed ports (needed because you'll have multiple containers that need to talk to each other)
  6. Create a container in that pod with a rootless Forgejo
  7. Create a container with a database
  8. Use environment variables to define the app.ini settings as needed.
  9. Mount the untared archive in the right places as volumes.
  10. Import the SQL back into the database.
  11. Start the database container
  12. Start the Forgejo container
  13. Generate SystemD files.
  14. Stop the pod
  15. Start the SystemD file for the pod
  16. Status and Enable those SystemD services

I plan to eventually write down a more detailed instruction on my blog.

> I'm moving from a stand alone install, to a docker install. How would I move files that are part of the git? I had this scenario around December 2024. My approach was: Old machine running Debian Bookworm using the downloaded binary in combination with SystemD and PostgreSQL: 1. Set Nginx (my reverse proxy) to maintenance mode (= return HTTP Status code 503). 2. Run `forgejo doctor check all` (see https://forgejo.org/docs/v10.0/admin/upgrade/#backup) 3. Run `forgejo manager flush-queues` 4. Run `forgejo dump` to generate a archive (I went with the [extra option](https://forgejo.org/docs/latest/admin/command-line/#dump) for a .tar.gz to maintain file permissions) 5. Run `pg_dump` resp. `pg_dumpall` with the respective database (or the whole cluster) 6. scp the SQL dump and tarball to the new server On the new server running Debian Bookworm using Podman with the rootless OCI, generating SystemD files. Still PostgreSQL as database. 1. Add a user for Forgejo (preferably the first one (uid 1000) as this eases the communication between the host and the containers). 2. Enable linger to that user (so you can start SystemD services without the user being logged in) 3. Move the tarball and SQL dump into the home 4. Make sure the environment variable `XFG_RUNTIME_DIR` is set to the correct value. 5. Create a pod with the exposed ports (needed because you'll have multiple containers that need to talk to each other) 6. Create a container in that pod with a rootless Forgejo 7. Create a container with a database 8. Use [environment variables](https://forgejo.org/docs/latest/admin/installation-docker/#configuration) to define the `app.ini` settings as needed. 9. Mount the untared archive in the right places as volumes. 10. Import the SQL back into the database. 11. Start the database container 12. Start the Forgejo container 13. Generate SystemD files. 14. Stop the pod 15. Start the SystemD file for the pod 16. Status and Enable those SystemD services I plan to eventually write down a more detailed instruction on my blog.

First back up your Forgejo data from the old server, including the gitea directory (usually located in /var/lib/gitea) and the database (using a tool like mysqldump or pg_dump, depending on your database). Then, set up Forgejo on the new server with the same version, copy your backed-up gitea files to the new server, restore the database, and make sure the configuration file (app.ini) is properly updated with the new server details. After that, start Forgejo and it should work the same as before.

First back up your Forgejo data from the old server, including the gitea directory (usually located in /var/lib/gitea) and the database (using a tool like mysqldump or pg_dump, depending on your database). Then, set up Forgejo on the new server with the same version, copy your backed-up gitea files to the new server, restore the database, and make sure the configuration file (app.ini) is properly updated with the new server details. After that, start Forgejo and it should work the same as before.

@danielhess219 forgive me for asking: are you a human or an AI?

@danielhess219 forgive me for asking: are you a human or an AI?
Sign in to join this conversation.
No Branch/Tag specified
No results found.
No results found.
Labels
Clear labels
User research - Accessibility
Requires input about accessibility features, likely involves user testing.
User research - Blocked
Do not pick as-is! We are happy if you can help, but please coordinate with ongoing redesign in this area.
User research - Community
Community features, such as discovering other people's work or otherwise feeling welcome on a Forgejo instance.
User research - Config (instance)
Instance-wide configuration, authentication and other admin-only needs.
User research - Errors
How to deal with errors in the application and write helpful error messages.
User research - Filters
How filter and search is being worked with.
User research - Future backlog
The issue might be inspiring for future design work.
User research - Git workflow
AGit, fork-based and new Git workflow, PR creation etc
User research - Labels
Active research about Labels
User research - Moderation
Moderation Featuers for Admins are undergoing active User Research
User research - Needs input
Use this label to let the User Research team know their input is requested.
User research - Notifications/Dashboard
Research on how users should know what to do next.
User research - Rendering
Text rendering, markup languages etc
User research - Repo creation
Active research about the New Repo dialog.
User research - Repo units
The repo sections, disabling them and the "Add more" button.
User research - Security
User research - Settings (in-app)
How to structure in-app settings in the future?
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
7 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
forgejo/discussions#292
Reference in a new issue
forgejo/discussions
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?