How to restore a JR site with the Database backup file only?

pch
@pch
7 years ago
328 posts
Hello Support Team and Friends,

I am in a very bad situation. I was working on my site few months ago and was making the backup. Then moved to another server.

Today when trying to restore the site on the new server, I've just realized that I've backed up the database only, not the site files.

So I only have a SQL-format dump file of the database (with all the system settings, quota etc) made on October 03, 2016. It is hours and hours of work (system configurations and settings). By then, my system was up to date. (Probably with JR 5.3.xx, i don't remember anymore)

Today, JR 6.1 is the latest release. My question is: "How to restore the JR site with the Database backup file only of JR 5.3.xx, then upgrade to JR 6.1?"

On my computer, I've an old jamroom-core-5.2.41 zip archive. Can I:

1) fully install it on the server,
2) restore my database using the JR 5.3.xx SQL-format dump file (overwriting the old 5.2.41 database),
3) then upgrade to 6.1 using the built-in JR system upgrade tool?

If so, what about the modules that were already installed in system before the backup was made? Will they be back in the system and work or should I have to re-reinstall them manually one by one?

Can someone help me with a comprehensive method and process to restore my site?

By the way, It is a new project and the site wasn't live yet. So it is empty. No audio, no video. (I just don't want to loose my system configurations/settings)

Thanks in advance.

Regards.

updated by @pch: 12/27/17 03:01:02PM
michael
@michael
7 years ago
7,692 posts
There is no foolproof step by step guide for the situation you're in.

First thing I would try is adding the database to a 6.1 site, then running the repair.php script

Docs: "somethings wrong what do I do"
https://www.jamroom.net/the-jamroom-network/documentation/problems/114/somethings-wrong-what-do-i-do

It might work, might not.

Good thing is you have the backup and can try as many times as you like.
pch
@pch
7 years ago
328 posts
Hi Michael,

Thanks for your reply.

If I understand you well, I should try to install a clean JR 6.1 site, add the JR 5.3.xx database backup to that JR 6.1 site (by completely deleting the JR 6.1 database and restoring the JR 5.3.xx database backup via phpMyadmin), then run the repair.php script. Right ?

After this process, should I run the integrity check, then upgrade my database to JR 6.1? Or will the repair.php script upgrade my database without me loosing my system settings?

Is the JR 5.3 database structure same than the JR 6.1 structure?

The repair.php script you mentioned, should it be run by visiting myjrsite..com/repair.php , right?

What about the installed modules in my database backup, will their files be restored on the server by running the repair.php script? Or will the system tell me which modules are missing files and allow me to re-install them without loosing the module settings?

I am afraid, I don't want to loose my system, modules and templates settings and modifications contained in the database (SQL-format file). Please advise.

Many Thanks
michael
@michael
7 years ago
7,692 posts
pch:....If I understand you well, I should try to install a clean JR 6.1 site, add the JR 5.3.xx database backup to that JR 6.1 site (by completely deleting the JR 6.1 database and restoring the JR 5.3.xx database backup via phpMyadmin), then run the repair.php script. Right ?
....
yes. This is the SECOND thing that I would try.

The FIRST thing that I would try would be to import the database into phpmyadmin without deleting the existing stuff. There are going to be no-anything there already, and its already there, so I'd try it while the option to try is there. Since your next thing to try would be deleting it anyhow, you're not loosing anything.
michael
@michael
7 years ago
7,692 posts
No files are going to be magically created from an SQL database backup. only the database state will be returned.

What custom modules did you have?
pch
@pch
7 years ago
328 posts
Thanks for your reply.

I will try the first option.

No, I don't have a custom module. I was referring to the JR modules (e.g. Paid modules: Audio and video support, Youtube, Item Tags etc). I will have them installed and set in the database (from the backup used), but what about their files on the server? Will they be created after running the repair.php script? Or maybe I have to re-install them from the marketplace in order to have their files on the server? If so, will my paid module settings remain in the database if i have to re-install them?

