News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

SMF Upgrading Procedure and Good Practices

Started by Chen Zhen, February 22, 2014, 03:26:51 PM

Previous topic - Next topic

Chen Zhen

SMF Upgrading Procedure

Notes:

  The following procedure is worded for an upgrade from SMF 1.1.19 to SMF 2.0.7 and using folder path names of forum & forum_old. These can be substituted to your specific SMF versions and folder paths.

  For export/import of a large database (ie. 20MB+) it is advised to make several compressed files containing partial exports of the original database. During mysql exporting one can opt to only backup specific tables whereas it may be prudent to export very large tables separately. One can then import those compressed mysql db files one at a time so long as they each contain different tables surmounting to the entire database backup.  This may eliminate the need to use other utilities such as BigDump or SqlDump to move larger db backups.

  This procedure will allow one to upgrade a forum while keeping backups of the original db data and files/folders. If anything goes awry or was forgotten in error it can easily be copied over to the new installation again.

  For this procedure one will be required to install an AMP platform application on their PC/MAC that allows testing/running forum software.
ref. http://en.wikipedia.org/wiki/List_of_Apache%E2%80%93MySQL%E2%80%93PHP_packages 




Example Scenario:







Current outdated/corrupted SMF installation: SMF 1.1.19
Target SMF installation: SMF 2.0.7
Installation residing path: ../forum
Copy of original forum path (rename ../forum to this folder): ../forum_old
Example error page residing path: /www/public_html/error_page

Procedure:


  • Empty out error log, unimportant logs and perform maintenance including db to lessen db size
  • Ensure no unnecessary copies of tables are within the same db
  • Copy db from forum to gzip file
  • Install SMF 1.1.19 locally on PC (same version as original forum)
  • Omit db tables from new local installation of SMF 1.1.19 (same version as original forum)
  • Import backup of original db to local installation
  • Run repair_settings.php on local installation & adjust paths
  • Use SMF 2.0.7 (or current SMF version) upgrade package on local installation
  • Copy db from local installation to gzip compressed file
  • Rename folder on host root dir (ie. ../forum) to forum_old
  • Create new folder (ie. ../forum in this case) and copy all files from forum_old into it
  • Create new database tables and prefix
  • Import copy of db from local installation to newer one created on server
  • Run repair_settings.php on new forum folder (set all dirs and paths accordingly & save then go to next step...)
  • Upload and replace files with upgrade package to new forum folder
  • Run upgrade package
  • Ensure all upgrade related files are removed (check mark box prior to viewing new forum installation)
  • Remove repair_settings.php
  • Remove all ghost theme directories in admin manage themes (ones that are not actually in the Themes folder)
  • *Upgrading from previous SMF 2.0.X branch* -> Use the Hooks Removal Tool
  • Run maintenance for Recount all forum totals and statistics, Find and repair any errors & Optimize all tables
  • Install smiley packs native to SMF 2.0.7 (or current SMF version)
  • Install avatar packs native to SMF 2.0.7 (or current SMF version)
  • Install mods native to SMF 2.0.7 (or current SMF version)
  • Done




Copying Files:

  It is also wise to keep backups of the files & folders on your PC/MAC however this can take some time for large folder/file sizes. The above procedure will actually work fairly fast as it copies files all on the server hdd.  If one does not have access to the parent directory of their forum folder, then copying folders/files to a local PC/Mac may be the only option.

Cpanel Notes:
  When copying files I noticed it is best to highlight all within a directory/folder and use the input to manually fill the destination folder on your home server. I advise not to drag all the files and drop them to the left panel of files/folders because Cpanel will 'cut' them instead of just 'copy' them. If the path is filled out manually, it will 'copy' the files whilst leaving the originals intact.   

FTP Platforms

Filezilla Notes:
  Be sure to check/adjust its settings to treat files without extensions as Binary. Failing to do this may result in corrupted image files from the SMF attachments directory.

WinSCP Notes:
  I will actually suggest that one uses the WinSCP FTP platform when copying files. This application should copy your attachments directory (containing files void of extensions) without any issues and may also facilitate in fixing corrupted image files due to initial accidental ASCII encoding.





.htaccess & custom error message:

Note: The procedure shown below is not entirely necessary for all scenarios. However, if you are going to keep a copy of your old forum on the server itself as this example demonstrates it would be wise to follow the first step. This will ensure no one is accessing your old copies of forum files. Further more one can recopy forum files to the forum_old directory to keep constant backups if one desires.

Protecting the older copy of folders/files:

.htaccess file contents for path: ../forum_old  (change example.com to your parent path or the entire url to something relevant)

Options All -Indexes
<Files *>
Order Deny,Allow
Deny from all
</Files>
<Files .htaccess>
order allow,deny
deny from all
</Files>
<Files *.txt>
order allow,deny
deny from all
</Files>
RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml
ErrorDocument 401 http://example.com/error_page/error.html
ErrorDocument 403 http://example.com/error_page/error.html
ErrorDocument 404 http://example.com/error_page/error.html
ErrorDocument 500 http://example.com/error_page/error.html





Creating a custom error page::

  In the parent of the root folder that contains both ../forum and ../forum_old, create a new folder named error_page, create a HTML file called error.html and put the following into it:

ie. /www/public_html/error_page/error.html  (change the link within the code shown below to your forum home page)

<html>
<head>
<title>Page Not Found</title>
</head>
<body>

<h2>We're sorry but the page you're looking for could not be found</h2>
<div>&nbsp;</div>
<div><a href="http://example.com/forum">Go back to the Home Page</a></div>
</body>
</html>


Also create another .htaccess file within the same folder as the error.html file to protect that directory. This file will only allow people to view the error file when they are redirected to it.

ie. /www/public_html/error_page/.htaccess

Order deny,allow
Deny from all

<Files "error.html">
    Allow from all
</Files>





SMF Tools:

  When upgrading from the SMF 1.0x branch to the SMF 2.0x branch, I have developed a tool to resolve issues regarding attachments and/or avatars not being displayed properly with some browsers. The issue is mime types missing from the attachments table. This SMF 2.0x tool will add those mime types to that table where applicable.

Downloads:
Repair Settings Tool
SMF Tools
Image Attachments Mime Types Tool
Useful tools written by Underdog




  There you have it.. An updated forum with secure backups of both files, db and a custom error page. It also leaves a local installation of one's forum for testing mods. The html for the error page can be edited to be more attractive as this is only a basic example.

Regards.

My SMF Mods & Plug-Ins

WebDev

"Either you repeat the same conventional doctrines everybody is saying, or else you say something true, and it will sound like it's from Neptune." - Noam Chomsky

Kindred

Very nice...  But you do realize that most of this is already written/covered in the wiki?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Chen Zhen

  When upgrading from the SMF 1.0x branch to the SMF 2.0x branch, I have developed a tool to resolve issues regarding attachments and/or avatars not being displayed properly with some browsers. The issue is mime types missing from the attachments table.

This SMF 2.0x tool will add those mime types to that table where applicable.
Download: Image Attachments Mime Types Tool




  The amount of mime types may be a little overkill as I tried to accommodate a number of image types. These will only be applied if the extensions are allowable & exist within a given column in ones attachment settings table.
 

My SMF Mods & Plug-Ins

WebDev

"Either you repeat the same conventional doctrines everybody is saying, or else you say something true, and it will sound like it's from Neptune." - Noam Chomsky

Advertisement: