It is in the nature of an Apache or Nginx server that each PHP process should only run for a short time. There is also the memory_limit, which often only allows a few hundred MB per process. The situation is different with processes that are initiated via the CLI. Unfortunately there is still no working import and export of typo3/cms-impexp.
A long time ago we built a TYPO3 package that can help you with TYPO3 migrations. In addition to many useful tools for migrations, in2code/migration also offers CLI functions to export large page trees with all data records and files as JSON and then import them again.
First, however, the package must be installed via Composer:
composer require --dev in2code/migration
Then you can use a configuration file in a separate extension to make all the necessary settings. Further details can be found in the migration or in the import / export documentation.
From now on, very large side trees or entire TYPO3 instances can also be merged.
# Export page with pid123 and all its subpages into a json file
./vendor/bin/typo3cms migration:export 123 > /home/user/export.json
Und after that an example import:
# Import page branch with subpages and files into page with uid 123
./vendor/bin/typo3cms migration:import /home/user/export.json 123
Tip: From a size of the JSON file of 6-10GB (for page trees with many thousand pages and a similar number of files such as PDF, video or image files), you can think about integrating files from the fileadmin directory (or other storages ) via configuration.