mailcow-dockerized-docs/docs/backup_restore_migrate/b_r_m_migration.en.md

85 Zeilen
3 KiB
Markdown

2023-05-25 12:08:41 +02:00
### Migration within the same system type (x86 to x86, ARM64 to ARM64, etc.)
2022-01-29 20:07:02 +01:00
!!! warning
This guide assumes you intend to migrate an existing mailcow server (source) over to a brand new, empty server (target). It takes no care about preserving any existing data on your target server and will erase anything within `/var/lib/docker/volumes` and thus any Docker volumes you may have already set up.
!!! tip
Alternatively, you can use the `./helper-scripts/backup_and_restore.sh` script to create a full backup on the source machine, then install mailcow on the target machine as usual, copy over your `mailcow.conf` and use the same script to restore your backup to the target machine.
2022-09-03 19:32:00 +02:00
**1\.**
2023-05-25 12:08:41 +02:00
Follow the [installation guide](../getting-started/i_u_m_install.en.md) to install Docker and Compose.
2022-01-29 20:07:02 +01:00
**2\.** Stop Docker and assure Docker has stopped:
```
systemctl stop docker.service
systemctl status docker.service
```
2022-09-03 19:32:00 +02:00
2023-05-25 12:08:41 +02:00
**3\.** Run the following commands on the source machine (take care of adding the trailing slashes in the first path parameter as shown below!)
!!! danger
This command (the second one) deletes everything that is already under `/var/lib/docker/volumes` on the target server. So make sure that nothing important is left on the target server before running the following commands!
2022-01-29 20:07:02 +01:00
```
rsync -aHhP --numeric-ids --delete /opt/mailcow-dockerized/ root@target-machine.example.com:/opt/mailcow-dockerized
rsync -aHhP --numeric-ids --delete /var/lib/docker/volumes/ root@target-machine.example.com:/var/lib/docker/volumes
```
**4\.** Shut down mailcow and stop Docker on the source machine.
2022-12-15 15:31:09 +01:00
=== "docker compose (Plugin)"
2022-12-14 22:09:09 +01:00
``` bash
cd /opt/mailcow-dockerized
docker compose down
systemctl stop docker.service
```
2022-12-15 15:31:09 +01:00
=== "docker-compose (Standalone)"
2022-12-14 22:09:09 +01:00
``` bash
cd /opt/mailcow-dockerized
docker-compose down
systemctl stop docker.service
```
2022-01-29 20:07:02 +01:00
2023-05-25 12:08:41 +02:00
**5\.** Repeat step 3 with the same commands. This is much faster than the first time, because this time only the diffs have to be synchronized.
2022-01-29 20:07:02 +01:00
**6\.** Switch over to the target machine and start Docker.
```
systemctl start docker.service
```
**7\.** Now pull the mailcow Docker images on the target machine.
2022-12-15 15:31:09 +01:00
=== "docker compose (Plugin)"
2022-12-14 22:09:09 +01:00
``` bash
cd /opt/mailcow-dockerized
docker compose pull
```
2022-12-15 15:31:09 +01:00
=== "docker-compose (Standalone)"
2022-12-14 22:09:09 +01:00
``` bash
cd /opt/mailcow-dockerized
docker-compose pull
```
2022-01-29 20:07:02 +01:00
2023-05-25 12:08:41 +02:00
**8\.** Start the whole mailcow stack and wait a moment.
2022-12-15 15:31:09 +01:00
=== "docker compose (Plugin)"
2022-12-14 22:09:09 +01:00
``` bash
docker compose up -d
```
2022-12-15 15:31:09 +01:00
=== "docker-compose (Standalone)"
2022-12-14 22:09:09 +01:00
``` bash
docker compose up -d
```
2023-05-25 12:08:41 +02:00
If everything worked, mailcow should look and work the same on the new server as it did on the old one!
2022-01-29 20:07:02 +01:00
**9\.** Finally, change your DNS settings to point to the target server. Also check the `SNAT_TO_SOURCE` variable in your `mailcow.conf` file if you have changed your public IP address, otherwise SOGo may not work.
2023-05-25 12:08:41 +02:00
**10\.** Enjoy mailcow on the new server! :grinning:
---