Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Trying to migrate file and file_chunk from one database to another database


I am trying to migrate attachments (and tickets & threads) from DB_1 to DB_2. I wrote basic mysql query to select all the fields from DB_1 and trying to insert into DB_2. I can successfully echo all the data on the page but the insertion doesn't work. 

I am getting the max(id) from file table in DB_2 and inserting the new file_id as max(id) + 1 for file_id field in both attachment and file_chunk tables, since they are not auto-increment fields.

I am new to this, could someone give me some advice?  


  • Hello, 

    Now all the attachment data (from DB_2) have inserted in to DB_1, including `filedata` field in file_chunk table. But when I click on download the file, my Chrome shows "Failed - Server Problem". Anybody knows why? I am guessing directly inserting longBLOB into the database may not work like this?  

  • No idea I've never tried.

    Although im curious why you wouldn't export db1 change the db name in the file and import it to db2.
  • edited February 6
    @ntozier  Could you explain a little bit more about exporting and importing?  

    And by the way, I think I found out the issue. Due to the chunk_size set in class.file.php, the files are stored in chunks of 500KB. That's why it didn't work since I directly selecting filedata from DB_1 and insert into DB_2. Tried a different file smaller than 500 KB and it worked. 

    Is there any problem if I change the "500" in "define('CHUNK_SIZE', 500*1024) " to some bigger number?
  • And when I do a SQL SELECT statement to select the longblob from DB_1 -  file_chunks - filedata, I am only selecting the first 500KB chunk not the whole filedata. Anybody has any idea of how to solve that? Thanks 
Sign In or Register to comment.