Backup and Restore ERPNext Database - jigneshpshah/greycube_helpmanual GitHub Wiki

To get backup from the source

bench --site <sitename> backup --with-files

After downloading .sql backup file from the source server

I did the below steps on target server

  1. Uploaded the sitename_backup.sql file to frappe-bench folder

  2. Created a new site ( with different name from the source, as i want to change the sitename/ URL )

bench new-site [sitename] --db-name [dbname]

  1. Installed ERPNext

  2. Install all custom apps . Optional ( if there are any custom app installed on source db , install the app on the target site)

  3. Restore db through the below command

bench --site [sitename] --force restore [path to database backup file] --with-private-files [relative-path-to-private-files-backup-file] --with-public-files [relative-path-to-public-files-backup-file]

Option 2 - manually

OR

mysql -u root -p --database=dbname < sitename_backup.sql

To extract public / private files

tar xvf private_files.tar -C sites/

tar xvf publicfiles.tar -C sites/

move the files if the sitenames are different

public files

mv -v /home/frappe/frappe-bench/sites/{source_sitename}/public/files/* /home/frappe/frappe-bench/sites/{target_site_name e.g.site1.local}/public/files/

private files

mv -v /home/frappe/frappe-bench/sites/{source_sitename}/private/files/* /home/frappe/frappe-bench/sites/{target_site_name e.g.site1.local}/private/files/

  1. bench --site [sitename] migrate

  2. bench site set admin password (optional)

bench --site [sitename] set-admin-password [password]

  1. bench setup nginx

  2. sudo service nginx reload

============================================================ 4. run setup wizard logout

4.1 Check if the global default for the instance are set correctly.

4.2 Install custom app . Optional ( if there are any custom app installed on source db , install the app on the target site)

  1. do bench force restore.

bench --site sitename --force restore sitename_backup.sql

  1. bench --site sitename migrate

  2. bench site set admin password (optional)

bench --site [sitename] set-admin-password [password]

Assumption : Both frappe and erpnext versions should be exactly same in both servers. OR target server should be ahead of source server.

Refer Link : https://discuss.erpnext.com/t/restore-from-backup-skip-setup-wizard-keep-customization-verify-db-records/43588/3?u=jignesh_shah

https://discuss.erpnext.com/t/how-to-restore-a-database-from-a-backup-bench-backup-bench-restore/41783/2

To Remove installed-apps


select name, defvalue from tabDefaultValue where defkey = 'installed_apps'

update tabDefaultValue set defvalue = "[""frappe"", ""erpnext""]" where name="42b752cf94" and  defkey = 'installed_apps';

to directly extract files with different site name

tar -xvf 20221213_192207-site1_local-private-files.tar ./site1.local/private/files -C /home/frappe/frappe-bench/sites/erpnext.o2h.com/private/files

⚠️ **GitHub.com Fallback** ⚠️