Failed backup led to unwanted reinstall script: how to roll back?

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 23.0.3 (or 23.0.4)
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): latest
PHP version (eg, 7.4): 7.4

The issue you are facing:

Failed doing a backup with the backup plugin. Then wrote a script to backup files and DB. Then bash script failed partially because of permission issues. Then moved to backup folder and inadvertently executed an occ command within the folder.
Now the main Nextcloud instance is showing me “Looks like you’re trying to install NextCloud again”. I can’t connect to DB anymore.
I think I was able to backup all “drive” files, but I’m worried I will miss critical data from the database.

How can I reverse the process.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Try to copy/paste nextcloud folder into a backup location + dump database
  2. execute occ command from the backup location
  3. Try starting the main nextcloud instance again.

Here is a screenshot of the current message:

I don’t want to reinstall. I would like to restore to previous state, if possible.

For what it’s worth, here is the script I had written to generate the backup, which failed:

#!/bin/sh
echo "Reminder: This needs to be run from the nextcloud folder!!"
export WDIR=`date +"%Y%m%d"`
sudo -u www-data php occ maintenance:mode --on
sudo mkdir ~/backups
sudo mkdir ~/backups/nextcloud
cd ~/backups/nextcloud
sudo mkdir $WDIR
sudo cp /var/www/nextcloud $WDIR -R
sudo chown $1 $WDIR -R
#sudo mysqldump --single-transaction --default-character-set=utf8mb4 -h localhost -u $2 -p$3 $4 | gzip > $WDIR/nextcloud-$WDIR.sql.gz
sudo zip -r ../nextcloud-$WDIR.zip  ./$WDIR/
sudo chown $1 ../nextcloud-$WDIR.zip
#sudo rm -rf $WDIR
sudo -u www-data php occ maintenance:mode --off

Thanks for your help.
At this stage, I don’t think any other log is going help finding a solution. Correct me if I am wrong. Thanks for your understanding.

Best,