[Tutorial] Downgrade from YetiShare v4.4 to v4.3

jeybird966368

New Member
YetiShare User
Dec 29, 2016
20
1
1
TIP: If you are having issues with files not generating links/saving after an upload then try disabling one or all of your plugins to see if that fixes it. It appears certain plugins conflict with some file types.
Try that before downgrading and then decide if you need to downgrade or not.

Note: While this tutorial is complete it still needs images. You can use this tutorial in it’s current state but the lack of visuals might leave some people lost.

How To:
Downgrade from Yetishare v4.4 to v4.3.


A lot of people have been having problems with the latest (V4.4) version of the Yetishare script. This guide is to show users how to downgrade to the previous version.
There are ways to fix problems without downgrading to the old version but some may find it easier to simply hold off until v4.4 is ironed out more.

WARNING: As always, make backups of everything in case something goes wrong so you can roll back. This is most definitely unsupported by the developers and I'm sure they will be rolling in their metaphorical grave when they see this.

I am not liable for anything that happens when following this tutorial.

What you will need:
SSH access to your server
FTP/SFTP access to your server
MySQL Workbench or some other way to edit your MySQL/MariaDB databases.

In my case I’m using Ubuntu 16.04LTS and MySQL Workbench, so your setup may vary slightly. If you use something like PHPmyAdmin then you will either need to figure out some stuff yourself or grab MySQL Workbench and connect to your server with it instead.
I be assuming that you are using NGINX as your web server but this should affect very little.

This tutorial states my specific process of downgrading but of course this can vary from installation to installation. This tutorial should work for anyone who has a single (local) server with paid users.

Step 0 (optional):
Send a newsletter alerting your users that the site will be down for maintenance.
Self explanatory.

Step 1:
Disable Uploads and place your site in Maintenance mode.
We don’t want users performing partial uploads while you mess with your server so it’s best to restrict their access to the site.

Enable “Uploads Block All” in Site Configuration > Site Settings > File Uploads.
Enable “Maintenance Mode” Site Configuration > Site Settings > Site Options.

Step 2:
Write down all of your custom settings, including any Auth keys and pricing structure information.
We won’t be restoring this part of the site so you will need to write these down for when you downgrade to v4.3.
Basically go through everything and write down with as much or as little detail as you want.

Step 3:
Create a Database backup.
This will allow us to roll back to v4.4 without any issue if we mess up and need to undo anything.
You can do this from Site Configuration > System Tools > Backups > Create Database Backup.
Once it’s created, download it.

You don’t need to make a code backup as we will do that when we log in via SSH later.

Step 4:
Backup your whole Yetishare folder.
We’ll quickly create TWO zips with all of the files in our installation, this will backup any custom code you have and also all of the files.

Prerequisites: zip and unzip application (can apt install) or you can use tar.

4a: Log in via SSH.
4b: go to your yetishare directory.

We will create one zip file for files and one for everything else, with makes it easier to manage.
We’ll place these in our home directory. Note that if you have a LOT of files you may prefer to just move the ./files directory away as this will take up more disk space.

Code:
zip -r -9 ~/yeti_files.zip files/
zip -r -9 ~/yeti_misc.zip * -x files/\*
Alternatively you can use tar to create smaller files. (will take a lot longer but can be worth it if space and/or bandwidth is limited.)

Code:
XZ_OPT=-9 tar --exclude='./files' -Jcvf ~/yeti_misc.tar.xz .
GZIP=-9 tar -cvzf ~/yeti_files.tar.gz files/
We’re using gzip for the files folder as most of the content there probably can’t be compressed well anyways. If your users store a lot of compressible data then feel free to try "XZ_OPT=-9 tar -Jcvf ~/yeti_files.tar.xz files/" instead.

If you do not want to create an archive then just rename your old install folder to something else and replace it with a new empty folder with the same name.

Step 5:
Create individual backups for each table in the database.
This partial backup is what we will use when we install Yetishare v4.3.
Here we will only be backing up the basics for the file server: USERS, FILE, FILE_FOLDER, FILE_ACTION, PAYMENT_LOG, and PREMIUM_ODER
If you need to then be sure to back up any additional schemas separately.
If you forget to back something up then you will probably be able to replace it manually but it’s better to be safe than sorry.

