Backup plugin not working

After install the backup plugin, I change my config.ini to this:
[cli]
dump = D:/xampp/mysql/bin/mysqldump.exe -h localhost -u (removed) -p (removed) (removed)
and then when try to backup my site I’m getting this:
backup error

This happens using any of the three backup sections (DB, Files and Code) so it not seems to be related to the mysqldump config.

Thanks for any help.

Hi @RoWEN,

I’ve removed the credentials from your post – please be careful not to post usernames/passwords! The recommended [dump] command in the plugin documentation suggests:

dump = "/usr/bin/mysqldump -h {$hostname} -u {$username} -p{$password} {$databasename}"

…in which the actual username, password, etc. will be replaced automatically. It’s best to leave it that way.

On your system, you’ll need to change /usr/bin/mysqldump for the right path. Otherwise everything should probably stay the same. I’m not sure of the best conventions for PHP under Windows, but I see from this post that you might want to try D:\\xampp\\mysql\\bin\\mysqldump.exe or D:/xampp/mysql/bin/mysqldump.exe. You might also want to try quoting the whole string with double quotes (").

When trying this, I’d also recommend checking your PHP error log to see if it indicates anything.

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks!! Now the database backup works fine. But the other two options (Files and Code) keeps giving the same error. Any idea?

In the error log I see this
tar.exe: Failed to clean up compressor

Hi @RoWEN,

That suggests that there’s a problem with the tar tool you’ve got installed. The user on the other thread had a concrete suggestion for which tar tool to install, and mentioned a couple of other libraries that were necessary. I’ve asked them to add some detail.

Regards,
Alec Smecher
Public Knowledge Project Team

I’ve checked the other thread that you suggest, but my country (Cuba) has no access to sourceforge sites. However a friend from other country helps me and downloaded the same file and put it on a different source. I’ve already installed it, and pointed my config to the new tar installed:
tar = C:/GnuWin32/bin/bsdtar.exe
and now I get this error in the log:
bsdtar.exe: Failed to open ‘\.\TAPE0’: No such file or directory

Hi @RoWEN,

I think the issue is probably differences between the bsdtar tool you’re using and the GNU tar that OJS is intended to work with. Have you tried the gnuwin32 version of tar recommended on the other thread I linked?

Regards,
Alec Smecher
Public Knowledge Project Team

Yes, I managed to download and install the gnuwin32 version in the other thread you mentioned before, that is the one who throw me the Failed to open ‘.\TAPE0’: No such file or directory error in the log.

Hi @RoWEN,

Ah, I see – even though that’s a GNUWin32 package, it seemingly contains BSD tar, which is slightly incompatible with the GNU tar I’m used to. Let’s see if we can adjust the backup plugin’s code so it’ll work with either variant of tar.

Try making the following change in plugins/generic/backup/BackupPlugin.inc.php.

diff --git a/BackupPlugin.inc.php b/BackupPlugin.inc.php
index c394c5b..c1a35c3 100644
--- a/BackupPlugin.inc.php
+++ b/BackupPlugin.inc.php
@@ -107,7 +107,7 @@ class BackupPlugin extends GenericPlugin {
 				header('Content-Disposition: attachment; filename=files-' . strftime('%Y-%m-%d') . '.tar.gz');
 				header('Content-Type: application/gzip');
 				header('Content-Transfer-Encoding: binary');
-				passthru($tarTool . ' -c -z ' . escapeshellarg(Config::getVar('files', 'files_dir')), $returnValue);
+				passthru($tarTool . ' -c -f - -z ' . escapeshellarg(Config::getVar('files', 'files_dir')), $returnValue);
 				if ($returnValue !== 0) header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
 				exit();
 			case 'code':
@@ -116,7 +116,7 @@ class BackupPlugin extends GenericPlugin {
 				header('Content-Disposition: attachment; filename=code-' . strftime('%Y-%m-%d') . '.tar.gz');
 				header('Content-Type: application/gzip');
 				header('Content-Transfer-Encoding: binary');
-				passthru($tarTool . ' -c -z ' . escapeshellarg(dirname(dirname(dirname(dirname(__FILE__))))), $returnValue);
+				passthru($tarTool . ' -c -f - -z ' . escapeshellarg(dirname(dirname(dirname(dirname(__FILE__))))), $returnValue);
 				if ($returnValue !== 0) header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
 				exit();
 		}

Essentially, this means finding the two cases in that file where $tarTool is executed, and adding a new -f - parameter to the command line.

If you can test and confirm that it works, I’ll add it to the github repository for the next release.

Regards,
Alec Smecher
Public Knowledge Project Team

I made the changes to the BackupPlugin.inc.php and now it makes the backup. But when I open the code-2020-07-23.tar.gz (size is 45 Mb) with the Winrar software it shows me no files, same with other software like Peazip. Is this the correct behavior?

I try again with the new code you gave me and the previous tar.exe located in c:/windows/system32 AND NOW IT WORKS!!! It makes the backup file and when opened it shows me all the files.

Thanks for all the help.

Hi @RoWEN,

Excellent! I’ll make sure that change is included in future releases.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like