I have started running the installation of JR 6.1. I have entered my database name, username and password. When I run the install, I get this error message:

Fatal error: Call to undefined function iconv() in /home/xxxxxxx/public_html/subfolder/modules/jrCore/lib/util.php on line 2598

Do you have any idea on what is going on and how to fix it?

Also, I uploaded JR to a sub-folder. When I enter the /subfolder/install.php in the address bar after my site url, it redirects me to mysite.com/install.php (root) with the following error message: "Not Found. The requested URL /install.php was not found on this server."

The install page only displays if I copy and paste the full install url in the address bar of the browser like this:

www.mysite.com/subfolder/install.php

Why? Then, the address bar will start showing a "Not secure" message as if the server/page was not secure. (lack of https://)

Is this a normal JR behavior on installation? Please explain.

Thanks.
brian
@brian
7 years ago
10,136 posts
pch:
Fatal error: Call to undefined function iconv() in /home/xxxxxxx/public_html/subfolder/modules/jrCore/lib/util.php on line 2598

Your PHP install is missing the iconv functions - these are needed by Jamroom. iconv functions are enabled by default, so they have been purposefully disabled on your server.

Make sure you are running at LEAST PHP 5.3 (PHP 7+ recommended).


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
pch
@pch
7 years ago
328 posts
@michael
@brian

Thanks for you help.

I've contacted my hosting provider and they have installed the iconv functions on my server. Thanks for the tip.

The cinstallation went smoothly.

Then I've moved to the next step to try to restore my site. I am trying to import my JR 5.3-based database backup into the JR 6.1.1 database using the import option of phpMyadmin but I am getting the following error :

Error
SQL Query:

INSERT INTO `jr_jrblog_item` (`_item_id`) VALUES
(1)

MySQL said:

#1062 - Duplicate entry '1' for key 'PRIMARY' 

What should I do?

Thanks
updated by @pch: 09/23/17 04:29:46PM
michael
@michael
7 years ago
7,692 posts
might need to delete that table, or TRUNCATE both the _blog_item tables.

The error means that you're trying to put some data into a location that there already is data and that table is setup to require all items to be unique.
pch
@pch
7 years ago
328 posts
Hi Michael,

Thanks a lot for your reply.

You were right. I truncated the _blog_item table and I was able to proceed with the import.

Then I have started having the similar error for many other tables. Below are tables that were giving me the duplicate error message. So I had to truncate them all in order to complete the import of my JR 5.3 database backup into the JR 6.1.1 database:

 
TRUNCATE `jr_jraction_item`;
TRUNCATE `jr_jraction_item_key`;
TRUNCATE `jr_jrblog_item`;
TRUNCATE `jr_jrblog_item_key`;
TRUNCATE `jr_jrcore_cache`;
TRUNCATE `jr_jrcore_count_ip`;
TRUNCATE `jr_jrcore_form`;
TRUNCATE `jr_jrcore_form_session`;
TRUNCATE `jr_jrcore_log`;
TRUNCATE `jr_jrcore_log_debug`;
TRUNCATE `jr_jrcore_menu`;
TRUNCATE `jr_jrcore_modal`;
TRUNCATE `jr_jrcore_module`;
TRUNCATE `jr_jrcore_performance`;
TRUNCATE `jr_jrcore_play_key`;
TRUNCATE `jr_jrcore_setting`;
TRUNCATE `jr_jrfeed_item`;
TRUNCATE `jr_jrfeed_item_key`;
TRUNCATE `jr_jrmarket_channel`;
TRUNCATE `jr_jrmarket_system`;
TRUNCATE `jr_jrprofile_quota`;
TRUNCATE `jr_jrprofile_quota_setting`;
TRUNCATE `jr_jrprofile_quota_value`;
TRUNCATE `jr_jruser_language`;


After truncating the tables listed above in JR 6.1.1, I was able to successfully complete the import. Then I run the repair.php script. Everything went smoothly. The database repair, the system cache reset and the Integrity Check were complete.

After doing everything, I visited my site, unfortunately it doesn't load. I get a HTTP ERROR 500 message. The site was loading fine after installing JR 6.1.1 and before importing the database backup. I don't know what is wrong and how to fix it. Please help.

Also I had to truncate the jr_jrcore_setting table because it was giving me many errors such as:

#1062 - Duplicate entry 'jrCore-system_name' for key 'PRIMARY'
#1062 - Duplicate entry 'jrCore-default_cache_seconds' for key 'PRIMARY'
#1062 - Duplicate entry 'jrCore-allowed_domains' for key 'PRIMARY'
etc etc.

I don't know whether it was a good idea. I have truncated so many table in JR 6.1.1 in order to complete the database backup import that I am afraid of start having database issues in the future. I am very concerned. Was it right to truncate the jr_jrcore_setting table ? Also is there any significant change between the database structure of JR 5.3 and JR 6.1.1?

Thanks for helping.
brian
@brian
7 years ago
10,136 posts
The problem here is that you had a FULL backup of your existing database (which contains the table definitions and table data), and were trying to import it to an database that had existing data in it - that's not going to work. You basically needed to delete all tables in the existing database and THEN import the SQL backup, which will re-create the tables and the data.

A "500" error usually means a PHP/Apache error - it's not database, so you need to look in data/logs/error_log and see what the error is.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
pch
@pch
7 years ago
328 posts
Hi Brian,

Thanks a lot for your quick reply.

Your suggestion is the second option that @michael gave me. I deleted all tables in the existing JR 6.1.1 database and imported the SQL backup (JR 5.3 database backup). Then run the repair.php script. Everything went fine. But unfortunately the 500 error message is still there.

As per your recommendation, I've looked in data/logs/error_log and here is what the error is.
PHP Fatal error:  require_once(): Failed opening required '/home/xxxxx/public_html/xxxxx/skins/jrxxxxx/include.php' (include_path='.:/opt/cpanel/ea-php56/root/usr/share/pear') in /home/xxxxx/public_html/xxxxx/modules/jrCore/include.php on line 479

Note: The site was loading just fine after installing JR 6.1.1 and before importing the database backup.

Also I still have an unanswered question. As I have imported a JR 5.3 database backup to run with JR 6.1.1 files. I wonder if there will not be incompatibly? Is there any significant change between the database structure of JR 5.3 and JR 6.1.1? Will the repair.php script upgrade my database to the JR 6.1.1 version? (Sorry for my ignorance but I'have to ask).

Thanks
brian
@brian
7 years ago
10,136 posts
The problem here is that your 5.3 backup likely has modules "active" in it that are NOT installed on your system. You need to look in the "jr_jrcore_module" table and make sure you have installed EACH module that is in that table - if you're missing even one then you'll get that error, because when JR "starts" it is going to run an include for each module that is active in that table (as defined by the module_active column being set to "1").

Jamroom 5.3 is fully upgradable to 6.1 no problem, so that should not be an issue. The repair.php will fix it all up, but you have to have ALL the modules installed on the file system that are defined in the jr_jrcore_module table.

I see you're not on our hosting - have you considered checking out our hosting? If interested let me know - we can get this working for you.

Let me know if that helps.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
pch
@pch
7 years ago
328 posts
Many thanks for your quick replies, Brian.

You are right. I am on a VPS with another popular host. They are providing us with a great service. No complain so far. Also we are running many other things on the server beside JR. I thank you for the invitation. We will take it into consideration whenever we will need to move to another hosting provider. Thanks.

About the modules, you came to the point I was concerned about since the beginning: "Having the modules installed and active in the database without having their corresponding files on the server".

So how can I install these missing module files in the system if I can't even log into the site to use the marketplace? Can I just download them from my JR.net Account (my licenses) and upload them to the server via ftp to /public_html/xxxxx/modules ? Will it work? (I think they are probably my paid modules).

Thanks
updated by @pch: 09/25/17 09:36:48AM
paul
@paul
7 years ago
4,325 posts
Yes - download the missing modules and FTP them to the /modules folder.
hth


--
Paul Asher - JR Developer and System Import Specialist
pch
@pch
7 years ago
328 posts
@brian
@paul

Thanks for your help. I have downloaded the missing modules from my JR.net account and uploaded them to my server. There were about 43 of them.

After running the repair.php script, the site was not loading and I was still getting a 500 error.

Then I've investigated the problem and discovered that I was missing my custom skin files which were made from the Elastic skin. This custom skin was active in the database. There was only the Elastic2 folder (files) in the skin folder on the server because JR 6.1.1 is packed with Elastic2 only as its default skin.

Trying to find a solution, as I had an old jamroom-core-5.2.41 zip archive on my computer, I've uploaded the Elastic skin file taken from that JR 5.2.41 to the skin folder of my JR 6.1.1 on the server and I duplicated the Elastic folder on the server giving that duplicated folder my custom skin name found in the database (jrMycustomname). Also I have uploaded few modified files (css, tpl, images etc) of my custom skin I had on my computer.

I don't know whether it is right way of fixing my problem (please correct me it is wrong) but then the site start working, No more 500 error message. I can log into the admin area. I have even reloaded all the modules one by one from the marketplace, just to make sure that there are installed correctly in the database.

Now I've few new issues:

1) My site layout is completed messed up. I can navigate without any error but the site design is just a mess. Yes I know, it's probably because of the custom skin made from JR 5.2.41 (Elastic skin) that I've manually uploaded to the server. If someone has an idea on how to fix it, please help.

2) I am unable to update the Elastic skin in the marketplace. Its status is red and it says: Installed: 1.2.12, Available: 1.4.3. But if I hit the update button, it updates and says:. "The skin was successfully updated", when nothing changes. It remains Installed: 1.2.12, Available: 1.4.3 with the red status. Any idea on how to fix it?

