Restore a previously backuped NC instance

I installed ncp on an AMD64 system with Debian 11.6 server.
When testing backup and subsequent restore on an external SSD mounted as sda1, an error occurred on the 3rd restore attempt. See uploaded image.
I ran the series of reinstallation and testing of backup and restore 3 times in a row with the same result.
Screenshot_20230207_173911
For me, backup and restore are crucial for using the Nextcloud.

Nextcloud is now constantly in maintenance mode.

ncpi 25.0.3
(my own: endeavourOS)

an excerpt from the log file

[ nc-backup ] (Tue Feb 7 17:05:32 CET 2023)
Installing template 'ncp-metrics.cfg.sh'...
check free space...
Maintenance mode enabled
backup database...
backup files...
backup /sda1/nextcloud-bkp_20230207_1675785934.tar.gz generated
Maintenance mode disabled

[ nc-restore ] (Tue Feb 7 17:07:42 CET 2023)
check free space...
extracting backup file /sda1/nextcloud-bkp_20230207_1675785934.tar.gz...
restore files...
DATA CONFLICT! Your old '/var/www/nextcloud/data' directory can be found in '/var/www/nextcloud/.data_2023-02-07' after the restore script is done. The new '/var/www/nextcloud/data' directory will be restored from the backup. You can manually merge these directories with this command (run nc-fix-permissions and nc-scan afterwards): cp -rn '/var/www/nextcloud/.data_2023-02-07/'* '/var/www/nextcloud/.data_2023-02-07/'.[!.]* '/var/www/nextcloud/data/'
Restoring old '/var/www/nextcloud/data' to '/var/www/nextcloud/.data_2023-02-07'...
restore database...
backing up existing /opt/ncdata/data to /opt/ncdata/data-2023-02-07...
restore datadir to /opt/ncdata/data...
Maintenance mode disabled
Installing template 'php/opcache.ini.sh'...
System config value tempdirectory set to string /opt/ncdata/data/tmp
System config value logfile set to string /opt/ncdata/data/nextcloud.log
System config value trusted_domains => 11 set to string 91.21.133.212
System config value trusted_domains => 1 set to string 192.168.178.68
System config value trusted_domains => 14 set to string nextcloudpi
System config value trusted_domains => 3 set to string nextcloudpi
System config value overwrite.cli.url set to string https://nextcloudpi/
System config value trusted_proxies => 11 set to string 127.0.0.1
System config value trusted_proxies => 12 set to string ::1
System config value trusted_proxies => 13 set to string nextcloudpi
System config value trusted_proxies => 14 set to string 192.168.178.68
Setup notify_push (attempt 1/5)
✓ redis is configured
✓ push server is receiving redis messages
✓ push server can load mount info from database
✓ push server can connect to the Nextcloud server
✓ push server is a trusted proxy
✓ push server is running the same version as the app
configuration saved
Scanning AppData for files

+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 70 | 44 | 00:00:00 |
+---------+-------+--------------+
Cleanup...

[ nc-restore ] (Tue Feb 7 17:09:29 CET 2023)
check free space...
extracting backup file /sda1/nextcloud-bkp_20230207_1675785934.tar.gz...
restore files...
DATA CONFLICT! Your old '/var/www/nextcloud/data' directory can be found in '/var/www/nextcloud/.data_2023-02-07' after the restore script is done. The new '/var/www/nextcloud/data' directory will be restored from the backup. You can manually merge these directories with this command (run nc-fix-permissions and nc-scan afterwards): cp -rn '/var/www/nextcloud/.data_2023-02-07/'* '/var/www/nextcloud/.data_2023-02-07/'.[!.]* '/var/www/nextcloud/data/'
Restoring old '/var/www/nextcloud/data' to '/var/www/nextcloud/.data_2023-02-07'...
restore database...
backing up existing /opt/ncdata/data to /opt/ncdata/data-2023-02-07...
restore datadir to /opt/ncdata/data...
Maintenance mode disabled
Installing template 'php/opcache.ini.sh'...
System config value tempdirectory set to string /opt/ncdata/data/tmp
System config value logfile set to string /opt/ncdata/data/nextcloud.log
System config value trusted_domains => 11 set to string 2003:db:970b:2f00:3af7:cdff:fec4:3620
System config value trusted_domains => 1 set to string 192.168.178.68
System config value trusted_domains => 14 set to string nextcloudpi
System config value trusted_domains => 3 set to string nextcloudpi
System config value overwrite.cli.url set to string https://nextcloudpi/
System config value trusted_proxies => 11 set to string 127.0.0.1
System config value trusted_proxies => 12 set to string ::1
System config value trusted_proxies => 13 set to string nextcloudpi
System config value trusted_proxies => 14 set to string 192.168.178.68
Setup notify_push (attempt 1/5)
✓ redis is configured
✓ push server is receiving redis messages
✓ push server can load mount info from database
✓ push server can connect to the Nextcloud server
✓ push server is a trusted proxy
✓ push server is running the same version as the app
configuration saved
Scanning AppData for files

