Permission denied /wp-admin/includes/class-pclzip.php on line 2203

Each time I try to run snapshot I get the following error:
Unknown: errno:2 fopen(pclzip-4fb55450e9841.tmp): failed to open stream: Permission denied /home/XXXX/public_html/ on line 2203

It always occurs at the third table, regardless of what that is. 1st two tables backup fine, at the onset of table three I get this error message and everything stops with a 0% completed of table three.

  • Paul

    ptoborek, Thanks for brining this to our attention. I don't know that I have an answer for you at this moment. Just writing to acknowledge I saw your post.

    The PCLZip library is part of the WordPress core. The Snapshot plugin simply calls an API method to add the database export file to the zip file. Internally as far as I can tell by reading through the WP core code the location of the temp file created during the zip process is not public. This general means it is part of the PHP configuration.

    So let me dig through the code to see if I can determine how to control the zip processing a little better.

  • Pete T


    1. I'm using multisite, and have Snapshot activated as Network Admin.

    2. See below:
    The following table show version information about your server. when contacting support it might be helpful to provide this information along with your specific issues.

    WordPress Version

    PHP Version

    MySQL Version

    Is Multisite

    Yes, Number of Sites
    Folder Permissions

    Writable (0777) – /XXX/snapshots
    Writable (0777) – /XXX/snapshots/_backup
    Writable (0777) – /XXX/snapshots/_locks
    Writable (0777) – /XXX/snapshots/_logs
    Writable (0777) – /XXX/snapshots/_restore

    PHP runtime information

    Display Errors

    Error Reporting

    Magic Quotes

    Max Execution Time (seconds)

    Memory Limit

    ZLib Compression

    The memory_limit per your php.ini is 256M

    3. No running CentOS5 32-bit on the server with Apache. And PHP 5.3.10

    Also, if I may note, all of the directories and files and such were created in the /snapshots subdirectory, so doesnt look like a permissions problem there. In fact everything works well until the class-pclzip.php error keboshes the process.

  • Paul


    One other thing. If you look under the wp-content/uploads/snapshots folder you will see a set of folders starting with an underscore '_'. These are using during the backup/restore processing. You should see a folder '_logs'. Inside this you will see one of more files like '1337296884_backup.log' The first part will match your snapshot entry when you list all snapshots. Hover on the edit link to see the URL. you should see the match. Can you pass me the log file for the snapshot where you are getting this perms error. It might have more details.

    Another folder you will see is '_backups'. Beneath this folder you will see a folder with the same timestamp used. Inside this timestamp folder you should see a file ''. When the snapshot process exports a table it first build a file like 'wp_options.sql'. Once this complete it then adds the .sql file to the '' zip file. Then for each table the same process repeats. Again the plugin uses the standard WP hooks to add the .sql file to the .zip file master. Even after the error you received you should still see the orphaned file there.

  • Paul

    So just more research notes. Did some digging into the class zip module around the line mentioned in your error. Seems the temp directory needs to have the trailing slash. Otherwise the file is create is the parent.

    So to combine this to you wp-config.php define it should be:

    define('PCLZIP_TEMPORARY_DIR', ABSPATH . 'wp-content/tmp'/);

    And of course make sure /wp-content/tmp/ is full permission. For now.

  • Pete T

    Hey Paul,

    That worked like a champ, setting the temp path to:

    define('PCLZIP_TEMPORARY_DIR', ABSPATH . 'wp-content/tmp/');

    However, now I noticed a different problem. Not all of my multisite tables are represented and backed up. When I create a new snapshot, it lists the tables for me to select and only the basic wordpress tables, and those for site ID 2 are represented. However, I have 3 other sites in this installation whose tables are not showing up (ID 6, 7, 8). Also, what is the intention for Snapshot in a multisite install? I activated it and am using it as network admin. Should I instead activate it separately for each individual site?

    This really is a brilliant plugin and I cant wait to put it into service!

    P.S. Should I start a new thread for this other issue?

  • Paul


    Excellent! So to close the loop on the permission issue. From what I can tell if you don't set this value then WP just sets it to blank. Which means the temp file used by the zip process is created in your site root. So this would indicate you have your site root locked down to prevent new files created. I hope my assumptions are correct.

    As for your other reported issue. When you go to the Add New Snapshot screen you should see the first form element is a drop down listing all your sites. From the drop down you can select which site to backup via Snapshot. When the value changes in the drop down the table listing should also be updated.

    At the time you do need to setup a Snapshot per site. In a future version I want to add the ability to clone a snapshot setting. So for example you create a base snapshot to backup all files for one site. You would then be able to clone this to all or selected sites. Thus creating multiple snapshot entries. The reason we are not taking one large snapshot of all sites at once is more a concern on the time this would take. We have many members who host Multisite installs with thousands and hundreds of thousand site. So the concern here would be timeout and just the large size of the zip file itself.

    Plus we wanted to keep the site data separate and discreet. Coming in the next version of Snapshot will be to include files. This would allow a next logical step of migration. So we would allow an admin to migrate a sub-site from one Multisite install to another or simply to a standalone WordPress install. So having the data all together would make this difficult.

  • Pete T

    Yes my site root is locked down. And I Now remember that dropdown. Snapshot works very well! I look forward to the additions!

    Also, do you have any plans for off-site storage such as Dropbox, sugarsync, email, or another FTP on the roadmap? That would elevate Snapshot into an all-in-one solution. I understand Snapshot's intended use, but I think it's real value is as a backup solution, as there are so few working / reliable ones out there. Please give it a thought. Anyway, great work, excellent plugin, and thanks for the outstanding support!!!

  • Paul

    Awesome. Well that closes the permission issues.

    Yes, the plan is to add offsite storage also. So for the mini-roadmap:

    1. Files. So on a Multisite when you backup a sub-site for example you would have the option to include just the media (/wp-content/blogs.dir/X/files/ But when you backup the primary site you would have the option to include themes, plugins or even the WP core. I'm also working on some logic to only backup files that change. So you can take an initial full backup then other snapshots would be like an incremental. So no use archiving the WP core or theme files if they don't change.

    2. Next is offsite storage. I'm actually working on this and #1 at the same time. At first we plan to support FTP/sFTP and Amazon S3. I have concerns with Dropbox. They have a 150Mb limit on uploads. See the Notes section at the end. We also plan to support Rackspace.

    3. Next, would be email alerts on backups and primarily backup failures. As well as being able to email a backup to an address. But again unless the backup is fairly small I can't think emailing the zip file would be much to offer. Though I know of plenty of existing backup plugins which do this as a primary action.

    4. Finally, Migrations and Imports. As I mentioned there is a gap in the existing plugin offering that provide a way to migrate a WordPress site from one host to another. In the past year I've seen some plugins come into use. These are mostly for developers who are building a client site under a sandbox environment then need to migrate it to another server. This is pretty easy under a single WP install. But for Multisite there is nothing. Also, being able to take a sub-site and migrate it to a stand alone WP install would be a big plus. I've done this a few time manually. Basically, my goal here is to allow taking the snapshot zip file and placing it on another host and be able to run a script to get things up and running again.

    Once of my big issues related to the core backup process is how common files like users and usermeta are handled. As you might be aware the user tables are only archive as part of the primary site snapshot. Not for sub-sites. But I'll work this out.

    Thanks for using my little Snapshot plugin. Glad we were able to figure out your permission issue. And thanks for being a WPMU Member.

  • Pete T

    The pleasure is all mine! Thank YOU! Also, I can't wait to see some of those features implemented. #4 is especially interesting as I've had to migrate from single to multisite and vice versa several times, what a PITA.

    And I agree the way Wordpress stores common tables is annoying sometimes (like users and meta). I "get it" why they chose that scenario, but think the caveats outweigh any real benefits it provides. It's bit me in the ass the many times. It's like the whole multisite capability was designed based off of a single (Edublogs-like) use case scenario, without the proper global forethought.

    Also regarding Drobpox, Isn't the API size limitation per PUT ? I think 150mb is still a lot of capability when dealing with Web files and databases especially on a per sub-site basis. Sure if someone wanted to backup a network of 1500 sites and all their files, wordpress core, etc and PUT to dropbox in one transaction they will run into troubs, but as a typical use scenario I think the 150mb limit is totally acceptable for 100% free storage, IMO anyway.

    Thanks again for the updates and can't wait to see the future versions of Snapshot!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.