|
| 1 | +# Upgrade from V3.x.x {#upgrade-from-v3} |
| 2 | + |
| 3 | +::: warning Warning |
| 4 | + |
| 5 | +The current upgrade tool is still in testing phase. Please make backups before proceeding and be prepared to revert to the original version in case of upgrade failure. |
| 6 | + |
| 7 | +::: |
| 8 | + |
| 9 | +When upgrading from V3.x.x to V4.0.x, the following data will be lost: |
| 10 | + |
| 11 | +- Remote download and other background task records; |
| 12 | +- Order records; |
| 13 | +- Report abuse records; |
| 14 | +- User-customized sidebar; |
| 15 | +- User's hardware authenticators; |
| 16 | +- Theme color configurations; |
| 17 | +- Thumbnails from non-local storage policy generated by thumbnail proxy; |
| 18 | +- Other configuration items no longer supported in V4. |
| 19 | + |
| 20 | +After the upgrade, V3 share links and direct links will remain valid. |
| 21 | + |
| 22 | +## 1. Preparation {#prepare} |
| 23 | + |
| 24 | +### Check Current Version {#check-current-version} |
| 25 | + |
| 26 | +The V3 to V4 upgrade tool was developed based on Cloudreve V3.8.x. Other older versions have not been tested. It is recommended to upgrade Cloudreve to V3.8.x first before proceeding with the upgrade to V4. |
| 27 | + |
| 28 | +### Close the Site {#close-site} |
| 29 | + |
| 30 | +Please close the current site and Cloudreve V3 process first to prevent new data from being written to the database. |
| 31 | + |
| 32 | +### Backup Database {#backup-database} |
| 33 | + |
| 34 | +Please backup your existing database version first. You can use third-party tools such as [`mysqldump`](https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html) to create database backups. For SQLite databases, you can directly backup the `cloudreve.db` file. |
| 35 | + |
| 36 | +The upgrade tool will only read the V3 database and convert it to V4 format without modifying the data in the V3 database. However, there is still a possibility of V3 database corruption due to operational errors or program defects. Please make sure you have a backup before proceeding with subsequent operations. |
| 37 | + |
| 38 | +### Backup Configuration File {#backup-config-file} |
| 39 | + |
| 40 | +Please backup the existing V3 version configuration file `conf.ini`. |
| 41 | + |
| 42 | +## 2. Convert Database {#convert-database} |
| 43 | + |
| 44 | +### 2.1 Obtain V4 Executable {#get-v4-executable} |
| 45 | + |
| 46 | +Refer to [Quick Start](../overview/quickstart) to obtain the V4.0.x version of the main program. Name it `cloudreve_v4` and place it in the same directory as the current `cloudreve`. |
| 47 | + |
| 48 | +::: warning Warning |
| 49 | + |
| 50 | +In future versions of V4, this upgrade tool will be removed. Please upgrade to version V4.0.x first, then proceed with subsequent upgrades. |
| 51 | + |
| 52 | +::: |
| 53 | + |
| 54 | +```bash |
| 55 | +# Rename the current Cloudreve V3 executable to cloudreve_v3 |
| 56 | +mv cloudreve cloudreve_v3 |
| 57 | + |
| 58 | +# Rename the V4 main program to cloudreve |
| 59 | +mv cloudreve_v4 cloudreve |
| 60 | + |
| 61 | +# Create a data directory for storing V4 configuration files and data |
| 62 | +mkdir data |
| 63 | +``` |
| 64 | + |
| 65 | +### 2.2 Prepare V4 Configuration File and Database {#prepare-v4-config-and-database} |
| 66 | + |
| 67 | +Refer to [Configuration File](../overview/configure) to prepare a configuration file `conf.ini` for V4 use, and place it in the `data` directory created in the previous step. In the V4 configuration file, please specify the database connection information for V4 in the `Database` configuration item. Please create a new database separate from V3. |
| 68 | + |
| 69 | +You can also directly copy the V3 configuration file `conf.ini` to the `data` directory and modify the database connection information in it, changing the `Name` in the `Database` configuration item to the name of the V4 database, or specify a new SQLite database file location through the `DBFile` configuration item. |
| 70 | + |
| 71 | +::: tip |
| 72 | +In V4, specifying the table prefix `TablePrefix` configuration item is no longer supported, so it is recommended here to specify a new database for V4, separate from V3. |
| 73 | +::: |
| 74 | + |
| 75 | +```bash |
| 76 | +# Copy the V3 configuration file `conf.ini` to the data directory created in the previous step |
| 77 | +cp conf.ini data/conf.ini |
| 78 | + |
| 79 | +# Modify the database connection information in the V4 configuration file |
| 80 | +# Please create a new database separate from V3 |
| 81 | +nano data/conf.ini |
| 82 | +``` |
| 83 | + |
| 84 | +### 2.3 Run the Upgrade Tool {#run-upgrade-tool} |
| 85 | + |
| 86 | +```bash |
| 87 | +# Run the upgrade tool |
| 88 | +./cloudreve migrate --v3-conf conf.ini -c data/conf.ini |
| 89 | +``` |
| 90 | + |
| 91 | +Specify the V4 configuration file path with the `-c` parameter and the V3 configuration file path with the `--v3-conf` parameter. The upgrade tool will read the data from the V3 database, convert it to V4 format, and write it to the V4 database. |
| 92 | + |
| 93 | +Depending on the amount of data, the upgrade tool may take from several minutes to several hours to run. |
| 94 | + |
| 95 | +## 3. Start V4 {#start-v4-site} |
| 96 | + |
| 97 | +After the upgrade tool has finished running, you can start the V4 site. |
| 98 | + |
| 99 | +```bash |
| 100 | +# Start V4 |
| 101 | +./cloudreve |
| 102 | +``` |
| 103 | + |
| 104 | +## 4. Subsequent Steps |
| 105 | + |
| 106 | +1. If you still see the V3 page when accessing the site after the upgrade is complete, please delete your browser cache and make sure you are not using a custom frontend. |
| 107 | +2. After checking that the V4 site is running normally, the database data used by V3 can be deleted. |
| 108 | + |
| 109 | +## Common Issues {#common-issues} |
| 110 | + |
| 111 | +::: details If the upgrade process is interrupted abnormally, how do I retry? |
| 112 | + |
| 113 | +Simply re-run the upgrade tool. Cloudreve will save the upgrade progress to the `migration_state.json` file and continue from where it was interrupted when started again. If you need to start the upgrade from scratch: |
| 114 | + |
| 115 | +1. Delete all data tables and data already generated in the V4 database; |
| 116 | +2. Delete the `migration_state.json` file, or use the `--force-reset` parameter to restart the upgrade. |
| 117 | + |
| 118 | +::: |
0 commit comments