nilsteampassnet/TeamPass — Issue #44: Restore Backup Fails
Author: spasticate
Created: 2012-02-15 22:33:21+00:00
State: open

TeamPass 2.1.2

Ubuntu 10.0.4 LTS, LAMP stack is from standard 10.0.4 repositories.

Attempting to restore a backup fails. Here's how to recreate this issue:

1. Make a manual backup. Set an encryption key and receive a file called: db-backup-1329342160.sql

2. Either
i) Wait a few weeks and make sure that you have used the
ii) Manually clear the file called db-backup-1329342160.sql out of the /files/ directory

Then try and restore this backup.

You will get logged out and have to log back in, but the database will not have been restored.

Instead if you look at the apache2 error log you will see:

[Wed Feb 15 22:05:20 2012] [error] [client 10.101.13.143] PHP Notice: Undefined variable: _SESSION in /var/www/teampass/includes/libraries/uploadify/uploadify.php on line 39
[Wed Feb 15 22:05:20 2012] [error] [client 10.101.13.143] PHP Notice: date_default_timezone_set(): Timezone ID '' is invalid in /var/www/teampass/includes/libraries/uploadify/uploadify.php on line 39
[Wed Feb 15 22:05:20 2012] [error] [client 10.101.13.143] PHP Notice: Undefined index: post_id in /var/www/teampass/includes/libraries/uploadify/uploadify.php on line 96
[Wed Feb 15 22:05:20 2012] [error] [client 10.101.13.143] PHP Notice: Undefined index: type in /var/www/teampass/includes/libraries/uploadify/uploadify.php on line 106
[Wed Feb 15 22:05:26 2012] [error] [client 10.101.13.143] PHP Warning: file(../files/db-backup-1329342160.sql): failed to open stream: No such file or directory in /var/www/teampass/sources/admin.queries.php on line 267, referer: http://10.101.13.63/index.php?page=manage_settings
[Wed Feb 15 22:05:26 2012] [error] [client 10.101.13.143] PHP Warning: unlink(../files/db-backup-1329342160.sql): No such file or directory in /var/www/teampass/sources/admin.queries.php on line 270, referer: http://10.101.13.63/index.php?page=manage_settings
[Wed Feb 15 22:05:26 2012] [error] [client 10.101.13.143] PHP Warning: Variable passed to each() is not an array or object in /var/www/teampass/sources/admin.queries.php on line 275, referer: http://10.101.13.63/index.php?page=manage_settings

Also, looking the /files/ directory reveals:

hwwadm@teampass:/var/www/teampass/files$ ls -alh
total 32K
drwxr-xr-x 2 www-data www-data 4.0K 2012-02-15 22:05 .
drwxr-xr-x 8 www-data www-data 4.0K 2012-01-16 09:34 ..
-rw-r--r-- 1 www-data www-data 18K 2012-02-15 22:05 28846fa3caa2e17ac0faa7924c8b5dd8
-rw-r--r-- 1 www-data www-data 1 2012-01-16 09:34 empty_file.txt

Examining the file 28846fa3caa2e17ac0faa7924c8b5dd8 confirms that it is the .sql file that we just uploaded; db-backup-1329342160.sql

If I rename the file 28846fa3caa2e17ac0faa7924c8b5dd8 to db-backup-1329342160.sql and then re try restoring the file db-backup-1329342160.sql the restore works, and it even deleted the file db-backup-1329342160.sql from the files directory when it's finished.

However if I go and look in /files/ again. i can see that there is another randomly named file left over from the 2nd attempted restore.

I think that this issue may have slipped through testing as if you don't ever use the Purge Old Files option, the original .sql backup files remain in the files directory and are sitting there with the correct name when you come to do a restoration.