Hey,

I taked many times to find how migrate our nice Flarum install. That's how we do it:

  1. Backup your DB on the ancient host:

    mysqldump --lock-tables -h [server] -u [user] -p[password] [database] > flarum-sqlbkp_`date +"%Y%m%d"`.bak
  2. Backup your data on the ancient host:

    rsync -Aax flarum/ flarum-dirbkp_`date +"%Y%m%d"`/
  3. Download all of this on your new host:

    scp -r user@host.lol:flarum-* .
  4. Create new DB:

    mysql -u root -p
    CREATE DATABASE flarum;
    exit
  5. Restore old DB on da new:

    mysql -h [server] -u [username] -p[password] [db_name] < flarum-sqlbkp.bak
  6. Do a fresh install of flarum as described here: http://flarum.org/docs/installation/

  7. Restore some of the old data on your new installation:

    cd flarum-dirbkp/
    cp -Rv config.php storage/ assets/ /var/www/fresh-new-flarum/
  8. Reinstall your extensions and it's done !

Hope this little tutorial will help some folks.
Cheers,

    to avoid downtime during DNS propagation, you may also point the old website to the new database

    I did that and it worked.

    a month later

    matunixe thanks for this!

    Could you explain:

    1. "on the ancient host:" - means I run this on the old server's terminal or my local machine terminal?
    2. I understand I don't use square brackets [] where server, user, password, database is?
    3. In [server] I put IP of the old server where DB is?
    4. [user] is DB user or server user?
    5. [password] is password to DB or server?
    6. Is there no space between -p and [password] in -p[password]on purpose?

    So many questions, perhaps you could edit your post to include it ?

      justshipit 6. no space ? but better dont enter the password in command line it will ask you to enter.

      Actually much easy is to zip the root directory of your site, and just to export the db. Then unzip the root directory of your flarum on the new host and import the new database. Change urls if need and database details and you are done.

        7h3ev1l what will be easier way to save old DB so later I can import to new Flarum? I am switching droplets on Digital Ocean and that's why I need to migrate DB.

        matunixe I am getting:

        mysqldump: Got error: 2003: Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (61) when trying to connect

          justshipit Well you cant connect to the server ? Use phpmyadmin if you cant operate with command line.

          3 years later

          matunixe When you do the fresh install do you use the restored database or do you create a new one? I am trying to use the restored one and I get this error:
          error

          I am not sure it is because of the database not being empty but it looks like it...

          EDIT: you have to create a new database and then go to config.php and change the database by hand... then when you access the website again you will be prompt to insert the password for the database again and it will restore the old database.