The WolfspyreLabs Blog/ 2022/ July/ Updating Nextcloud through the CLI/ Updating Nextcloud through the CLI Updating Nextcloud Server is a whole lot easierI don’t like the k8s version of Nextcloud server. It simply feels like the wrong tool for the job. #Instead I run a VM and manage nextcloud as usual. CLI Updating for the win # Check to see if there’s an update #root@bluebox:~# cd /var/www/nextcloud && sudo -u www-data /var/www/nextcloud/occ update:check && cd $OLDPWD π± Click here to see Console π₯ output π β€΅οΈ ```Shell root@bluebox:~# cd /var/www/nextcloud && sudo -u www-data /var/www/nextcloud/occ update:check && cd $OLDPWD Nextcloud 23.0.6 is available. Get more information on how to update at https://docs.nextcloud.com/server/23/admin_manual/maintenance/upgrade.html. 1 update available ``` That's pretty slick. Update it for me #root@bluebox:~# cd /var/www/nextcloud && sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/updater/updater.phar && cd $OLDPWD π± Click here to see Console π₯ output π β€΅οΈ ```Shell root@bluebox:~/# sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/updater/updater.phar Nextcloud Updater - version: v20.0.0beta4-11-g68fa0d4 Current version is 23.0.5. Update to Nextcloud 23.0.6 available. (channel: "stable") Following file will be downloaded automatically: https://download.nextcloud.com/server/releases/nextcloud-23.0.6.zip Open changelog β Steps that will be executed: [ ] Check for expected files [ ] Check for write permissions [ ] Create backup [ ] Downloading [ ] Verify integrity [ ] Extracting [ ] Enable maintenance mode [ ] Replace entry points [ ] Delete old files [ ] Move new files in place [ ] Done Start update? [y/N] ``` At which point, you press..... (you guessed it) `y`: ```Shell Start update? [y/N] y Info: Pressing Ctrl-C will finish the currently running step and then stops the updater. [β] Check for expected files [β] Check for write permissions [β] Create backup [β] Downloading [β] Verify integrity [β] Extracting [β] Enable maintenance mode [β] Replace entry points [β] Delete old files [β] Move new files in place [β] Done Update of code successful. Should the "occ upgrade" command be executed? [Y/n] ``` At which point, you press..... (you guessed it) `y`: ```Shell Should the "occ upgrade" command be executed? [Y/n] y Nextcloud or one of the apps require upgrade - only a limited number of commands are available You may use your browser or the occ upgrade command to do the upgrade Setting log level to debug Repair step: Repair MySQL collation Repair info: Not a mysql database -> nothing to do Repair step: Repair SQLite autoincrement Repair step: Copy data from accounts table when migrating from ownCloud Repair step: Drop account terms table when migrating from ownCloud Updating database schema Updated database Updating ... Repair step: Upgrading Circles App Updated to 23.1.2 Update app analytics from App Store Update app calendar from App Store Repair step: Update name of the stored view Update app deck from App Store Update app groupfolders from App Store Update app mail from App Store Repair step: Restore default tags that are missing Repair info: Looking up default tags Repair info: 0 accounts to check found Restore default tags that are missing Starting ... 0/0 [>---------------------------] 0% Repair step: Add a generated message-id to all Mail messages that have none Repair info: Looking up messages without a message-id Repair step: Purify and migrate collected mail addresses Purify and migrate collected mail addresses Starting ... 0/0 [->--------------------------] 0% Repair step: Insert background jobs for all accounts Insert background jobs for all accounts Starting ... 0/0 [--->------------------------] 0% Repair step: Make Mail itinerary extractor executable Repair step: Create or update provisioned Mail accounts Repair info: 0 accounts provisioned Repair step: Repair Broken Threads for all mail accounts Repair info: Repaired threads, 0 messages updated Repair step: Repair MySQL collation Repair info: Not a mysql database -> nothing to do Repair step: Repair mime types Repair step: Clean tags and favorites Repair info: 0 tags of deleted users have been removed. Repair info: 0 tags for delete files have been removed. Repair info: 0 tag entries for deleted tags have been removed. Repair info: 0 tags with no entries have been removed. Repair step: Repair invalid shares Repair step: Move .step file of updater to backup location Repair info: .step file exists Repair info: .step-previous-update removed Repair info: .step file moved to .step-previous-update Repair step: Add move avatar background job Repair info: Repair step already executed Repair step: Add preview cleanup background jobs Repair step: Migrate oauth2_clients table to nextcloud schema Repair info: Update the oauth2_access_tokens table schema. Repair info: Update the oauth2_clients table schema. Repair step: Fix potential broken mount points Repair info: No mounts updated Repair step: Repair language codes Repair step: Install new core bundle components Repair step: Add log rotate job Repair step: Clear frontend caches Repair info: Image cache cleared Repair info: SCSS cache cleared Repair info: JS cache cleared Repair step: Clear every generated avatar on major updates Repair step: Add preview background cleanup job Repair step: Queue a one-time job to cleanup old backups of the updater Repair step: Cleanup invalid photocache files for carddav Repair step: Add background job to cleanup login flow v2 tokens Repair step: Remove potentially over exposing share links Repair info: No need to remove link shares. Repair step: Clear access cache of projects Repair step: Reset generated avatar flag Repair step: Keep legacy encryption enabled Repair step: Check encryption key format Repair step: Remove old dashboard app config data Repair step: Add job to cleanup the bruteforce entries Repair step: Queue a one-time job to check for user uploaded certificates Repair step: Repair DAV shares Repair step: Add background job to set the lookup server share state for users Starting code integrity check... Finished code integrity check Update successful Maintenance mode is kept active Resetting log level Keep maintenance mode active? [y/N] ``` I didn't have an explicit need to keep maintenance mode on, so I just hit `N` here ```Shell Keep maintenance mode active? [y/N] n Maintenance mode disabled Maintenance mode is disabled root@bluebox:~/# ``` Reboot # Perform the Major version update #root@bluebox:~# cd /var/www/nextcloud && sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/updater/updater.phar π± Click here to see Console π₯ output π β€΅οΈ ```Shell root@bluebox:~# cd /var/www/nextcloud && sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/updater/updater.phar Nextcloud Updater - version: v20.0.0beta4-11-g68fa0d4 Current version is 23.0.6. Update to Nextcloud 24.0.2 available. (channel: "stable") Following file will be downloaded automatically: https://download.nextcloud.com/server/releases/nextcloud-24.0.2.zip Open changelog β Steps that will be executed: [ ] Check for expected files [ ] Check for write permissions [ ] Create backup [ ] Downloading [ ] Verify integrity [ ] Extracting [ ] Enable maintenance mode [ ] Replace entry points [ ] Delete old files [ ] Move new files in place [ ] Done Start update? [y/N] y Info: Pressing Ctrl-C will finish the currently running step and then stops the updater. [β] Check for expected files [β] Check for write permissions [β] Create backup [β] Downloading [β] Verify integrity [β] Extracting [β] Enable maintenance mode [β] Replace entry points [β] Delete old files [β] Move new files in place [β] Done Update of code successful. Should the "occ upgrade" command be executed? [Y/n] ``` No..... I'd rather you didn't do anything. I like being out of date.... **Press** `Y` **here** ```Shell Start update? [y/N] y Info: Pressing Ctrl-C will finish the currently running step and then stops the updater. [β] Check for expected files [β] Check for write permissions [β] Create backup [β] Downloading [β] Verify integrity [β] Extracting [β] Enable maintenance mode [β] Replace entry points [β] Delete old files [β] Move new files in place [β] Done Update of code successful. Should the "occ upgrade" command be executed? [Y/n] Y Nextcloud or one of the apps require upgrade - only a limited number of commands are available You may use your browser or the occ upgrade command to do the upgrade Setting log level to debug Repair step: Repair MySQL collation Repair info: Not a mysql database -> nothing to do Repair step: Repair SQLite autoincrement Repair step: Copy data from accounts table when migrating from ownCloud Repair step: Drop account terms table when migrating from ownCloud Updating database schema Updated database Disabled incompatible app: breezedark Disabled incompatible app: deck Disabled incompatible app: external Disabled incompatible app: groupfolders Disabled incompatible app: ocdownloader Updating ... Updated to 1.14.0 Updating ... Updated to 1.12.0 Updating ... Repair step: Update OAuth token expiration times Updated to 1.12.0 Updating ... Updated to 1.14.0 Updating ... Updated to 1.19.0 Updating ... Updated to 2.16.0 Updating ... Repair step: Upgrading Circles App Updated to 24.0.0 Updating ... Updated to 1.7.0 Updating ... Repair step: Fix component of birthday calendars Repair info: 1 birthday calendars updated. Repair step: Regenerating birthday calendars to use new icons and fix old birthday events without year Repair info: Repair step already executed Repair step: Fix broken values of calendar objects Fix broken values of calendar objects Starting ... 0/0 [>---------------------------] 0% Repair step: Registering building of calendar search index as background job Repair info: Repair step already executed Repair step: Register building of social profile search index as background job Repair step: Registering background jobs to update cache for webcal calendars Repair info: Added 0 background jobs to update webcal calendars Repair step: Registering building of calendar reminder index as background job Repair info: Repair step already executed Repair step: Clean up orphan event and contact data Repair info: 0 events without a calendar have been cleaned up Repair info: 0 properties without an events have been cleaned up Repair info: 0 changes without a calendar have been cleaned up Repair info: 0 cached events without a calendar subscription have been cleaned up Repair info: 0 changes without a calendar subscription have been cleaned up Repair info: 0 contacts without an addressbook have been cleaned up Repair info: 0 properties without a contact have been cleaned up Repair info: 0 changes without an addressbook have been cleaned up Repair step: Remove activity entries of private events Repair info: Removed 0 activity entries Repair step: Clean up old calendar subscriptions from deleted users that were not cleaned-up Clean up old calendar subscriptions from deleted users that were not cleaned-up Starting ... 0/0 [->--------------------------] 0% Repair info: 0 calendar subscriptions without an user have been cleaned up Updated to 1.22.0 Updating ... Repair step: Fix the share type of guest shares when migrating from ownCloud Repair step: Copy the share password into the dedicated column Repair step: Set existing shares as accepted Updated to 1.16.2 Updating ... Updated to 1.14.0 Updating ... Updated to 1.17.0 Updating ... Updated to 1.14.0 Updating ... Repair step: Populating added database structures for workflows Updated to 2.6.0 Updating ... Updated to 1.14.0 Updating ... Updated to 1.14.0 Updating ... Updated to 2.13.0 Updating ... Updated to 1.13.0 Updating ... Updated to 2.12.0 Updating ... Updated to 1.14.0 Updating ... Updated to 1.15.0 Updating ... Repair step: Migrate old user config Migrate old user config Starting ... 0/0 [--->------------------------] 0% Updated to 1.10.0 Updating ... Updated to 1.5.0 Updating ... Updated to 7.4.0 Updating ... Updated to 1.14.0 Updating ... Updated to 2.5.0 Updating ... Updated to 1.3.0 Updating ... Updated to 1.13.0 Updating ... Updated to 2.9.0 Updating ... Updated to 1.6.0 Updating ... Updated to 1.8.0 Updating ... Updated to 1.14.0 Updating ... Updated to 1.3.0 Updating ... Updated to 1.14.0 Updating ... Updated to 1.6.0 Updating ... Repair step: Switches from default updater server to the customer one if a valid subscription is available Repair info: Repair step already executed Updated to 1.7.0 Updating ... Repair step: Send an admin notification if monthly report is disabled Updated to 1.12.0 Updating ... Updated to 3.5.1 Updating ... Repair step: Add background job to check for backup codes Updated to 1.13.0 Updating ... Updated to 1.14.0 Updating ... Updated to 1.4.0 Updating ... Updated to 1.8.0 Updating ... Updated to 1.4.0 Update app breezedark from App Store Update app deck from App Store Update app external from App Store Repair step: Copy default images to the app data directory Repair info: Icon external.svg already exists Repair info: Icon external-dark.svg already exists Repair info: Icon settings.svg already exists Repair step: Copy default images to the app data directory Repair info: Icon external.svg already exists Repair info: Icon external-dark.svg already exists Repair info: Icon settings.svg already exists Repair step: Copy default images to the app data directory Repair info: Icon external.svg already exists Repair info: Icon external-dark.svg already exists Repair info: Icon settings.svg already exists Update app groupfolders from App Store Repair step: Repair MySQL collation Repair info: Not a mysql database -> nothing to do Repair step: Repair mime types Repair step: Clean tags and favorites Repair info: 0 tags of deleted users have been removed. Repair info: 0 tags for delete files have been removed. Repair info: 0 tag entries for deleted tags have been removed. Repair info: 0 tags with no entries have been removed. Repair step: Repair invalid shares Repair step: Move .step file of updater to backup location Repair info: .step file exists Repair info: .step-previous-update removed Repair info: .step file moved to .step-previous-update Repair step: Add move avatar background job Repair info: Repair step already executed Repair step: Add preview cleanup background jobs Repair step: Migrate oauth2_clients table to nextcloud schema Repair info: Update the oauth2_access_tokens table schema. Repair info: Update the oauth2_clients table schema. Repair step: Fix potential broken mount points Repair info: No mounts updated Repair step: Repair language codes Repair step: Install new core bundle components Repair step: Add log rotate job Repair step: Clear frontend caches Repair info: Image cache cleared Repair info: SCSS cache cleared Repair info: JS cache cleared Repair step: Clear every generated avatar on major updates Repair step: Add preview background cleanup job Repair step: Queue a one-time job to cleanup old backups of the updater Repair step: Cleanup invalid photocache files for carddav Repair step: Add background job to cleanup login flow v2 tokens Repair step: Remove potentially over exposing share links Repair info: No need to remove link shares. Repair step: Clear access cache of projects Repair step: Reset generated avatar flag Repair step: Keep legacy encryption enabled Repair step: Check encryption key format Repair step: Remove old dashboard app config data Repair step: Add job to cleanup the bruteforce entries Repair step: Queue a one-time job to check for user uploaded certificates Repair step: Repair DAV shares Repair step: Add background job to set the lookup server share state for users Starting code integrity check... Finished code integrity check Update successful Maintenance mode is kept active Resetting log level Keep maintenance mode active? [y/N] ``` Press `N` ```Shell Keep maintenance mode active? [y/N] N Maintenance mode disabled Maintenance mode is disabled root@bluebox:/var/www/nextcloud# ``` Validate everything’s Kosher #root@bluebox:/var/www/nextcloud# cd /var/www/nextcloud&& sudo -u www-data /var/www/nextcloud/occ update:check && sudo -u www-data /var/www/nextcloud/occ upgrade: π± Click here to see Console π₯ output π β€΅οΈ ```Shell root@bluebox:/var/www/nextcloud# cd /var/www/nextcloud&& sudo -u www-data /var/www/nextcloud/occ update:check && sudo -u www-data /var/www/nextcloud/occ upgrade Everything up to date Nextcloud is already latest version ``` Mischief Managed #Stupendously simple now. Thanks Nextcloud team :)