3) The integrity check from the admin side never complete. It keeps on running forever no matter if I select "verify modules" and "verify skins" only or if I select all the options (repair modules, repair tables, optimize tables etc). Please, how to fix it?

4) I am trying to activate Elastic2 to see if I can use it for my custom skin. First of all, I had to reload it from the marketplace because I've noticed that its files were in the server but the skin entries were not in the database since I've restored the database from a JR 5.3 backup and JR 5.3 was prior to the Elastic2 release.

After reloading the Elastic2 from the marketplace, its entries were back to the database in many tables.

Now the problem is whenever I try to set Elastic2 as active in my system, I get a 500 error message. Then the whole website stops working (loading) . Lucky for me I made a database backup before trying to set Elastic2 as active. It was easy for me to restore my system to its previous state using the database backup and get the site back online.

Here is what the error is from the error log.

 
PHP Fatal error:  Cannot redeclare jrElastic_skin_meta() (previously declared in /home/xxxxx/public_html/xxxxx/skins/jrElastic-release-1.4.3/include.php:54) in /home/xxxxx/public_html/xxxxx/skins/jrMycustomskin/include.php on line 63


How to fix it? Please help.

Thanks a lot.
SteveX
SteveX
@ultrajam
7 years ago
2,583 posts
It means you have a function named jrElastic_skin_meta in jrMycustomskin/include.php

You need to rename that function to jrMycustomskin_skin_meta


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
pch
@pch
7 years ago
328 posts
Hi ultrajam,

Thanks for your reply. But... should I have to hack the file/code? I am restoring my site. How come the site was just working fine before with the Elastic skin and even with the custom skin without any hack in the include.php file?

Isn't there any fix without hacking the include.php file?

Thanks
SteveX
SteveX
@ultrajam
7 years ago
2,583 posts
Because you can't have 2 functions with the same name, you have to rename (or delete) one or the other.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 09/28/17 11:05:01AM

Tags