Container migration playbook
If you need to migrate containers and data between hosts, do the following:
- Set the
configure_rsync_daemon
variable for the target host totrue
to setup an rsync daemon. - Initialize the
rsync_daemon_modules
variable for the target host to configure rsync modules. - Set the
configure_xxxxx
variable for the target host totrue
to prepare the target host. - Set the
start_xxxxx
variable for the target host tofalse
because we don't want to start any services before copying data. - Run Ansible. With the above configuration, it will prepare the target host without starting any service.
- Set the
start_xxxxx
variable for the source host tofalse
to stop the service we're migrating. - Run Ansible.
- Copy data from the source host to the target host. You can use
scripts/copy-data.sh
script to copy data from one host to another. - Remove the
start_xxxxx
from the target host configuration because it defaults to theconfigure_xxxxx
value, which is set totrue
. - If needed, update endpoint definitions in
config/ansible/inventory/group_vars/all/main.yaml
. - Run Ansible.
- Verify that the container works in the target environment as expected.
- Remove the
start_xxxxx
variable from the source host configuration. - Remove the
configure_xxxxx
variable from the source host configuration. - Run Ansible. This will remove all the copied data from the source host.
- Delete data in the source host if it's not deleted automatically, such as media directories.
- If not needed anymore, disable the rsync daemon by removing the
configure_rsync_daemon
andrsync_daemon_modules
variables in the target host configuration. - Commit the changes in the repository.
Data migration examples
These examples assume that the current working directory is the root of this repository:
- Copy one directory from one host to another by connecting an rsync daemon running on the target host:
scripts/copy-data.sh "user@source.host" "/source/directory" "rsync://rsync_user@target.host/destination/directory"
- Copy one directory from one host to another using rsync:
scripts/copy-data.sh "user@source.host" "/source/directory" "user@target.host:/destination/directory/"