uploads restore fails if on different FS

UpdraftPlus Home Forums Paid support forum – UpdraftPlus backup plugin uploads restore fails if on different FS

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #674251
    Hugues Lismonde
    Participant

    Hi,

    Trying to restore an uploads backup fails because the wp-content/uploads and wp-content/updraft directories are on different mount points.

    Relevant part of the log:

    
    0027.430 () Entity: uploads
    0027.430 () restore_backup(backup_file=backup_2020-10-02-0937_Voo_CMS_be747ce0a015-uploads.zip, type=uploads, info=a:2:{s:4:"path";s:30:"/var/www/wp/wp-content/uploads";s:11:"description";s:7:"Uploads";}, last_one=1)
    0027.430 () Unpacking backup... (backup_2020-10-02-0937_Voo_CMS_be747ce0a015-uploads.zip, 73.4 MB)
    0027.432 () Unzipping backup_2020-10-02-0937_Voo_CMS_be747ce0a015-uploads.zip to /var/www/wp/wp-content/upgrade/c776faee/ using UpdraftPlus_ZipArchive, starting index 0
    0027.842 () Unzip progress: 110 out of 110 files (73.4 MB, uploads/ithemes-security/maxmind/index.php)
    0027.842 () RINFO:{"type":"state","stage":"files","data":{"entity":"uploads","index":0,"file":"backup_2020-10-02-0937_Voo_CMS_be747ce0a015-uploads.zip","fileindex":109,"size_written":76915009,"total_files":110}}
    0027.892 () /var/www/wp/wp-content/updraft/uploads-old: This directory already exists, and will be replaced
    0027.907 () Moving old data: filesystem method / updraft_dir is potentially possible
    0027.908 () /var/www/wp/wp-content/uploads-old: This directory already exists, and will be replaced
    0027.912 () Moving old data: can potentially use wp_filesystem method / -old
    0027.912 () Moving old data out of the way...
    0027.965 () Error message: Could not move the files into place. Check your file permissions.
    0027.965 () Error data (move_failed): /var/www/wp/wp-content/uploads/ithemes-security -> /var/www/wp/wp-content/updraft/uploads-old/ithemes-security
    0027.965 () uploads: /var/www/wp/wp-content/uploads: deleting contents (as attempts to copy failed)
    0028.049 () Moving unpacked backup into place...
    0028.068 () PHP event: code E_WARNING: copy(): The first argument to copy() function cannot be a directory (line 309, wp-admin/includes/class-wp-filesystem-direct.php)
    0028.074 () Error message: Could not move the files into place. Check your file permissions.
    0028.074 () Error data (move_failed): /var/www/wp/wp-content/upgrade/c776faee/uploads/2020 -> /var/www/wp/wp-content/uploads/2020
    0028.074 () RINFO:{"type":"state","stage":"cleaning","data":[]}
    0028.083 () Restore failed...
    0028.083 () Error message: Could not move the files into place. Check your file permissions.
    0028.083 () Error data (move_failed): /var/www/wp/wp-content/upgrade/c776faee/uploads/2020 -> /var/www/wp/wp-content/uploads/2020
    0028.083 () Restore failed
    

    The restorer.php move function only uses rename:

    
    	public function move($source, $destination, $overwrite = false) {
    		if (!$overwrite && $this->exists($destination))
    			return false;
    
    		// try using rename first. if that fails (for example, source is read only) try copy
    		if (@rename($source, $destination))// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
    			return true;
    
    		return false;
    	}
    

    as opposed to its WordPress original:

    
    		if ( ! $overwrite && $this->exists( $destination ) ) {
    			return false;
    		}
    
    		// Try using rename first. if that fails (for example, source is read only) try copy.
    		if ( @rename( $source, $destination ) ) {
    			return true;
    		}
    
    		if ( $this->copy( $source, $destination, $overwrite ) && $this->exists( $destination ) ) {
    			$this->delete( $source );
    			return true;
    		} else {
    			return false;
    		}
    

    rename doesn’t always work across partitions or over NFS mounts (this is not a permissions problem per se as they are correct but can’t be changed by the process executing the restore)

    #674252
    Hugues Lismonde
    Participant
    This reply has been marked as moderator-only.
    #674263
    udadmin
    Keymaster

    Hi,

    Actually UpdraftPlus calls copy() if rename() fails – that’s why there are errors in your log which mention copy() (the wording of which comes from WP core and is misleading). So, copy() is also failing on your setup.

    David

    #674271
    udadmin
    Keymaster

    (Note the code comment above that method, concerning why that part isn’t reproduced in that location:

    // The purpose of this is that, in a certain case, we want to forbid the "move" operation from doing a copy/delete if a direct move fails... because we have our own method for retrying (and don't want to risk copying a tonne of data if we can avoid it)

    )

    #675857
    Hugues Lismonde
    Participant

    Yes indeed I saw that afterward and haven’t had the time to come back here.

    So now it’s not a rename bug but a copy bug. I’ve tried to debug but other priorities came and my problem remains, all permissions are ok, I can copy/move files as the same user (999/999) without issue but updraft can’t restore the files (db is fine).

    Currently my setup has two NFS mounts, one for wp-content/uploads and one for wp-content/updraft. This is needed because the site is served by multiple docker containers and so I need to ensure they all see the same updraft folder. wp-content/upgrade is inside the container but I’m trying to mount it through NFS also to see if that helps.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘uploads restore fails if on different FS’ is closed to new replies.