Nextcloud backup problem : Could not open input file: occ

Hello everyone,

I’m using Nextcloud since some weeks now, and I would like making a backup of it thanks this tutorial. The thing is I got this :

root@localhost:~# sudo -u www-data php occ maintenance:mode --on
Could not open input file: occ
root@localhost:~# cd /var/www/
root@localhost:/var/www# dir
html

I already searched on the forum a solution of : Could not open input file: occ, and it seems for a majority of people it’s a permission problem. But for me, I don’t even have the Nextcloud folder !

So I tried to locate occ with

root@localhost:~# locate occ

I get a lot of results :

root@localhost:~# locate occ
/snap/bin/nextcloud.occ
/snap/nextcloud/26119/bin/occ
/snap/nextcloud/26119/htdocs/occ
etc...

From now, I’m a bit confused and I don’t know what to do next…

If someone could help, it would be awesome !

Cheers,

since you are using snap: do it the snapway. read the manual and use the include cli utilities

most of the people didn’t seem to be aware that occ is a file read by the php command and therefore you have to supply the full path to it or be in the correct directory before you execute php

so in your case:

sudo -u www-data php /snap/nextcloud/26119/bin/occ maintenance:mode --on

but: do it the snapway. :wink:

1 Like

Thanks for the quick answer.

As you can see, I’m a noob and still discovering stuff and trying to understand how it works.

First, I tried the php method with your command line, and I get this in return :

root@localhost:~# sudo -u www-data php /snap/nextcloud/26119/bin/occ maintenance:mode --on

# shellcheck source=src/mysql/utilities/mysql-utilities
. "$SNAP/utilities/mysql-utilities"
# shellcheck source=src/php/utilities/php-utilities
. "$SNAP/utilities/php-utilities"
# shellcheck source=src/redis/utilities/redis-utilities
. "$SNAP/utilities/redis-utilities"
# shellcheck source=src/nextcloud/utilities/nextcloud-utilities
. "$SNAP/utilities/nextcloud-utilities"

if [ "$(id -u)" -ne 0 ]; then
        echo "This utility needs to run as root"
        exit 1
fi

wait_for_php
wait_for_redis
wait_for_nextcloud_to_be_configured

run-php "$SNAP/htdocs/occ" "$@"

I don’t really understand what I’m reading tho… haha

Second, you’re telling me to do it the snapway, I don’t know how to put the server in maintenance mode with snap command, and if I still can follow the step of the backup tutorial !

NB : I’m super happy that in your short manuel, it explains how to change HTTP port, I never found how to do it, so I changed the PiHole admin panel port from 80 to 81 haha !

that’s in the manual. basically just run nextcloud.occ
that should be equivalent to " sudo -u www-data php /snap/nextcloud/26119/bin/occ"

of course you could follow the “official backup tutorial”. but it won’t match out-of-the-box. you have to understand what you have to backup (data, config, database) and where to find it in the snap folders.

1 Like

Thanks a lot dude !

With the simple command :

nextcloud.export

I was able to copying everything, and a rapid scp command allowed me to backup the save folder on my computer !

It was super easy finally ! :smiley:

There is a very useful walkthrough here How To Backup Nextcloud - Kev Quirk