Restore grav backup by copying httpdocs folder

I would like to move my grav website to a new server. In the process I found this thread.

But now I wonder the following: I have backed up the entire httpdocs folder - this is where all the important grav files/folders like user, system, etc. are located. I now want to upload this httpdocs folder to the new server and thus restore the “backup”. Which files must be edited manually so that this also works with a new domain? I can well imagine that the old domain under which grav ran before is stored in various files.

@matt777, Grav makes extensive use of caching relevant information (eg. config info) in the /cache folder. This folder might contain config information for the current domain. Moving this folder to a new domain might result in unexpected results.

This /cache folder can also become quite big which might cause a large Zip if copying the entire Grav folder.

As explained in the post you are referring to, creating a fresh install on your new domain and copying the /user folder from the old domain into the new location should do the job.

There is one explicit location where domain related information could be stored: /user/env. See Environment Configuration | Grav Documentation.

Using environment configuration, you can override the default configs in /user/config, by using domain specific config files, eg. user/env/olddomain/config/system.yaml.

Grav will automatically pick the configs inside the folder matching the current domain name, if available.

After moving your installation from olddomian to newdomain, you will have to rename folder olddomain into newdomain.

As explained in the post you are referring to, creating a fresh install on your new domain and copying the /user folder from the old domain into the new location should do the job.

So i did the following steps:

  • Backup the /user folder from my old server via ftp
  • Did a clean grav install on my new server (checked the website, everything is working)
  • Created first user on new website, just in case
  • rename /user to /user.old
  • again, i checked the website which is of course not working anymore
  • copied /user folder from old server via ftp to new server
  • see this error messages while visiting my new server: https://pastebin.com/QEvh2Ai4

Also, i recognize, there is this old “test.oldserver.com” folder in my directory hierarchy (test.oldserver.com is btw the correct domain pattern for my old server - obviously) and ALSO test.newserver.com, which is the correct domain pattern for my new server. Just in case this is important and i have to delete/modify something here:
grafik

I did not modify any files by myself, in fact i just copied my old /user folder into my grav installation (new server, new domain). Thats it.

@matt777,

A few remarks:

  • The TypeError is thrown by plugin GDPR Privacy Setup, which:
    • Has been marked abandoned since Oct 22, 2019
    • It might not be compatible with Grav 1.7.x
    • It might not be compatible with PHP 8
    • The error refers to line 230, which is empty… (I guess you have an even older version)
      But line 234 does contain $setup['whitelist'] = in_array($this->current_route, $pagesWhitelist);
  • PHP 8 has tighter typings, which will thrown an error on in_array if $haystack is not an array. In your case it complains it is null:
    in_array(mixed $needle, array $haystack, bool $strict = false): bool

So my guess is, your olddomain was running PHP 7 and your newdomain is running PHP 8

Suggested solution:

  • Add line whitelistPages: [] to all of your gdprprivacysetup.yaml files.

Also, i recognize, there is this old “test.oldserver.com” folder in my directory hierarchy (test.oldserver.com is btw the correct domain pattern for my old server - obviously) and ALSO test.newserver.com, which is the correct domain pattern for my new server. Just in case this is important and i have to delete/modify something here:

That where Grav 1.6 stored its environment configuration files. Grav 1.7 will store them inside /user/env/…

From the docs:

Up to Grav 1.6 environments were stored in user/ folder. Grav 1.7 moves environments to user/env/ to make environments easier to maintain. It is highly recommended that you move all the environments into this new location on your existing sites.

So both servers are running on the same php version (8.2) and also using the same grav version (latest). But indeed, adding whitelistPages: [] to gdprprivacysetup.yaml seems to solve this.

@matt777, Instead of fixing a broken and abandoned plugin, you might also consider to switch to a well maintained GDPR/Cookie plugin: GitHub - TecArt/grav-plugin-tecart-cookie-manager: Cookie Banner Plugin for Grav CMS with extended Admin Panel Manager and Cookie Settings options. Banner based on Cookie Consent JavaScript API by Osano.