Server migration – issues with blog/forum images still linking to original server

Hi everyone!

I'm running Elgg 1.7.7 and I'm migrating everything from my live server to my localhost for archiving. I've read and followed the wiki for Duplicating Installation to the letter (including all 4 mySQL commands for changing the filestore data directory), and for the most part, everything works. I've even done the time tweak (80% of avatars showing at the moment!).

However, I have an issue:

In blogs/comments/posts, all of the images uploaded by the user still points to the live server instead of the localhost. 

I've tried uploading a file and it works, and all users files are intact and point to the localhost (when I'm at the Files page). The problem is when the images are previously used in a blog post/forum/etc that is is still linked to the live server. 

Can anyone tell me what's missing? I'm frustrated as I've searched and implemented everything already!


  • I found some clues:

    Through phpmyadmin, I found some traces of the original URL (on the live server) in the below tables:

    1. blogwatch (8 entry)

    2. metastrings (512 entries!)

    3. objects_entity (600+ entries!)

    4. private_settings (1 entry)

    The question is how do I rename all instances of the old server URL and replace it with my new one?

  • looks like metadata/strings and maybe other tables have remmants of the old server's pathnames ;-( all those will need to be patched to new server's relative paths - if you're comfortable with playing with the database ;-)

  • Thanks Dhrup! I'm ready to do this on phpMyadmin! :)

    I've done this before as well:

    UPDATE elgg_metastrings set string = '/var/data/elgg_test/' WHERE id = (SELECT value_id from elgg_metadata where name_id = (SELECT * FROM (SELECT id FROM elgg_metastrings WHERE string = 'filestore::dir_root') as ms2) LIMIT 1) ;

    But it doesn't work – the string in the metastrings table still has remnants (lots of it!) of the old server's pathnames. 

    Any pointers from you would be wonderful, and much thanks in advance. (I've already searched on this forum, google, etc!)

  • I believe what you're refering to is the actual content of blogs, etc.  This is stored as html in the database, and isn't used by the system for anything other than displaying that content.  There is no "elgg" way to update that, as far as I'm aware.

    You can do a sql replace and hope it works.  I can't guarantee anything, and make sure you do a backup before you attempt it.

    UPDATE elgg_metastrings

    SET string = REPLACE(REPLACE(string, "", "localhost"), "/old/file/path", "/new/file/path")

    WHERE id > 0

    Keep in mind it's not super sophisticated but it should make all of your images and whatnot work.  You may get some oddities that I can't think of right now, for example if there's any emails using your live url they will be updated to localhost...

  • Matt, thanks for the heads up! And yes, you're right -- they're stored as HTML so no wonder it didn't work (everything did up to that point). I'll make a back up and give your method a go – crossing my fingers that it works!

    I'll report back here when I'm done!

  • easy --
    mysqldump metastrings;
    edit, global replace /olddir/newdir/
    upload sqldump back.

  • Dhrup – thanks for the tip. Is it the same as what Matt suggested? and is that the exact command for me to type out on SQL command? (sorry, I can brave myself to attempt it, but I just wanted to make sure I don't mess things up!) 

    Thank you so very much!

  • i think both are same.. it's just that if you do sqldump and edit - you can see the exact redundant old server path texts like any other text ;-) no sql cmnds nothing - just text..

  • Yes they're both equivalent, Dhrups way is just more graphical.  What I typed out is the exact command, obviously replace "" and "path/to/blah" with the relevant information.

  • ;-) weelll - i kinda likes that phrase 'more graphical', snds quasi-techno-artsy ;-oO
    i was trying to phrase it in a simple-like way so din;t wanna make refs to any API stuff,
    though yr code snippet is the'Elgg' way for same effect. the edit of the sqldump text file
    is sorta up-in-yr-face and pretty stright-forward anyways - b/c one can *see
    what's inside under those hoods that makes Elgg run.. and mostly takes lesser headache time..
    hope GNyMa gets those images showing s-o-on ;-oP *and posts her steps for others
    caught in the same 'missing images' chapter...