[URGENT] Restore print formats

On the print format list, I selected two custom formats and opted to delete, but the whole list disappeared. There are no longer any print formats in my system. I need to restore the default formats at the very least. Please help.

Please check in Deleted Document List. Restore from there.

Also for greater clarity, please set the filter for DocType to Print Format to get only the Print Formats.

Deleted Document List only lists the two formats I intended to delete.

I averted crisis for the moment by going back in browser history to select customize on the print previews of the documents we print and saving them again. But to reiterate: the old formats are gone, they are not listed on the Deleted Document List.

Do you have older backup say just before deleting those formats ?

Also do you have a testing or developer instance ?

I do not. I’m using the production branch, I was just clearing formats created for testing. I absolutely did not expect to encounter such a bug and deemed it unnecessary to take a backup before the action.

No actually ERPNext has automatic backups so if you check in your sites folder, there will be another named private and inside you will find backups.

1 Like

ERPNext.com or self hosted?

all will have it.

i.e. after you setup bench backup in crontab.

Well, how do I specifically restore formats from those backups? It’s a self-host using the installation script. I don’t want to rollback the entire database, just whatever table/DocType for formats.

Okay what I am going to tell you is a hack.

There is a Database way which I originally planned to suggest, but it is way too dangerous so we’ll skip that and take this one instead.

You’ll need to setup a new site with erpnext on it. Then, use command

bench use your-new-site-name (This makes that site as default so you access that site’s database)

Then Login as administrator after bench start. Setup a test company.

Now Go to Print Format. And select Import from Menu. Now follow this GIF to export all the default print formats.

ezgif-5-901335149cfd

You get a Excel or CSV file.

Now, you ought to import this into your current database.

Before that, to make sure import works. Open Print Format via Edit Doctype and check Allow Import (via Data Import Tool) to yes and save.

Again in frappe-bench folder, use bench use your-production-site-name. Simlarly, login as Administrator.

Go For Data Import. Then Attach that Excel file and import it. Your files should come back.


Notice:

You changed the import settings for Print Format via Edit Doctype - and you will be able to see this change in your repo. First step to revert that change i.e. uncheck it. However, there will still be a change of the timestamp when that change was done. Then if it is in frappe, navigate to your frappe and erpnext repo and discard those changes. It is easier when done via an Editor like Visual Studio Code.

This is important because this may cause problems in case of bench update

5 Likes