Uploading / Restoring Huge WordPress Sites with All-in One WP Migration

 Migration of WordPress site's are easy, thanks to plugins like All-in One WP Migration however if your site happens to be very large then migrating it can be difficult or next to impossible. 

For starters the plugin All-in One WP Migration limits the upload file size of a backup, but that can be removed by purchasing their Unlimited Extension, I would recommend you do that, but if you still want to be able to upload large backup files check below. 


There are multiple issues with large files that might popup, first there's an upload limit on the server that you have to resolve, this is usually configured on your webhost, through php.ini where you set PHP configuration variables to a high enough number (I am not going to instruct how to do that here, I assume you have already done that.)

If you don't update the server upload limits you won't be able to upload the files. But there's a workaround that I often 

Using WP File Manager to directly upload to your server

Downloading large files, 5gb, 10gb or more, can be a time consuming and in many cases not even practical, say you got a slow connection or a metered one, and even if not that then maybe you just want to speed the process up. 

For that instead of download the file on your computer, then uploading it to the plugin's Import feature, directly upload the backup file in the plugin's upload directory. This is particularly useful as the free version of the extension don't even allow for large files. 

Follow these steps
  1. Install the file manager plugin on your WordPress site where you want to restore your backup
  2. Create a backup on your source site, when the backup is created instead of downloading the file, right click on the download button and copy the link
  3. Go to the file manager page on your target website then navigate to the folder wp-content > ai1wm-backups    (this assumes you have the backup plugin installed on the target site too)
  4. Right click on an empty area and click on "Upload files"
  5.  In the box that opens paste the link to your backup file.
The upload process starts automatically, and it all happens server-to-server, so you never have to download any files then upload it. 

Restoring the Backup file

Now if you go to All-in One WP migration backups page you will see your backup file in the list

The page is at this location
[yoursite.com]/wp-admin/admin.php?page=ai1wm_backups

However if you try restoring it, it won't proceed


You are asked to get the paid extension to use the "Restore" functionality. 

Let's by pass that using JavaScript

Good thing about WordPress is that plugin's are supposed to be open-sourced and they cannot provide partial code, even if it has features that you have to pay to use, the plugin still has the entirety of code, so there is always a way to use those feature. 

With a little trick we can use the Restore functionality, which is simply the following JavaScript snippet
var modelimport = new Ai1wm.Import();
	
var storage = Ai1wm.Util.random(12);
var archive_name = 'REPLACE-WITH-ARCHIVE-NAME';
var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({ name: 'storage', value: storage }).concat({ name: 'archive', value: archive_name});

// Set global params
modelimport.setParams(options);

// Start import
modelimport.start();
Copy this into a text editor, you will have to make some edits, a very small one. See the line `var archive_name = 'REPLACE-WITH-ARCHIVE-NAME';`  

On the backup page copy the name of the backup file you want to restore and put it in the specified field in that line 



So it becomes
var archive_name = 'example.com-20221215-205102-pit8or.wpress';
Once done, copy the entire snippet of code, on the All in One plugin backup page, open the Chrome DevTools, you can do that by Right clicking an empty area on the page > Inspect Element or CTRL+Shift+J


Go to the Console tab


Paste in the snippet of code and hit enter. As soon as you do that the restore process should start. 

That's basically it, If successful you will get to see the migrated site after the restore process finishes. 



A note to the readers: This workaround relies on the fact that the code of this backup plugin doesn't change to the extent where this snippet stops working, if the above snippets doesn't work for you let us know in the comments what error do you see, but eventually the above snippet might stop working, so do look for new snippets that can do the same thing on Google or request it in the comments and I might update this post if possible. 


And special thanks to this Github gist, I myself ended up on this snippet by giovanni-d to solve the issue, but it did not work, so I tweaked the snippet and it did so sharing the updated one with everyone of you who needs it. 

https://gist.github.com/giovanni-d/f9a05638e0b31467762b71585e8c3bfa


Thanks!