Skip to content

Instantly share code, notes, and snippets.

@giovanni-d
Last active April 21, 2024 19:16
Show Gist options
  • Star 57 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save giovanni-d/f9a05638e0b31467762b71585e8c3bfa to your computer and use it in GitHub Desktop.
Save giovanni-d/f9a05638e0b31467762b71585e8c3bfa to your computer and use it in GitHub Desktop.
All-in-One WP Migration - Restore From Server (without PRO version) - Restore

All-in-One WP Migration Restore From Server (without pro version)

If you don't want to pay for the PRO version of this plugin, and you want to use the "Restore from Server" functionally that was present in the version 6.77, follow the instructions below:

  1. Open the js file: wp-content/plugins/all-in-one-wp-migration/lib/view/assets/javascript/backups.min.js
  2. On line 1208, replace the code below:
$('.ai1wm-backup-restore').click(function (e) {
	e.preventDefault();

	if (!!Ai1wm.MultisiteExtensionRestore) {
		var restore = new Ai1wm.MultisiteExtensionRestore($(this).data('archive'));
	} else if (!!Ai1wm.UnlimitedExtensionRestore) {
		var restore = new Ai1wm.UnlimitedExtensionRestore($(this).data('archive'));
	} else if (!!Ai1wm.FreeExtensionRestore) {
		var restore = new Ai1wm.FreeExtensionRestore($(this).data('archive'));
	} else {
		var restore = new Ai1wm.Restore($(this).data('archive'));
	}
});

with the following code:

$('#ai1wm-backups-list').on('click', '.ai1wm-backup-restore', function (e) {
	e.preventDefault();
	var modelimport = new Import();
	
	var storage = Ai1wm.Util.random(12);
	var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({ name: 'storage', value: storage }).concat({ name: 'archive', value: $(this).data('archive') });

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

	// Start import
	modelimport.start();
});
  1. Go to your All-in-One WP Migration > Backups page and you should be able to use the Restore button now.
@exbm
Copy link

exbm commented Oct 10, 2021

I got the code to work when trying to restore a backup: here is my version:

