Backup and restore for creating local development environment

Hi all ,
I would like to know detailed procedures for backup and restore of erpnext site. I need to setup local dev environment from the server.By this i need to restore data ,custom doctypes ,clients and server scripts etc.Is there any easy way . i tried doing it manually but facing some error.Please help

@Anjan_Dev restoring the database is the easy part .

bench backup --with-files 

open site_name/private/backups . copy the folder to your new server then

bench restore database_file --with-public-files public_files_file --with-private-files private-files-file

Custom and server scripts written in the app are included to the database .
now to copy custom doctypes and custom fields you need to create and app (you should have done this at the first beginning ), to do so please refer to this link
note that you can not migrate the changes made inside frappe or erpnext application along with changes made by Editing Doctype , unless you do it manually .

@bahaou thanks for the reply .
i am not used to git so i just created and installed the app with name same as the one i wanted to backup.Copied all the doctype from the main to my local machine inside that app folder .i was able to see all the doctypes with fields .but when clicking to view the list view

it redirects to this page

@Anjan_Dev does it work when you search the doctype list with the search bar ?

i tried entering the url directly in search bar .that also redirects to the same page

@bahaou for better understanding i will leave a screen recording here


do you have all permissions ?
have you migrated the site ?
can you check the database to see if the table actually exists (bench console or bench mariadb)

@bahaou yea all permission is there.migrated .also the table is there in db

@Anjan_Dev try duplicating the doctype using a different name .

Made new doctype with different name.Edited the doctype json file and populated it with last doctype json data .all the fields were updated and still the problem was not sorted . @bahaou

@Anjan_Dev why are you editing json file? also could you open the console to see if there is any messages ?

@bahaou edited the json file to add fields of old doctype

console had this

14:54:30 web.1            | - - [12/Jul/2022 14:54:30] "GET /api/method/frappe.desk.form.load.getdoctype?doctype=crop%20slayer&with_parent=1&cached_timestamp=&_=1657617870164 HTTP/1.1" 404 -

@Anjan_Dev try not changing it ,

it works fine without changing . i am able to create doctypes .add fields .everything is fine @bahaou

@Anjan_Dev so you are probably messing with the json file , maybe adding some links that does not exists or has no permissions

@bahaou i didnt edit anything in my restored doctypes and also there were about 75 custom doctypes and some of them works fine

also i just checked all the linking fields.all the links exist and i am logged in as administrator@bahaou

@Anjan_Dev try exporting the custom fields using the app . the fixtures option allow you to move all custom fields you made to your app .