Skip to main content

Migrating Drupal 6 'sites/default/files' directory to 'sites/'

Just wanted to post these instructions for my own sanity, and so I wouldn't lose them as I've used them numerous times over the past year. Thanks Jeff for the original post:…

Steps to change a Drupal 6 database to use a new files directory

  1. Update the files table (which is used by the system as well as imagecache):
    1. UPDATE `files` SET `filepath` = REPLACE(`filepath`, `sites/OLDDOMAIN/files/`, `sites/NEWDOMAIN/files/`);
  2. Update the boxes table (which is used for all the block content):
    1. UPDATE `boxes` SET `body` = REPLACE(`body`, `sites/OLDDOMAIN/files/`, `sites/NEWDOMAIN/files/`);
  3. Update the node_revisions table (all the node content is in here... you'll need to update both the body and the teaser fields):
    1. UPDATE `node_revisions` SET `body` = REPLACE(`body`, `sites/OLDDOMAIN/files/`, `sites/NEWDOMAIN/files/`);
    2. UPDATE `node_revisions` SET `teaser` = REPLACE(`teaser`, `sites/OLDDOMAIN/files/`, `sites/NEWDOMAIN/files/`);
  4. Update the users table 'picture' value (if you're using user pictures):
    1. UPDATE `users` SET `picture` = REPLACE(`picture`, `sites/OLDDOMAIN/files/pictures/`, `sites/NEWDOMAIN/files/pictures/`);