I think the user nextcloud could not have ssh rigths… The user app is just a user shell, he have no home/$app
directory , no PATH, no .ssh
file.
So I think you will need use your own user (root also can’t use ssh or only locally) to rsync files, then using root to change the owner of the directory chown -R nextcloud: my_rsync_directory
and rsync the files in this folder inside the folder /home/yunohost.app/nextcloud/data
like this: rsync -av /home/my_user/my_rsync_directory/ /home/yunohost.app/nextcloud/data
The problem is that a lot of things are edited in the database. If you are migrating a nextcloud, you need migrate the database ! and also if you want keep the authentification LDAP is a little complex.
Here there is a how-to (in french) Migrate Nextcloud / Migration Nextcloud
Perhaps a better solution is to sync all files with a nextcloud client and then sync them again in the new nextcloud, or a very nice application to do the migration is OwnershipTransfer : A new application for Framaspace: OwnershipTransfer – Framablog
For info, you can open a shell as the user app, but is only to use php occ
commands, for example
yunohost app shell nextcloud
php occ files:scan --all
Anyway, if the old server is also a Yunohost, why not use a backup ? Create a backup on the old server
yunohost backup create --apps nextcloud
Then download the backup in the webadmin. Try also extract locally in the backupfile.tar
the file backupfile.info.json
transfer the backup on the new server
scp backupfile.tar my_user@domain.tld:~/
scp backupfile.info.json my_user@domain.tld:~/
Then on the new server
sudo -i
chown root: /home/my_user/backupfile.*
mv /home/my_user/backupfile.* /home/yunohost.backup/archives/
And restore the backup
yunohost backup restore backupfile
or via the webadmin