5a: Open MySQL Workbench and connect to your server via SSH.
5b: in the menu bar go to Server > Data Export
5c: select/check the table for your Yetishare install.
5da: Be sure to set it to “Dump Structure and Data”
5db: Set to “Export to Project Dump Folder”
5e: Start Export.

You now have individual backups of each table.

Step 6:
Create a new database schema.
You probably already now how to do this if you’ve done it once. I suggest setting the default collation to utf8 utf8_unicode_ci. You can’t reuse the database between versions. Be sure that the new database has the same name as the old one.

Step 7:
Prepping for v4.3 install.
Now we’ll just quickly go over a few things before we install.

7a: Make the new install folder (as mentioned in Step 4) to replace the old one. If you chose to keep the old folder without archiving then you can just rename that one to something like yetishare-old or something.
7b: Download v4.3 from https://mfscripts.com/previous-versions.html?id=10935. You will need to log into your account.
7c: Upload the zip file to your server and extract it into your intended installation location. unzip v4.3_File_Hosting_Script.zip
7d: You can now delete the zip file from your server. Rm v4.3_File_Hosting_Script.zip.

7e: Set the permissions and ownership of the install folder as follows:
Code:
chmod -R 775 my_yetishare_folder/
chown -R www-data: my_yetishare_folder/
7f: Go through the setup wizard as normal. Delete the /install folder.

7g: Edit the _config.inc.php.
Set your _CONFIG_SITE_HOST_URL, _CONFIG_SITE_FULL_URL, _CONFIG_DB_HOST, _CONFIG_DB_NAME, _CONFIG_DB_USER, _CONFIG_DB_PASS to the appropriate values.
Also be sure to set _CONFIG_SITE_PROTOCOL to https if your site is TLS enabled (If it’s not you should look into that in the future).
BE SURE to replace the _CONFIG_UNIQUE_ENCRYPTION_KEY with the key from your previous install and replace the current one.
Chmod _config.ini.php to 644.

Your cron tasks should be fine as is unless you changed the directory.

Step 8:
Restore your files folder backup.
Depending on which way you chose to back up your files folder you either have to do one of several things

Code:
mv ~/yeti_files.tar.gz /path/to/yeti/install
tar xvf yeti_files.tar.gz
Code:
mv ~/yeti_files.zip /path/to/yeti/install
unzip yeti_files.zip
Code:
mv /path/to/old/yeti/install/files /path/to/new/yeti/install
You may need to repeat the permissions as stated in step 7.

Your files are now where they should be, we can move on to the next step.

Step 9:
Restore the wanted sections of your old database. And edit the database.

Connect to your server with MySQL Workbench via SSH.

Open the schema for your Yetishare install.
Open Tables
Open the users table.

Delete the admin user that was created by the install wizard, we won’t need this and it will cause problems when importing.

In the top menu bar click Server > Data Import.
Select “Import from Dump Project Folder” and navigate to the folder containing your previous backup.
UNCHECK the schema and click on it to list the tables within it. We will only be doing a partial selection.
Select the USERS, FILE, FILE_FOLDER, FILE_ACTION, PAYMENT_LOG, and PREMIUM_ODER tables.
Make sure “Dump Structure and Data” is set.
Start Import.

The structure of Yetishare v4.4 and v4.3 tables are slightly different. Specifically the File and File_Folder tables. So we will need to remove a few columns in these to they match what they would be in v4.3.

Edit the imported FILE table and remove the uploadedUserId and description columns. Click Apply.

Edit imported FILE_FOLDER table and remove the totalSize column. Click Apply.

As of right now all your files will be available and you site will be fully downgraded to version v4.3! All you need to do now is restore and theme changes and some settings and you will be all set and ready to go. Consider this Step 10 :)

If you want to keep more tables then the ones stated here then you will need to note the differences in the structure by looking at the .sql files and making those changes when you import them, which should be simple enough. I could of shortened this quite a bit but I tried to make it so as many people as possible can follow along.

I'm sure this will be irrelevant in the next Yetishare update (4v.4.1?) but who knows how long until that arrives! For some of us it's best to downgrade until the new version is ready.