How to restore from backup when you have custom apps

Hi,

What’s the easiest way to restore from a backup when you have custom apps? Just to be clear, I’m referring to apps that were created from bench and not installed from an external repository

Thanks

1 Like

i faced the same issue and ended up by installing the same app with same name.

and bench migrate

if that app is not installed, server will not respond…

Hi @adnan

Thanks a lot for your response. What about DocTypes and Custom Methods that were created within the app? Do I need to create all those again also??

Kind regards,

No.

those things (DocTypes) are already in your backup. just need to create custom app and restore DB
Custom Methods if it’s in PY file, then yes you need to pull that repo with custom methods. if those were added in Custom Script, they’ll come along with DB Backup.

Thanks a lot @adnan

Yes, the Custom Methods are in the PY file so I guess we’ll need to manually copy those over to the new server since the app doesn’t have an external repo to pull from

Kind regards,

If you are looking for restoring database and you already have .sql backup files then
try this command inside frappe-bench:

mysql -u ‘your dbname’ -p’yourpassword’ “again your dbname” <path upto the file where your backup .sql file is stored.
before this command check your dbname and password in site_config.json file.

Hi @PrashantPatil

Thanks a lot for your response. My main concern was actually about the custom apps. I will follow the guidance given by @adnan and hopefully won’t run into any issues along the way :slight_smile:

Cheers!

Hi @wale,

The easiest way would be to push your app to a repository (Github, Bitbucket, Gitlab,…) and to pull it on your new server.
This way you can be certain that both are on the same version.

Another method would be to rsync your app on both servers, but it may lead to version mismatch with Frappe and ERPNext if not done carefully.

Good luck!

Hi @chdecultot

Thanks for your response. If I use this approach, at what point do I pull the app and install? As @adnan mentioned earlier, the database might not restore till I first install the app. If you could give some guidance on the order to follow, it would be much appreciated

I’m currently assuming the following:

  1. Install Frappe and create new site (on new server)
  2. Pull Custom App and install it on new site
  3. Restore database and files from previous site

I’m also assuming that I should not setup the new site (from UI) before restoring the database

Kind regards,

Hi @wale,

You’re assumption is correct:

  1. Install Frappe (and ERPNext if needed) on a new site
  2. Install your app using bench get-app command
  3. Restore your database and files.

You don’t need to make the setup, because the installed database will be anyway overridden by your backup.

You can follow exactly the instructions on the wiki:

1 Like

Many thanks @chdecultot

js files for the doctypes created under custom app/module will be included in the backup zip?

It wouldn’t. You have to manually pull and install custom application in desired destination.

How to do so? I am fairly new to erpnext and coding itself, it’d be nice you will explain the steps on how to or point to documentation or forum post.

Please give us more details what you want to do (like where is your custom app and where you want to install).

My erpnext instance is currently on a digital ocean droplet, ubuntu 16.04.6 LTS, its going into production in few days, I need to replicate the instance on my VM (Planning on using virtualbox on a windows 10 machine) so that i can work in it locally without disturbing the production system once its deployed, then retrofit the new changes overnight (which i currently plan on doing manually, will set up git later).

below is the details of the instance

ERPNext: v12.4.2 (version-12)

Frappe Framework: v12.2.1 (version-12)

Hide Help Menu: v0.0.1 (master)

MyApp: v0.0.1 (master)

any update on this?

try below:

  1. Create repository in Github or Bitbucket for your applications Hide Help Menu and MyApp
  2. Push your changes to above repo
  3. Download database backup from current ERPNext application
  4. Install ERPNext on VM
  5. Install Custom Applications on VM from github or bitbucket
    bench get-app custom_app <url_of_custom_app.git>
    bench install-app custom_app
  6. Restore database backup on new site:
    bench --force --site <site_name> restore <database.sql.gz>
2 Likes

i’ll try it out and update
thanks

it works,

thanks for taking the time to help out