+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 70 | 44 | 00:00:00 |
+---------+-------+--------------+
Cleanup...

[ nc-restore ] (Tue Feb 7 17:12:44 CET 2023)
check free space...
extracting backup file /sda1/nextcloud-bkp_20230207_1675785934.tar.gz...
restore files...
DATA CONFLICT! Your old '/var/www/nextcloud/data' directory can be found in '/var/www/nextcloud/.data_2023-02-07' after the restore script is done. The new '/var/www/nextcloud/data' directory will be restored from the backup. You can manually merge these directories with this command (run nc-fix-permissions and nc-scan afterwards): cp -rn '/var/www/nextcloud/.data_2023-02-07/'* '/var/www/nextcloud/.data_2023-02-07/'.[!.]* '/var/www/nextcloud/data/'
Restoring old '/var/www/nextcloud/data' to '/var/www/nextcloud/.data_2023-02-07'...
restore database...
backing up existing /opt/ncdata/data to /opt/ncdata/data-2023-02-07...
mv: cannot move '/opt/ncdata/data' to '/opt/ncdata/data-2023-02-07/data': Directory not empty
Cleanup...

I have read the hints of the 3rd attempt section.
I ran nc-fix.permission.
Than I started nc-scan. But I don’t know what to put in the fields
recursive, external, path1, path 2 and path3.

Can someone explain what the text means

cp -rn '/var/www/nextcloud/.data_2023-02-07/'* '/var/www/nextcloud/.data_2023-02-07/'.[!.]* '/var/www/nextcloud /data/'
Restoring old '/var/www/nextcloud/data' to '/var/www/nextcloud/.data_2023-02-07'...
restore database...
backing up existing /opt/ncdata/data to /opt/ncdata/data-2023-02-07...
mv: cannot move '/opt/ncdata/data' to '/opt/ncdata/data-2023-02-07/data': Directory not empty

If I knew that, I would have a better understanding.

i highly recommended using crontab (outside nexctcloud apps)

example :

file complete folder

script :

tar -czvf nextcloudbackup.tar.gz
/var/www/data/html/nextcloud

dont forget database too ( more easily using postgresql)
using pg_dump

then u have complete backup without any problem i guaranted 100% work as long u dont change system file

Read Backup and Restore.
But it seems you use NextcloudPi.
Than you have got maybe other functions and my links do not work.

cp -rn '/var/www/nextcloud/.data_2023-02-07/'* '/var/www/nextcloud/.data_2023-02-07/'.[!.]* '/var/www/nextcloud /data/'
Restoring old '/var/www/nextcloud/data' to '/var/www/nextcloud/.data_2023-02-07'...
restore database...
backing up existing /opt/ncdata/data to /opt/ncdata/data-2023-02-07...
mv: cannot move '/opt/ncdata/data' to '/opt/ncdata/data-2023-02-07/data': Directory not empty

It seems that the backup (last command backing up …) does not work because the directory exists. You can delete the directory ( /opt/ncdata/data-2023-02-07) or move (mv) it to another name. Make ab backup first. :wink:

Thank you for your answers!
In the meantime I was able to turn off maintenance mode and then ran
(Re)initiate Nextcloud to a clean configuration.

It was important that I could reset the passwords with ncp-config. Then I tried whether restore works correctly: And yes, everything is there again.

I’ve learned so much, I won’t backup and restore 3 times in a row in the future.