Backup and Restore ERPNext Database - jigneshpshah/greycube_helpmanual GitHub Wiki
bench --site <sitename> backup --with-files
After downloading .sql backup file from the source server
I did the below steps on target server
-
Uploaded the sitename_backup.sql file to frappe-bench folder
-
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]
-
Installed ERPNext
-
Install all custom apps . Optional ( if there are any custom app installed on source db , install the app on the target site)
-
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]
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/
-
bench --site [sitename] migrate
-
bench site set admin password (optional)
bench --site [sitename] set-admin-password [password]
-
bench setup nginx
-
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)
- do bench force restore.
bench --site sitename --force restore sitename_backup.sql
-
bench --site sitename migrate
-
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.
select name, defvalue from tabDefaultValue where defkey = 'installed_apps'
update tabDefaultValue set defvalue = "[""frappe"", ""erpnext""]" where name="42b752cf94" and defkey = 'installed_apps';
tar -xvf 20221213_192207-site1_local-private-files.tar ./site1.local/private/files -C /home/frappe/frappe-bench/sites/erpnext.o2h.com/private/files