How to get the ERPNEXT digital ocean to the VM

Hi all,
I have the ERPNext in the digital ocean with customised most of the ERPNext codes from masters and added additional doctypes as per the client convenience. Now they are expecting this whole ERP in VM as there is insufficient net facility in their places. Any way to migrate this to VM. As there is no facility to covert the files to OVA format in digital ocean. I have tried to pull the folders and set the bench migrate it shows pkg resource file error. Any way to get the Fully finished ERP in to VM. with all set data’s and codes.

Unfortunately it doesn’t seem like DigitalOcean has a feature to do that.

For the code changes, you can just use any Git hosting service like GitHub or BitBucket (They have private repositories) if you haven’t done that yet.

For the data, you can use bench backup --with-files and copy the backup file over to the new VM

So basically:
You setup bench again on the new system, make sure it’s a clean VM.
Create a new site by bench new-site [site-name]
Do bench get-app erpnext [git-repo-url]
And then follow the instructions here : https://github.com/frappe/erpnext/wiki/Restoring-From-ERPNext-Backup

Hi @vjFaLk Thanks for your reply,
I will work on it and revert back.

Even for ERPNEXT code edit also the migration will work?.

As I said for the actual code changes you’ve made, you want to push it to Github / Bitbucket and then use bench get-app. The backup command will not take a backup of the code.

Hi @vjFaLk I have followed these steps and got the app
But in erp screen it doesn’t reflecting any thing. I have given few questions below.
while creating the new site the db pulled from the github is showing in the mysql -u root -p. and db is not showing in the bench mysql,
While giving the bench migrate option it show the error after restoring the db.

frappe@erpnext:~/frappe-bench$ bench --site vas migrate
Migrating vas
Executing erpnext.patches.v5_7.item_template_attributes in vas (8723baf2cf)
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 162, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands.py”, line 29, in _func
ret = f(frappe.dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands.py”, line 213, in migrate
frappe.modules.patch_handler.run_all()
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 25, in run_all
if not run_single(patchmodule = patch):
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 52, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 68, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v5_7/item_template_attributes.py”, line 32, in execute
migrate_item_variants()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v5_7/item_template_attributes.py”, line 90, in migrate_item_variants
save_attributes_in_template(item, attribute_value_options)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v5_7/item_template_attributes.py”, line 98, in save_attributes_in_template
template.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 255, in save
self.run_post_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 622, in run_post_save_methods
self.run_method(“on_update”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 566, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 722, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 705, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 560, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/item/item.py”, line 91, in on_update
self.update_variants()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/item/item.py”, line 521, in update_variants
variant.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 240, in save
self.run_before_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 604, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 566, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 722, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 705, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 560, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/item/item.py”, line 76, in validate
self.validate_attributes()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/item/item.py”, line 547, in validate_attributes
frappe.throw(
(“Attribute table is mandatory”))
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 265, in throw
msgprint(msg, raise_exception=exc)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 258, in msgprint
_raise_exception()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 243, in _raise_exception
raise raise_exception, encode(msg)
frappe.exceptions.ValidationError: Attribute table is mandatory

When giving the bench set default site it show this error.
frappe@erpnext:~/frappe-bench$ bench set-default-site vas
frappe app is not installed. Run the following command to install frappe
bench get-app frappe https://github.com/frappe/frappe.git
/bin/sh: 1: /home/frappe/frappe-bench/env/bin/frappe: not found
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 9, in
load_entry_point(‘bench==0.0.0’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/bench-repo/bench/cli.py”, line 60, in cli
bench()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/frappe/bench-repo/bench/cli.py”, line 388, in set_default_site
_set_default_site(site)
File “/home/frappe/bench-repo/bench/utils.py”, line 349, in set_default_site
cwd=os.path.join(bench, ‘sites’))
File “/home/frappe/bench-repo/bench/utils.py”, line 105, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: /home/frappe/frappe-bench/env/bin/frappe --use vas

but i have created a new site.
frappe@erpnext:~/frappe-bench$ ls
apps config config.json env logs node_modules Procfile sites
frappe@erpnext:~/frappe-bench$ cd sites/
frappe@erpnext:~/frappe-bench/sites$ ls
apps.txt beat.schedule currentsite.txt languages.txt
assets celerybeat.pid erpnext.vm vas

For databases;
frappe@erpnext:~/frappe-bench$ bench mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 242
Server version: 10.0.24-MariaDB-1~trusty mariadb.org binary distribution

Copyright © 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [d56cb677ea]> show databases;
±-------------------+
| Database |
±-------------------+
| d56cb677ea |
| information_schema |
±-------------------+
2 rows in set (0.00 sec)

MariaDB [d56cb677ea]>

In root:
frappe@erpnext:~/frappe-bench$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 243
Server version: 10.0.24-MariaDB-1~trusty mariadb.org binary distribution

Copyright © 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> show databases;
±-------------------+
| Database |
±-------------------+
| 8723baf2cf | — This is my DB of VAS
| d56cb677ea |
| information_schema |
| mysql |
| performance_schema |
±-------------------+
5 rows in set (0.00 sec)

MariaDB [(none)]>

How can i move this to my bench mysql.

It seems that you’re on an older version of ERPNext and Frappe and what’s happening is that it’s creating issues because of version and code differences.

Now, there are multiple ways we can handle this.

  1. The dirty way. You can create an image out of your DO Droplet for using in a Virtual Machine. Which is not very reliable : Refer to this. If you can make it work, it’ll work, but in the long term you might face issues.

  2. The clean way : If you have separate DocTypes that add to ERPNext, you should create a separate app for them. If you have any ERPNext related code changes, you should stash them (If you haven’t committed them). Basically, separate your code from ERPNext / Frappe code and then run bench update to get everything to the latest version and reapply your code changes. Once you do that do the backup and restore process again. (Make sure you start with a new VM as well)

  3. Another hacky thing you can try is replacing the frappe folder and it’s contents on your VM with the frappe folder on your VPS and then try to migrate on a new site. But I doubt that would help either.

Any Way to roll back my VM ERPNext to older version.

I am Using this version of erpnext in digital ocean.

Another thing you can try is : Get a fresh VM, run the production setup and try replacing the entire frappe-bench folder on your VM with the frappe-bench folder from your Droplet.

Unfortunately, here is no clean way to do this.

Yeah i have done this already Thanks