Tag archive for: scp

How to migrate your MySQL / MariaDB database with mysqldump, tar and scp

If you had been building the content for your new WordPress site on a Raspberry Pi 3, there will come a time when you need to migrate the underlying MySQL database to another machine, for eg. a DigitalOcean droplet, for production usage.

MySQL provides us with the mongodump client utility to produce a set of SQL statements that can be executed to reproduce the original database object definitions and table data.

A simple MySQL database migration can be performed with the following steps:

  1. Use mysqldump to get the set of SQL statements that can be executed to reproduce the original database object definitions and table data.
  2. If the mysqldump output is too big, use the tar command to compress it.
  3. Use the scp command to send the mysqldump output from the source server to the destination server.
  4. If you had used the tar command to compress the mysqldump output, use the tar command at the destination server to decompress it.
  5. Execute the set of SQL commands in the mysqldump output at the destination server.

This post documents how you can migrate your MySQL / MariaDB database with utilities provided by MySQL and most Linux servers.

How to migrate your MongoDB database instance with mongodump, mongorestore, tar and scp

Migration of MongoDB database is part and parcel of DevOps, especially when you are running your own projects.

MongoDB provides us with two utilities for performing database migration – mongodump and mongorestore.

A simple MongoDB database migration can be performed in 5 steps:

  1. Use the mongodump command to export the data of a MongoDB database instance as files in the source server’s filesystem.
  2. Use the tar command to compress the exported files as a single .tar.gz file in the source server’s filesystem.
  3. Use the scp command to send the .tar.gz file from the source server to the destination server.
  4. Use the tar command to decompress the .tar.gz file at the destination server.
  5. Use the mongorestore to import the extracted files into the destination MongoDB database.

This post discusses how you can perform MongoDB database migration with utilities provided by MongoDB and most Linux servers.