partkeepr / PartKeepr

Open Source Inventory Management
http://www.partkeepr.org
GNU General Public License v3.0
1.38k stars 400 forks source link

Export database from Virtual Machine version #1138

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi guys, for a long time I use PartKeepr version 0.1.9 on Virtual Machine. Now, I want to update to latest version(not Virtual Machine version), but I'm not sure how to export database from Virtual Machine. Can someone help? Thanks a lot!

christianlupus commented 4 years ago

We had recently multiple such requests.

A few questions before we start: What are the operating systems both on the VM as well as the destination machine? What database exists? Which version? Have you considered the restrictions regarding PHP and database on the destination system?

For a live discussion, you can reach me on IRC for now in #partkeepr on freenode.

ghost commented 4 years ago

Hi, thanks for answer! On VM is Debian(32-bit), for destination I don't know. It's web server with MySQL, phpMyAdmin, PHP etc... "What database exists?" I don't understand the question. I'm looking for database with all users, parts, warehouses etc... Can I export the database in .txt file so later I can import it on new PartKeepr? Yes, I'm currently working on requirements for new PartKeepr.

I guess I have to log in with root/partkeepr in VM.

Gasman2014 commented 4 years ago

Don’t forget that many of the assets (datasheets, images etc) are NOT stored in the database itself but are in the ‘data’ directory and need to be backed up separately.

John Pateman

Sent from my iPhone

On 16 Jul 2020, at 11:49, Pararera notifications@github.com wrote:

 Hi, thanks for answer! On VM is Debian(32-bit), for destination I don't know. It's web server with MySQL, phpMyAdmin, PHP etc... "What database exists?" I don't understand the question. I'm looking for database with all users, parts, warehouses etc... Can I export the database in .txt file so later I can import it on new PartKeepr? Yes, I'm currently working on requirements for new PartKeepr.

I guess I have to log in with root/partkeepr in VM.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

christianlupus commented 4 years ago

On VM is Debian(32-bit), for destination I don't know. It's web server with MySQL, phpMyAdmin, PHP etc...

The thing is, you must have a PHP <= 7.1. Furthermore, MariaDB (a common implementation of MySQL) is supported up to 10.1 (see #1098). If the new system is newer, PartKeepr will cause problems. Just a warning.

"What database exists?" I don't understand the question. I'm looking for database with all users, parts, warehouses etc... Can I export the database in .txt file so later I can import it on new PartKeepr?

I wanted to know if you are using MySQL/MariaDB or PostgreSQL in the VM.

The first step is to stop using the VM instance. We need to export some files and these need to be consistent. Otherwise, you might get strange effects.

Export of the files

In the VM there is the folder data in the PK installation. This folder needs to be backed up.

cd /path/of/pk/installation/data
tar czf /tmp/pk-data.tar.gz .

Copy the file /tmp/pk-data.tar.gz from your VM to your main host. (Thanks @Gasman2014 for the heads-up).

Export of the database

It is possible to export the database into a *.sql file. You will need the sql user and password as well as the database name. If you do not know these values anymore, you can find them in the file /path/to/partkeepr/app/config/parameters.php.

I assume you are using MySQL/MariaDB in the VM. For PostgreSQL there are similar commands but these are incompatible with the destination MySQL.

mysqldump -u $SQLUSER -p $DATABASE > /tmp/partkeepr.sql

Set $SQLUSER and $DATABASE accordingly. The command will ask for the password of the SQL user. The resulting file /tmp/partkeepr.sql you will need as well.

Important Backup the files or even better the whole VM. I have seen this approach taking multiple tries if something was forgotten or overseen. So do not risk your data.

Import the SQL file in the new space

In the new location, start phpMyAdmin and import the SQL file. If you have shell access, you can also use the mysql command line. This should clone the database structure. You might want/need to create a separate user for PartKeepr (or not, depends on your setup). If you need to, do it now.

Install the latest release

Copy the files of the latest release of PartKeepr into the corresponding location on the destination. If you use the git version, you will have to do some extra steps.

Next, restore the data folder in the PartKeepr destination installation.

cd /path/to/dest/pk/installation/data
tar xzf /path/to/pk-data.tar.gz

You can, of course, untar locally and upload via FTP.

The last step should be to run the setup. As soon as the database has been connected, the setup should detect a previous installation of PartKeepr and allow you to keep the settings.

This should be it in theory. I hope I did not miss anything. (Always keep a backup!)

ghost commented 4 years ago

Thanks for help. Please, don't close the issue yet. So, in a nutshell:

I have no data stored outside database(datasheets etc..). Only components, categories, warehouses, etc.. Guess all data are in SQL database.

christianlupus commented 4 years ago

You can have a look into the data folder. Also images, footprints icons and the like are stored there. Just look if there are any files except for potential .gitkeep files: tree /path/to/pk/data or ls -lR /path/to/pk/data.

Your summary is correct. That should do the trick. Just give it a try and see if you can access all your data. If everything is going bad, you might need to migrate the old 0.1.9 version, make it running and then upgrade the PK version.

The will be closed soon! tag enabled the 1-month stall bot, so when no comments are written within 6 weeks the issue is due to be closed. As long as we are writing, the bot is reset again. I just want to do some house-keeping with the issues here.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon if no further activity occurs. Thank you for your contributions.