Trying to backup ncp instance from RPi 3b+ to RPi 4 (4GB)

Hey there. Yesterday I received my new Raspberry Pi 4 (8 GB) that I wanted for my NextcloudPi server. I asked help on Telegram group (https://t.me/NextCloudPi/40931) and now I’m here looking for more help and hoping that this post will help more people.

I launched ncp-backup command more than 12 hours ago, I just checked the state of the backup now, and the nextcloud-bck file has gone, I get this on terminal:

Running nc-backup
check free space...
clean up old backup /media/USBDRIVE1/nebula/backups/nextcloud-bkp_20200911_1599827190.tar.gz
Maintenance mode enabled
backup database...
backup files...
chown: changing group of '/media/USBDRIVE1/nebula/backups/nextcloud-bkp_20201116_1605529641.tar.gz': Operation not permitted
Abort...
rm: cannot remove '/media/USBDRIVE1/nebula/backups/nextcloud-bkp_20201116_1605529641.tar.gz': Input/output error
Maintenance mode disabled
Done. Press any key...
1 Like

Please post the output of
ls -la /media/USBDRIVE1/nebula/backups/

pi@nextcloudpi:/media/USBDRIVE1/nebula $ ls -la /media/USBDRIVE1/nebula/backups/
total 6144
drwxrwxrwx 1 root root 2097152 Nov 17 00:21 .
drwxrwxrwx 1 root root 2097152 Sep 11 14:25 ..
-rwxrwxrwx 1 root root  317440 Sep 11 18:53 ncp-config_20200911.tar

Thanks bro. Looks to be a permissions issue as described in this recent guide.

Try changing recursive ownership from root to www-data as shown below. Note, you might want to include the parent directories as well:
$ sudo chown www-data:www-data -R /media/USBDRIVE1/nebula/backups/

pi@nextcloudpi:/media/USBDRIVE1 $ sudo chown www-data:www-data -R /media/USBDRIVE1/nebula/
chown: changing ownership of '/media/USBDRIVE1/nebula/backups/ncp-config_20200911.tar': Operation not permitted
chown: changing ownership of '/media/USBDRIVE1/nebula/backups': Operation not permitted
chown: changing ownership of '/media/USBDRIVE1/nebula/': Operation not permitted

Verify if pi has sudo access
$ sudo -v

Still getting same thing…

pi@nextcloudpi:/media/USBDRIVE1 $ sudo -v

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for pi:
pi@nextcloudpi:/media/USBDRIVE1 $ sudo -v
pi@nextcloudpi:/media/USBDRIVE1 $ sudo usermod -a -G www-data pi
pi@nextcloudpi:/media/USBDRIVE1 $ sudo chown www-data:www-data -R /media/USBDRIVE1/nebula/
chown: changing ownership of '/media/USBDRIVE1/nebula/backups/ncp-config_20200911.tar': Operation not permitted
chown: changing ownership of '/media/USBDRIVE1/nebula/backups': Operation not permitted
chown: changing ownership of '/media/USBDRIVE1/nebula/': Operation not permitted

What does the nebula directory mean, just a name?
Is this drive just for NextcloudPi?

Here is another way to check sudo access

$ sudo -l -U

In /media I have one USBDRIVE for Nextcloud

pi@nextcloudpi:/media/USBDRIVE5 $ ls
lost+found  ncdata  ncdatabase

and another that I connect to the Raspberry when I want to make a backup, USBDRIVE1 is used for other things.
nebula is the name i’ve given to my Nextcloud server.

Is it mounted via fstab? Personally, I always mount by UUID

I just made a
sudo mount /dev/sdb1 /media/USBDRIVE1

sudo -l -U pi give me that, I think I have the correct root access:

User pi may run the following commands on nextcloudpi:
        (ALL : ALL) ALL
        (ALL) NOPASSWD: ALL

Hmm, the issue is not being able to execute the commands… you can temporarily switch to user www-data or execute the chown as root.

 sudo -u www-data command

I already tried executing the command as root

root@nextcloudpi:/media/USBDRIVE1/nebula# chown www-data:www-data -R /media/USBDRIVE1/nebula/
chown: changing ownership of '/media/USBDRIVE1/nebula/backups/ncp-config_20200911.tar': Operation not permitted
chown: changing ownership of '/media/USBDRIVE1/nebula/backups': Operation not permitted
chown: changing ownership of '/media/USBDRIVE1/nebula/': Operation not permitted

Try this to see if you have a flag set @euktkgu

You are getting I/0 errors, so chances are either your HDD is failing, or it is not receiving enough power. Then you get permissions denied because probably it is mounting itself read only after the I/0 error.

Do not power it from the PI USB port. Get a dedicated good quality PSU for it.

1 Like