How to Migrate your Shinobi to another Machine
Learn to move your Shinobi from one machine to another.
Shinobi is installed at /home/Shinobi by default. Please have your new machine have the Operating System installed and ready for installing Shinobi. Do not install Shinobi on it until backup steps are completed.
You may need to be root to do these steps.
Important Files
- Videos Folder : /home/Shinobi/videos
- SQL Database : /var/lib/mysql
- Configuration File : /home/Shinobi/conf.json
- Superuser Credentials : /home/Shinobi/super.json
Make a Backup of your Monitors from the Dashboard
- Click your Username in the top left.
- Select Monitors.
- Select all the Monitors (or your desired ones) and click Export.
- A file will be downloaded, keep this in a safe place. These are your Monitor configurations.
Copying the Database
There are two ways to do this. One may seem easier than the other depending on your experience.
Direct Copy of /var/lib/mysql
You can make a direct copy of this directory and place in the exact same place on your new machine. Then you can install Shinobi.
mysqldump
You can use the command line to dump the database then re-import later when you have MariaDB (MySQL) installed.
mysqldump -p ccio > /home/ShinobiDatabaseBackup.sql
The file that is created will be the contents of your database. Just import this SQL file after installing Shinobi.
Copying the Configuration File and Superuser Credentials
Navigate to your Shinobi folder and copy the following files to a safe directory.
- conf.json
- super.json
Once Shinobi is installed place these files in your Shinobi folder.
Copying your Videos
After installing and Stopping Shinobi you can place your videos into the filesystem. Do not start Shinobi without importing your SQL database first.
/home/Shinobi/videos is the default location. Place it in the same place in your new machine's Shinobi installation.
Importing a Database
This can only be done once a fresh Shinobi is installed.
Navigate to the directory where your dump is located and run the following.
mysql use ccio; source /home/ShinobiDatabaseBackup.sql; exit;
Now your database is imported and you can restart Shinobi.
Restarting Shinobi
pm2 restart all
Summary
- Create backup of Monitors
-
Create backup of Database
- If you choose to copy the directory, you must place the copied folder (/var/lib/mysql) on the new machine before beginning installation. If you are importing the mysqldump then you can run the import after installation of Shinobi.
- Create backup of Configuration and Superuser Credentials
- Install Shinobi
-
Stop Shinobi
- pm2 stop all
- Copy Videos to Filesystem
- Copy over the conf.json and super.json files into the new Shinobi folder
-
Import the mysqldump you made previously
- Only if you don't decide to copy the /var/lib/mysql folder instead.
-
Restart Shinobi
- pm2 restart all