Code Error in Snapshot

We just downloaded and installed Snapshot on our client’s site. I tried to run a simple test backup to DropBox and received the following error.

ERROR: zip archive add failed [Array ( [type] => 2048 [message] => is_a(): Deprecated. Please use the instanceof operator [file] => /var/www/vhosts/fitchronaems.com/httpdocs/fitchronaems/wp-admin/includes/screen.php [line] => 376 ) ]

This sounds like it’s out of my hands. Is this something you can help resolve? Thanks!

  • Paul
    • The Green Incsub

    @chatmandesign, The Snapshot plugin is picking up the wrong error from PHP. The real error is something occurring when Snapshot attempts to add files to the zip archive it builds.

    Some things to try.

    1. Go to Snapshot > Settings. On this page is a section ‘Memory Limit’ What is the value there? If it it 64M or lower consider setting this to at least 100M. This extra memory is needed when building the zip archive only.

    2. Does Snapshot work properly when not including file? Meaning can you include database tables only?

    Reply back and I’ll see if I can get you further to a solution.

  • Paul
    • The Green Incsub

    @chatmandesign, The Snapshot plugin is picking up the wrong error from PHP. The real error is something occurring when Snapshot attempts to add files to the zip archive it builds.

    Some things to try.

    1. Go to Snapshot > Settings. On this page is a section ‘Memory Limit’ What is the value there? If it it 64M or lower consider setting this to at least 100M. This extra memory is needed when building the zip archive only.

    2. Does Snapshot work properly when not including file? Meaning can you include database tables only?

    Reply back and I’ll see if I can get you further to a solution.

  • chatmandesign
    • Flash Drive

    Hi Paul,

    The original install I posted about is something worse with that particular WordPress installation. However, I did try it on a more trustworthy WP install, and the plugin goes through the whole process fine, but it doesn’t appear to be actually creating the zip files in my DropBox. It says “blahblah.zip created successfully” but nothing is showing up in the DropBox, as far as I can see. Any ideas there?

    Matt

  • Paul
    • The Green Incsub

    @chatmandesign, The remote destination processing is handles and required the use of the WordPress WPCron engine. Basically when you run the manual Snapshot it will create the local zip file in the /wp-content/uploads/snapshot. Then at the very end of this processes Snapshot will call the WPCron ZPI to schedule the delivery of the file from your server to the remote destination. The reason Snapshot does not send direct is this may take some time depending on the size of your zip file. So to ensure completion without typing up your screen we ask WPCron to send the file.

    The WPCron processing is part of WordPress. This is supposed to function like a normal UNIX cron but is not as accurate. On other gotcha is WPCron needs to have traffic (page loads) on the front-end of your site.

  • chatmandesign
    • Flash Drive

    Hi Paul,

    Gotcha. And I just checked and the backups just synced with DropBox a minute ago. That makes sense.

    I’m not sure how much you can help with the original install now. If my WordPress install isn’t sitting right on the server (which is sad because I just set it up last week), then I have a different thing to deal with to make sure things are working.

    I appreciate the help!

    Matt

  • chatmandesign
    • Flash Drive

    UPDATE:

    I used the beta version of Snapshot you sent on the first install and got the following error:

    ERROR: zip archive add failed [-2] [Unable to open archive ‘/var/www/vhosts/fitchronaems.com/httpdocs/fitchronaems/wp-content/uploads/snapshots/_backup/1351526765/snapshot-backup.zip’ in wb mode] memory_limit: 32M: memory peak usage: 18.25M

    I have increased the memory limit setting but that didn’t seem to help. I’m guessing the plugin can’t speak for the server’s default setting?

    Matt

  • Paul
    • The Green Incsub

    @chatmandesign, Depending on how large your site is you may nee to double this. The Snapshot plugin is using the WordPress PcLZip package. So from Snapshot this is just an API call like everything else in WP to add files to a zip file. But we are finding out from some members that this API is a memory hog.

    Snapshot will read and consider the official PHP memory limit. But there are sometime where the admin doesn’t want Snapshot to consume all the memory available. That is why we have the Snapshot > Settings option.

  • Paul
    • The Green Incsub

    @chatmandesign, I just posted version 2.0.4 of Snapshot as an official release. Feel free to upgrade. When you get a chance I’d like to have you double check if you are still receiving the original errors. If not I’d like to get this thread closed out. If you have new issues please open a new thread on those issues.

  • chatmandesign
    • Flash Drive

    This error now shows up before doing anything (right after upgrading to 2.0.4):

    The session save path (/var/lib/php/session) is not set to a valid directory. Check your PHP (php.ini) settings or contact your hosting provider.

    Is that just a valid error now that you cleaned things up or is something wrong with the plugin now?

  • chatmandesign
    • Flash Drive

    I also tried to run a back up and got this again:

    ERROR: PcLZIP file:themes add failed -2: Unable to open archive ‘/var/www/vhosts/fitchronaems.com/httpdocs/fitchronaems/wp-content/uploads/snapshots/_backup/1351526765/snapshot-backup.zip’ in wb mode

    The plugin is reading 32M as the memory_limit (the process only maxed out at 18.25M). I used the wp-config.php file to set the memory_limit to 64M

    define(‘WP_MEMORY_LIMIT’, ’64M’:wink:;

    Maybe this doesn’t work the way I was hoping, but just thought I would mention it.

    Again, this works fine on another WP install that’s on the same server. I think there’s more going on here with this install than the plugin can account for.

    Matt

    [code -2]

    The plugin is reading 32M as the memory_limit (the process only maxed out at 18.25M). I used the wp-config.php file to set the memory_limit to 64M

    define(‘WP_MEMORY_LIMIT’, ’64M’:wink:;

    Maybe this doesn’t work the way I was hoping, but just thought I would mention it.

    Again, this works fine on another WP install that’s on the same server. I think there’s more going on here with this install than the plugin can account for.

    Matt

  • Paul
    • The Green Incsub

    @chatmandesign,

    First on the session issue. This is new. I had some other members show for whatever reason their servers session save path was invalid or not writable. So if you are seeing this then Snapshot thinks your is also either an invalid path of not writeable by the web server user. This is not always the save as your FTP user.

    As for the Memory the PcLZip library is somewhat is a memory hog. It will try and do compression in memory for small things. But when it gets to files which are large it starts to build up memory. So go to Snapshots > Setting On this page there are two things I need you to look at.

    On the Memory Limit section blank out the field. If this is blank then it will use whatever is defined in your wp-config.php

    Second, Look at the last box. Switch to using ZipArchive instead of PcLZip.

    Let me know.

  • chatmandesign
    • Flash Drive

    Hi Paul,

    I changed to ZipArchive and got this:

    ERROR: ZipArchive file:themes : add failed: N No error

    Second, because I have the memory_limit set via the wp-config.php file, it removes the ability to edit the memory limit box. All it shows is a note:

    “The Memory Limit setting can allow Snapshot to use more or limit the amount of memory used by Snapshot during the backup or restore processing. If left blank, snapshot will use the default amount of memory defined by WordPress.

    Memory limit defined by WordPress: 32M

    Warning: Unable to update the ‘memory_limit’ via the PHP function init_set. This means in order in to increased the allowed memory limit for Snapshot you will need to make the change directly in your php.ini file. Contact your host provider for details.”

    Just an update, I don’t work over the weekend, so after 4pm CST I won’t be back until Monday. Please don’t close this thread since I won’t be responding! :slight_smile: Thanks.

  • Paul
    • The Green Incsub

    @chatmandesign, No problem. I’ll leave the thread open.

    So to interpret what Snapshot is saying is this. There is a function used in PHP ini_set() and can be used to override settings like the ‘memory_limit’. But the PHP configuration can be such that it does not allow the website to override the settings. So if you are seeing this what is means is Snapshot took the current memory_limit and tries to set it to something higher using ini_set(). If an error is returned then it figures the PHP configuration will limit this setting.

    We can touch base on Monday. I’ll work with you all day to get this figured out. Have a good weekend.

  • chatmandesign
    • Flash Drive

    Hi Paul,

    1: define(‘WP_MEMORY_LIMIT’, ’64M’:wink:; is already there, so that’s good.

    2: Switching back to PcLZIP gave me this:

    ERROR: PcLZIP file:themes add failed -2: Unable to open archive ‘/var/www/vhosts/fitchronaems.com/httpdocs/fitchronaems/wp-content/uploads/snapshots/_backup/1351526765/snapshot-backup.zip’ in wb mode

    [code -2]

  • chatmandesign
    • Flash Drive

    Hi Paul,

    I’m sorry I never got notification that you responded to this last week! We are actually going to be launching that site next weekend. After that it will be accessible to you. Right now I can only access it via an entry in my local host file.

    I apologize again for the delay here. Let’s be in touch next week.

    Have a good Thanksgiving!

    Matt

  • Paul
    • The Green Incsub

    @chatmandesign (Matt),

    I think there are some permissions issues on your server. After digging into this some I decided to remove the snapshot folder at /wp-content/uploads/snapshots. The plugin when it loads will automatically create the folders. Or at least it is supposed to. After deleting the folder tree I loaded the main snapshot page page. At the top of this page is an admin message “ERROR: Cannot create snapshot Log folder. Check that the parent folder is writeable wp-content/uploads/snapshots/_backup” Sure enough when I checked via FTP the /wp-content/uploads/snapshots folder was present but the folders needed below that point were not.

    So I enabled WP_DEBUG in your wp-config.php and this was utput.

    Warning: fopen() [function.fopen]: SAFE MODE Restriction in effect. The script whose uid is 10029 is not allowed to access //wp-content/uploads/snapshots owned by uid 48 in /wp-content/plugins/snapshot/lib/snapshot_utilities.php on line 941

    Warning: fopen(/wp-content/uploads/snapshots/index.php) [function.fopen]: failed to open stream: No such file or directory in /wp-content/plugins/snapshot/lib/snapshot_utilities.php on line 941

    Warning: fopen() [function.fopen]: SAFE MODE Restriction in effect. The script whose uid is 10029 is not allowed to access /wp-content/uploads/snapshots owned by uid 48 in /wp-content/plugins/snapshot/lib/snapshot_utilities.php on line 948

    Warning: fopen(/wp-content/uploads/snapshots/.htaccess) [function.fopen]: failed to open stream: No such file or directory in /wp-content/plugins/snapshot/lib/snapshot_utilities.php on line 948

    See the note on the PHP documentation about SAFE MODE http://php.net/manual/en/ini.sect.safe-mode.php

    Basically, best I can tell is your folders are using two different user ids. Your wp-content/uploads folder and all files there are owned by user ‘apache’ group ‘apache’. But I also noticed that some files created are owner ‘fitchronaems’ and group ‘psacln’ With SAFE MODE enabled even with the folders fully writeable (0777) once user cannot write to a folder owner by another user.

    So to prove this out I again deleted the folder tree /wp-content/uploads/snapshots and this time created the needed folder and sub-folders via FTP. At this point I was able to run a full snapshot backup. But there is one catch that prevents this solution. As part of the backup snapshot creates a working folder under snapshots/_backups/ the name of this working folder is the snapshot item ID (1353970025). I had to also manually create this sub-folder.

    Again, I’m not sure on the solution. Still digging.

  • Paul
    • The Green Incsub

    Ok More on this issue. I’ve not had to dog into SAFE MODE issues in a while. Basically the rule is the owner/group of the PHP script running must be compatible with the directory/file group/owner it is trying to preform an operation on.

    So the PHP script /wp-content/plugins/snapshot/snapshot.php has owner ‘fitchronaems’ and group ‘psacln’ which is the FTP account authority.

    The webserver user/group is ‘apache’ This means when you load the snapshot page and try to creates a file like a backup the files/folders will inherit the webserver owner/group values.

    And there lies the problem. I even just tried to remove the snapshot plugin and re-add it within wp-admin. But since I have to provide the FTP credentials to install the new plugin it will inherit the FTP owner/group.

    Ug no wonder PHP is dropping this in 5.3 Any chance you can upgrade your PHP version to 5.3.x

  • Paul
    • The Green Incsub

    @chatmandesign, Any chance to just turn off safe mode in the php.ini??

    IF not:

    Since the files from snapshot are created via the web user (apache) not the FTP user this means the plugin folder and files /wp-content/plugin/snapshot/ which are currently

    ‘fitchronaems’ need to be all changed to user ‘apache’ group ‘apache’ This will then match the files created by snapshot which are written to /wp-content/uploads/snapshots

    But this creates another issue. Plugin upgrades. So would probably be better to go up a level in the plugin directory tree and set /wp-content/plugins and all plugins files and folders to be the same ‘apache’ user and group. This way plugin upgrades will no inherit the FTP user.

    This also means you shouldn’t FTP plugins into the site as they will inherit the wrong owner/group

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.