ERPNext – Backup & Restore // Frappe Bench

You must have installed in ERPNext and configured Full Guide of Manual Installation is here

Now as ERPNext is configured next step is to back up the site and database and restore in the event of IT disaster or whenever needed. This article is a full guide to ERPNext Backup and Restore

ERPNext Automatic Backup

ERPNext uses CronJob to automatically backup after every 6 hours, once the Production environment is set up. Depending upon your business criticality and the frequency of data that is being entered into the system you can decide the frequency and can edit the automated backup frequency or you can define your own in Crobjob section.

The automatic backup is a backup of your MySQL Database and site files. remember only the database is not important, the attachments are stored in the files directory, and ACL is also stored in the site folder therefore a backup of the entire site is important.

Backup Path of ERPNext

By default ERPNext backup is stored in the Private folder of your website. If you look at your site directory it has private and public folders. The private folder has the backup files.

Manual Backup & Schedule using CronJob

In case you want to backup manually or you want to do manual backup the command is simple. Just log in to shell, ensure that your working directory is frappe-bench and use the following command depending upon what you want to backup.

To backup all the sites use the following command;

bench backup
bench backup [Options]

For example if I want to backup the erpnext which is installed on erp.syncbricks.com including all files and database I will use the following command.

bench --site erp.syncbricks.com backup --with-files --compress

To remain up to date, you can use various backup methods, to backup file, to backup database, exclude files, include files change the path, and so on. The full list is available on frappe-guide here.

How to Restore ERPNext from Backup

In case of any incident when it is very important to restore the ERPNext from backup. It could be server migration, data issues, disasters,s or any other reason. First of you must have a Backup and Restore policy well defined in your organization, which is a subset of DRP. Disaster Recovery Plan will help you to define the time to recover restore and so on.

Once you have decided to restore the site and data, depending upon what you want to restore you can choose the command accordingly. The bench is the CLI command and then the second command is restored, then you will choose the option of what exactly you want to restore and then the MySQL path. The command format is below;

bench restore [OPTIONS] SQL_FILE_PATH

I will explain it through once example of erp.syncbricks.com where I restore the database from backup every night (automatically) because this for public to test and try. They keep adding and removing the data. I simply restore it every night and then other users get the fresh data.

As I don’t need to restore the files I only reset the data to my original configuration, so I will mainly restore the data.

Restore ERPNext Database

Follow the below steps as a guide;

  • Copy the database backup gz file to a new folder. I created amjid in frappe-bench
  • Unzip the zip database file the file in my case was renamed as dbbackup.sql.gz I used below command

cd /frappe-bench/amjid/
ls #this will show the files
gunzip dbbackup.gql.gz

This will extract the file and will remove the zip file. Now you are ready to restore the file.

remember to use the exact path including the file name

bench --site erp.syncbricks.com --force restore amjid/dbbackup.sql

Depending upon the size of database and files if you are restoring them too, it will take time and will give you the output as below.

site erp.syncbricks.com has been restored.

There might be many cases, depending upon the case you can choose the appropriate command. All the commands are available here in frappe documentation.

TODAY'S OFFERS

Gator Website Builder

Leave a Comment