How to restore a backup from one site name to another

I have a test version of ERPNext running in docker. People have been trying it out, and setting things up.

At some point we will want to bring up a live version, on a different domain name.

Is there any way we can copy all the things we setup on the test version into the live version?

I am imagining that bench backup of the test site, followed by bench restore of the backup into the new site won’t work (the database names are different, for a start, and the domain name won’t be the same).

Hi,

You can restore backup of test site to live site with below command. It will work flowlessly.

bench --site newsitename restore backupfiles path

Thanks,

Divyesh Mangroliya

2 Likes

Hi @nikkilocke,

Adding @mangroliya answer, Restore a site with files for apply the commands like:

bench --site {site} restore {path/to/database/file} --with-public-files {path/to/public/archive} --with-private-files {path/to/private/archive}

More details for, please check it post.

Thank You!

Thankyou everyone - so much else has gone wrong with my attempts at a docker install, I didn’t trust the restore engine to be able to restore to a different database. I will try it when I have everything running properly.

OK, I set up a brand new site under a different site name. Went through the initial setup to add the admin user.

Then I restored as instructed.

404 not found message when I visited the new site!

Then I tried a bench migrate, in case that was the problem.

Still 404 not found.

This is a 404 message generated by frappe, not by my host nginx proxy. I can see the various GET requests in the logs.

"GET / HTTP/1.0" 404 120697 "https://crm.test.example.uk/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
"GET /assets/frappe/images/ui-states/404.png HTTP/1.0" 200 96089 "https://crm.test.example.uk/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
"GET /website_script.js HTTP/1.0" 200 25 "https://crm.test.example.uk/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
"POST / HTTP/1.0" 200 13 "https://crm.test.example.uk/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
"GET /assets/erpnext/images/erpnext-favicon.svg HTTP/1.0" 200 455 "https://crm.test.example.uk/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"

General steps here

Here is what I just tried:

  1. docker-compose down
  2. Delete all the volumes:
docker volume rm test_logs test_redis-cache-data test_redis-queue-data test_redis-socketio-data  test_sites
  1. Run the containers
    docker-compose up -d
  2. Copy the database backup into the database container (uncompressed) as backup.sql
docker-compose exec db bash
mysql -p
drop database _346dbbd99919e6b7;
create database _346dbbd99919e6b7;
source /var/lib/mysql/backup.sql
Exit
  1. Copy the encryption_key from the original sites_config.json to the new one
  2. Connect to the server
    Result: Internal Server Error
    docker-compose logs backend reveals:
    “Access denied for user ‘_346dbbd99919e6b7’@‘172.16.21.4’ (using password: YES)”

You must have missed --no-mariadb-socket

Follow frappe_docker/docs/troubleshoot.md at main · frappe/frappe_docker · GitHub

Nope - from the docker-compose file, create-site container:
bench new-site ${FRAPPE_SITE_NAME_HEADER} --no-mariadb-socket --admin-password=${ADMIN_PASSWORD} --db-root-password=${MYSQL_ROOT_PASSWORD} --install-app erpnext --set-default;

This is followed by:

        bench --site ${FRAPPE_SITE_NAME_HEADER} install-app payments;
        bench --site ${FRAPPE_SITE_NAME_HEADER} install-app non_profit;
        bench --site ${FRAPPE_SITE_NAME_HEADER} migrate;

Do those also require --no-mariadb-socket?

Will starting up the queue containers also break it?

not required

try the troubleshoot link if it helps

I am doing the first database command in the troubleshooting link. It says:
UPDATE mysql.user SET Host = '%' where User = 'db_name'; FLUSH PRIVILEGES;
The result is:

ERROR 1356 (HY000): View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

Query OK, 0 rows affected (0.000 sec)

For reference:

select Host, User from user;
+-------------+-------------------+
| Host        | User              |
+-------------+-------------------+
| %           | _346dbbd99919e6b7 |
| %           | root              |
| 172.16.21.4 | _346dbbd99919e6b7 |
| localhost   | mariadb.sys       |
| localhost   | root              |
+-------------+-------------------+
5 rows in set (0.001 sec)

I have confirmed that "db_name": "_346dbbd99919e6b7" in site_config.json.

I can also log onto the database from the database container
mysql -p -u _346dbbd99919e6b7 _346dbbd99919e6b7 successfully.

The same command from backend fails.

Finally fixed it by running a valid Mariadb command:

grant all privileges on `<database name from sites/<domain name>/site_config.json`.* TO `<same database name (which is also the user name!)`@'%' IDENTIFIED BY '<password from the same file>';

Would it be an idea to update the troubleshooting page?