$('#ai1wm-backups-list').on('click', '.ai1wm-backup-restore', function (e) {
	e.preventDefault();

	var modelimport = new Import();

	var storage = Ai1wm.Util.random(12);
	var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({ name: 'storage', value: storage }).concat({ name: 'archive', value: $(this).data('archive') });

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

	// Start import
	modelimport.start();
`});

@giovanni-d
Copy link
Author

Thanks @exbm! I've gone ahead and updated the code in this gist as well.

@XTard
Copy link

XTard commented May 3, 2022

Still works, thanks. :)

@arbabcodes
Copy link

Works like a charm.

@Linivivi
Copy link

Neither of 2 worked for me...

@sutidor
Copy link

sutidor commented Jul 20, 2022

Since it is a JS file, which might be cached, make sure you reload the site: In Chrome hard reload, in Firefox disable cache from the developer console and reload the site while the console is still open.

@AleCo3lho
Copy link

Still working, saved my day love you guys.

@levelingup
Copy link

levelingup commented Sep 13, 2022

Since it is a JS file, which might be cached, make sure you reload the site: In Chrome hard reload, in Firefox disable cache from the developer console and reload the site while the console is still open.

Thanks @sutidor
This is what fixed mine!

@xxxdepy
Copy link

xxxdepy commented Oct 12, 2022

** UPDATE OCTOER 2022 **

If you want to quickly start the Restore process and don't care about having that option always enabled, then just fire up the Developer console on the browser and run this while on the Restore page

        var modelimport = new Ai1wm.Import();
	
	var storage = Ai1wm.Util.random(12);
	var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({ name: 'storage', value: storage }).concat({ name: 'archive', value: 'REPLACE-WITH-ARCHIVE-NAME'});

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

	// Start import
	modelimport.start();

REPLACE-WITH-ARCHIVE-NAME - you will find this in the data-archive attribute of the restore button next to the file. It's just a string.

@nsilvera
Copy link

Tanks! @xxxdepy !!

@devrittick
Copy link

Thank you Very much @xxxdepy @giovanni-d

@Alaaeldin1993
Copy link

in my case i found the code in 1725 not , 1208, than you

@shejaemeric
Copy link

Worked like a charm thank you

@Pikamander2
Copy link

Looks like @xxxdepy's solution still works in February 2023.

@alvindex
Copy link

Not working on 7.7.1 version....

@Pikamander2
Copy link

@alvindex - xxxdepy's solution worked for me on 7.7.1 yesterday. Were you using that or the original one by giovanni-d?

@alvindex
Copy link

alvindex commented Mar 5, 2023

@alvindex - xxxdepy's solution worked for me on 7.7.1 yesterday. Were you using that or the original one by giovanni-d?

My mistake...sorry
I made the modification and uploaded the modified file by FTP.
Important condition, empty the "ai1wm-backups" folder EXCEPT the backup file before activating the plugin.
to finish, empty the browser cache AND reconnect to the site.

  • block plugin update.
    Now is working !!!
    thank you @Pikamander2

@JonGrvla
Copy link

JonGrvla commented Mar 8, 2023

@alvindex - xxxdepy's solution worked for me on 7.7.1 yesterday. Were you using that or the original one by giovanni-d?

My mistake...sorry I made the modification and uploaded the modified file by FTP. Important condition, empty the "ai1wm-backups" folder EXCEPT the backup file before activating the plugin. to finish, empty the browser cache AND reconnect to the site.

  • block plugin update.
    Now is working !!!
    thank you @Pikamander2

Can't get this to work for me, sadly. Working on All-in-One WP Migration 7.72

Tried @alvindex 's solution, although there are some steps I don't understand:

What do you mean by "modified file"? In which way does it have to be modified?
What do you mean by "reconnect to the site"?
This is what I tried:

Install All-in-One WP Migration (leave deactivated)
Upload backup file to "ai1wm-backups" folder
Empty folder except for backup file (some files always reappear, e.g. robots.txt, index.html, and a few more)
Activate plugin
Empty browser cache
Not sure what is meant by "reconnect to the site", I tried closing the tab and re-opening it
Open "Import" screen of AIO WP Migration
Paste @xxxdepy code snippet into console whilst replacing "REPLACE-WITH-ARCHIVE-NAME" with the name of the backup file
Hit Enter
A popup "Preparing for import" opens and I see a loading animation - after a few minutes, the popup closes and nothing happened.

What did I miss?

Thanks in advance!

@alvindex
Copy link

alvindex commented Mar 8, 2023

@JonGrvla
sorry, English is not my first @language...
ii hope to be more clear now ;)
1 > Instal " all-in-one-wp-migration 7.72 "
2 > dont activate !
3 > Open by FTP " all-in-one-wp-migration\lib\view\assets\javascript\ "
4 > donwload " backups.min.js "
5 > Open: " backups.min.js "

use this tools:
Notepadd ++
Winmerge

go to...
line 2688 to 2733

/////////// ORIGINAL 7.72 ///////////////

 $('#ai1wm-backups-list').on('click', '.ai1wm-backup-restore', function (e) {
    e.preventDefault();
    /* eslint-disable no-unused-vars */

    if (Ai1wm.MultisiteExtensionRestore) {
      var restore = new Ai1wm.MultisiteExtensionRestore($(this).data('archive'), $(this).data('size'));
    } else if (Ai1wm.UnlimitedExtensionRestore) {
      var _restore = new Ai1wm.UnlimitedExtensionRestore($(this).data('archive'), $(this).data('size'));
    } else if (Ai1wm.FreeExtensionRestore) {
      var _restore2 = new Ai1wm.FreeExtensionRestore($(this).data('archive'), $(this).data('size'));
    } else {
      var _restore3 = new Ai1wm.Restore($(this).data('archive'), $(this).data('size'));
    }
    /* eslint-enable no-unused-vars */

  }); // List file content

///////////////////////////////////////////

change by:

$('#ai1wm-backups-list').on('click', '.ai1wm-backup-restore', function (e) {
	e.preventDefault();
	var modelimport = new Import();
	
	var storage = Ai1wm.Util.random(12);
	var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({ name: 'storage', value: storage }).concat({ name: 'archive', value: $(this).data('archive') });

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

	// Start import
	modelimport.start();
}); // List file content

//////////////// END ///////////////////

UPLAOD TO > " all-in-one-wp-migration\lib\view\assets\javascript\ "

//////////////////////////////////////////////////////

IMPORTANT !
go to " wp-content/ai1wm-backups "
look inside and remove:
in case of previous version

.htaccess
index.html
index.php
robots.txt
web.config

this files will be recreated after activation.

NOW >>> ACTIVATE >>> " all-in-one-wp-migration 7.72 "

@jawad-multani
Copy link

@JonGrvla sorry, English is not my first @language... ii hope to be more clear now ;) 1 > Instal " all-in-one-wp-migration 7.72 " 2 > dont activate ! 3 > Open by FTP " all-in-one-wp-migration\lib\view\assets\javascript\ " 4 > donwload " backups.min.js " 5 > Open: " backups.min.js "

use this tools: Notepadd ++ Winmerge

go to... line 2688 to 2733

/////////// ORIGINAL 7.72 ///////////////

 $('#ai1wm-backups-list').on('click', '.ai1wm-backup-restore', function (e) {
    e.preventDefault();
    /* eslint-disable no-unused-vars */

    if (Ai1wm.MultisiteExtensionRestore) {
      var restore = new Ai1wm.MultisiteExtensionRestore($(this).data('archive'), $(this).data('size'));
    } else if (Ai1wm.UnlimitedExtensionRestore) {
      var _restore = new Ai1wm.UnlimitedExtensionRestore($(this).data('archive'), $(this).data('size'));
    } else if (Ai1wm.FreeExtensionRestore) {
      var _restore2 = new Ai1wm.FreeExtensionRestore($(this).data('archive'), $(this).data('size'));
    } else {
      var _restore3 = new Ai1wm.Restore($(this).data('archive'), $(this).data('size'));
    }
    /* eslint-enable no-unused-vars */

  }); // List file content

///////////////////////////////////////////

change by:

$('#ai1wm-backups-list').on('click', '.ai1wm-backup-restore', function (e) {
	e.preventDefault();
	var modelimport = new Import();
	
	var storage = Ai1wm.Util.random(12);
	var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({ name: 'storage', value: storage }).concat({ name: 'archive', value: $(this).data('archive') });

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

	// Start import
	modelimport.start();
}); // List file content

//////////////// END ///////////////////

UPLAOD TO > " all-in-one-wp-migration\lib\view\assets\javascript\ "

//////////////////////////////////////////////////////

IMPORTANT ! go to " wp-content/ai1wm-backups " look inside and remove: in case of previous version

.htaccess index.html index.php robots.txt web.config

this files will be recreated after activation.

NOW >>> ACTIVATE >>> " all-in-one-wp-migration 7.72 "

This is working for 7.74 as well

@Pikamander2
Copy link

There's no need to edit the plugin files. xxxderpy's simple JavaScript console solution still works in the latest version.

var filename = 'FILENAME.wpress';
var importer = new Ai1wm.Import();
var storage = Ai1wm.Util.random(12);
var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({name: 'storage', value: storage}).concat({name: 'archive', value: filename});
importer.setParams(options);
importer.start();

@miabyte
Copy link

miabyte commented May 29, 2023

** UPDATE OCTOER 2022 **

If you want to quickly start the Restore process and don't care about having that option always enabled, then just fire up the Developer console on the browser and run this while on the Restore page

        var modelimport = new Ai1wm.Import();
	
	var storage = Ai1wm.Util.random(12);
	var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({ name: 'storage', value: storage }).concat({ name: 'archive', value: 'REPLACE-WITH-ARCHIVE-NAME'});

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

	// Start import
	modelimport.start();

REPLACE-WITH-ARCHIVE-NAME - you will find this in the data-archive attribute of the restore button next to the file. It's just a string.

29.05.2023 Still works with latest version. 👍

@medkhalilbk
Copy link

Thanks for the solutions 👍

@Dominar400MX
Copy link

$('#ai1wm-backups-list').on('click', '.ai1wm-backup-restore', function (e) {
e.preventDefault();
var modelimport = new Import();

var storage = Ai1wm.Util.random(12);
var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({ name: 'storage', value: storage }).concat({ name: 'archive', value: $(this).data('archive') });

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

// Start import
modelimport.start();
}); // List file content

This works :) just make sure to clear cache or login from incognito after the change

@hkilimci
Copy link

perfect!

@viktorasbuivydas
Copy link

@xxxdepy your code still works. Also guys, don't forget to put full file name with .wpress at the end :)

@Kyolue008
Copy link

OMG,thanks and love you guys so much. The following still works in January 26th, 2024. (YES 2024!!)
"@JonGrvla sorry, English is not my first https://github.com/language... ii hope to be more clear now ;) 1 > Instal " all-in-one-wp-migration 7.72 " 2 > dont activate ! 3 > Open by FTP " all-in-one-wp-migration\lib\view\assets\javascript\ " 4 > donwload " backups.min.js " 5 > Open: " backups.min.js "

use this tools: Notepadd ++ Winmerge

go to... line 2688 to 2733

/////////// ORIGINAL 7.72 ///////////////

$('#ai1wm-backups-list').on('click', '.ai1wm-backup-restore', function (e) {
e.preventDefault();
/* eslint-disable no-unused-vars */

if (Ai1wm.MultisiteExtensionRestore) {
  var restore = new Ai1wm.MultisiteExtensionRestore($(this).data('archive'), $(this).data('size'));
} else if (Ai1wm.UnlimitedExtensionRestore) {
  var _restore = new Ai1wm.UnlimitedExtensionRestore($(this).data('archive'), $(this).data('size'));
} else if (Ai1wm.FreeExtensionRestore) {
  var _restore2 = new Ai1wm.FreeExtensionRestore($(this).data('archive'), $(this).data('size'));
} else {
  var _restore3 = new Ai1wm.Restore($(this).data('archive'), $(this).data('size'));
}
/* eslint-enable no-unused-vars */

}); // List file content
///////////////////////////////////////////

change by:

$('#ai1wm-backups-list').on('click', '.ai1wm-backup-restore', function (e) {
e.preventDefault();
var modelimport = new Import();

var storage = Ai1wm.Util.random(12);
var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({ name: 'storage', value: storage }).concat({ name: 'archive', value: $(this).data('archive') });

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

// Start import
modelimport.start();

}); // List file content

//////////////// END ///////////////////

UPLAOD TO > " all-in-one-wp-migration\lib\view\assets\javascript\ "
//////////////////////////////////////////////////////

IMPORTANT ! go to " wp-content/ai1wm-backups " look inside and remove: in case of previous version

.htaccess index.html index.php robots.txt web.config

this files will be recreated after activation.

NOW >>> ACTIVATE >>> " all-in-one-wp-migration 7.72 "

This is working for 7.74 as well"

@Pikamander2
Copy link

To reiterate, there's no need to edit any plugin files. A simple console command on the Backups page is all you need.

var filename = 'FILENAME.wpress';
var importer = new Ai1wm.Import();
var storage = Ai1wm.Util.random(12);
var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({name: 'storage', value: storage}).concat({name: 'archive', value: filename});
importer.setParams(options);
importer.start();

@Muhammad-9500
Copy link

Muhammad-9500 commented Feb 6, 2024

var filename = 'FILENAME.wpress';
var importer = new Ai1wm.Import();
var storage = Ai1wm.Util.random(12);
var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({name: 'storage', value: storage}).concat({name: 'archive', value: filename});
importer.setParams(options);
importer.start();

This restored my site successfully, but the site is not reachable again. While it was in the first place. So I reset the website and restored again, but it still doesn't work. I cleared cache and cookies in the browser but to no avail. The error says :
"The page isn’t redirecting properly
An error occurred during a connection to hitechpharma.net.
This problem can sometimes be caused by disabling or refusing to accept cookies.". Help!!!

@vetka-nn
Copy link

OMG,thanks and love you guys so much. The following still works in January 26th, 2024. (YES 2024!!)

Thanks a lot! It still works at version 7.8.1, April 2024!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment