Migrating from Symbiosis

From Sympl Wiki
Revision as of 11:34, 17 October 2021 by Phill104 (talk | contribs) (→‎Testing the sites)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This rough guide will take you through migrating from a server running Symbiosis, to a new server running Sympl.

It requires a little downtime of any sites running on the old server, but you have the option do a dry-run and check things work before committing to the change.

Note that while it's not needed for the dry-run, you will need access to change your DNS records to make the change.

This guide has not been fully tested yet, so you should ensure you do the dry run before the live run.

Preparation

On The Destination Server Running Sympl

Get the Sympl user's MySQL password, with sudo cat /home/sympl/mysql_password

Make a directory for incoming databases mkdir /home/sympl/incoming-db

On The Source Server Running Symbiosis

Add the new server's sympl user MySQL details to current database.

sudo mysql --defaults-file=/etc/mysql/debian.cnf -e "CREATE USER 'sympl'@'localhost' IDENTIFIED BY 'password-from-new-server';"

sudo mysql --defaults-file=/etc/mysql/debian.cnf -e "GRANT ALL PRIVILEGES ON * . * TO 'sympl'@'localhost';"

TIPS

If on your source server you are running CMS packages such as Joomla or Wordpress etc, it may be a good idea to clear their cache. In many cases the cache can double the file size of the site so clearing this cache can reduce not only processing time but the amount of data that needs to be copied to the new location.

Dry Run

On The Source Server Running Symbiosis

Dump the Databases

sudo /etc/symbiosis/backup.d/pre-backup.d/10-dump-mysql

Sync Databases and Sites To New Server

rsync -aviP /var/backups/mysql/* sympl@new-server.example.com:~/incoming-db

This will overwrite any domains on the new server with the same details.

rsync -aviP /srv/*.* sympl@new-server.example.com:/srv/

On The Destination Server Running Sympl

cd /home/sympl/incoming-db

If have any local databases, exclude: roundcube.sql.gz, information_schema.sql.gz, performance_schema.sql.gz

If you don't have any local databases, exclude: roundcube.sql.gz, information_schema.sql.gz, performance_schema.sql.gz

zcat filename.sql.gz | mysql -u 'sympl' -p your_database

Once this is all complete, run sudo mysql_upgrade to ensure any database updates have happened.

Then run: sudo sympl-filesystem-security; sudo sympl-web-configure

Testing the sites

For each site, you'll probably want to test things, which you can do by editing your hosts file and then browsing to the sites manually.

Once you're happy everything is working, then you can do the live run.

Live Run

You will need to update the DNS for the relevant domains when making this change, so before starting this ensure you have access to change the DNS all the domains being moved.

On The Source Server Running Symbiosis

Stop the services to prevent anything changing while you're migrating things over.

You can skip this step if you're not moving all the sites at once, or aren't worried about changes not being copied over while DNS propagates.

touch /etc/symbiosis/monit.d/disable

sudo service apache2 stop

sudo service exim4 stop

sudo service dovecot stop

If you need to re-enable these services later, you can do so with rm /etc/symbiosis/monit.d/disable

Dump the Databases

sudo /etc/symbiosis/backup.d/pre-backup.d/10-dump-mysql

Sync Sites And Databases To New Server

rsync -aviP /var/backups/mysql/* sympl@new-server.example.com:~/incoming-db

This will overwrite any domains on the new server with the same details.

rsync -aviP /srv/*.* sympl@new-server.example.com:/srv/

On The Destination Server Running Sympl

cd /home/sympl/incoming-db

If you have any local databases already, exclude: mysql.sql.gz roundcube.sql.gz, information_schema.sql.gz, performance_schema.sql.gz

Note that you will need to create new databases and users manually. to replace the old ones.

If you don't have any local databases, exclude: roundcube.sql.gz, information_schema.sql.gz, performance_schema.sql.gz

For every file in the directory, do zcat filename.sql.gz | mysql -u 'sympl' -p your_database

Once this is all complete, run sudo mysql_upgrade to ensure any database updates have happened.

Then run: sudo sympl-filesystem-security; sudo sympl-web-configure

Move the DNS to Point To The New Server

You should now make the DNS change if you haven't done so already, but in the meantime you can edit your hosts file to make sure everything looks right.

Updating phpMyAdmin and Roundcube databases

If you're using phpMyAdmin, then the password from the old server will have overwritten the local password. You can fix this with: mysql -e "SET PASSWORD FOR 'phpmyadmin'@'localhost' = PASSWORD('$( grep '^$dbpass' /etc/phpmyadmin/config-db.php | sed -e 's|^\$dbpass=.||' -e 's|.;$||' )');"

Similarly, the password for RoundCube webmail will have been overwritten. This can be fixed with:

mysql -e "SET PASSWORD FOR 'roundcube'@'localhost' = PASSWORD('$( grep '^$dbpass' /etc/roundcube/debian-db.php | sed -e 's|^\$dbpass=.||' -e 's|.;$||' )');"